From 045bb0215268f3ffa3d2fffe11797c11f253e137 Mon Sep 17 00:00:00 2001 From: jolov Date: Wed, 13 Mar 2024 14:27:14 -0700 Subject: [PATCH 01/10] Generate bicep serialization for container apps --- ...ontainerAppAuthConfigData.Serialization.cs | 186 +++++++ .../Generated/ContainerAppAuthConfigData.cs | 5 + ...ntainerAppCertificateData.Serialization.cs | 175 +++++++ .../Generated/ContainerAppCertificateData.cs | 1 + ...pConnectedEnvironmentData.Serialization.cs | 286 +++++++++++ .../ContainerAppConnectedEnvironmentData.cs | 7 + ...tedEnvironmentStorageData.Serialization.cs | 127 +++++ ...ainerAppConnectedEnvironmentStorageData.cs | 1 + ...ainerAppDaprComponentData.Serialization.cs | 299 +++++++++++ .../ContainerAppDaprComponentData.cs | 8 + .../ContainerAppData.Serialization.cs | 435 ++++++++++++++++ .../src/Generated/ContainerAppData.cs | 15 + ...ontainerAppDiagnosticData.Serialization.cs | 127 +++++ .../Generated/ContainerAppDiagnosticData.cs | 1 + .../ContainerAppJobData.Serialization.cs | 321 ++++++++++++ .../src/Generated/ContainerAppJobData.cs | 8 + ...tainerAppJobExecutionData.Serialization.cs | 174 +++++++ .../Generated/ContainerAppJobExecutionData.cs | 4 + ...AppManagedCertificateData.Serialization.cs | 175 +++++++ .../ContainerAppManagedCertificateData.cs | 1 + ...AppManagedEnvironmentData.Serialization.cs | 467 ++++++++++++++++++ .../ContainerAppManagedEnvironmentData.cs | 17 + ...gedEnvironmentStorageData.Serialization.cs | 127 +++++ ...ntainerAppManagedEnvironmentStorageData.cs | 1 + .../ContainerAppReplicaData.Serialization.cs | 212 ++++++++ .../src/Generated/ContainerAppReplicaData.cs | 5 + .../ContainerAppRevisionData.Serialization.cs | 289 +++++++++++ .../src/Generated/ContainerAppRevisionData.cs | 11 + ...ainerAppSourceControlData.Serialization.cs | 180 +++++++ .../ContainerAppSourceControlData.cs | 4 + .../Generated/Internal/WirePathAttribute.cs | 27 + ...llowedAudiencesValidation.Serialization.cs | 99 ++++ .../Models/AllowedAudiencesValidation.cs | 1 + .../AppContainerResources.Serialization.cs | 121 +++++ .../Generated/Models/AppContainerResources.cs | 3 + .../AuthConfigCollection.Serialization.cs | 108 ++++ ...orkloadProfilesCollection.Serialization.cs | 108 ++++ ...StaticWebAppsRegistration.Serialization.cs | 85 ++++ .../Models/AzureStaticWebAppsRegistration.cs | 1 + .../BillingMeterCollection.Serialization.cs | 87 ++++ .../Models/BillingMeterCollection.cs | 1 + .../CertificateCollection.Serialization.cs | 108 ++++ ...ctedEnvironmentCollection.Serialization.cs | 108 ++++ ...ironmentStorageProperties.Serialization.cs | 77 +++ .../ConnectedEnvironmentStorageProperties.cs | 1 + ...ronmentStoragesCollection.Serialization.cs | 86 ++++ .../ConnectedEnvironmentStoragesCollection.cs | 1 + ...ainerAppAllowedPrincipals.Serialization.cs | 134 +++++ .../Models/ContainerAppAllowedPrincipals.cs | 2 + ...inerAppAppleConfiguration.Serialization.cs | 106 ++++ .../Models/ContainerAppAppleConfiguration.cs | 3 + ...RegistrationConfiguration.Serialization.cs | 107 ++++ ...tainerAppAppleRegistrationConfiguration.cs | 2 + .../ContainerAppAuthPlatform.Serialization.cs | 100 ++++ .../Models/ContainerAppAuthPlatform.cs | 2 + .../ContainerAppAuthToken.Serialization.cs | 201 ++++++++ .../Generated/Models/ContainerAppAuthToken.cs | 2 + ...pAvailableWorkloadProfile.Serialization.cs | 141 ++++++ .../ContainerAppAvailableWorkloadProfile.cs | 2 + ...WorkloadProfileProperties.Serialization.cs | 149 ++++++ ...erAppAvailableWorkloadProfileProperties.cs | 5 + ...iveDirectoryConfiguration.Serialization.cs | 135 +++++ ...nerAppAzureActiveDirectoryConfiguration.cs | 5 + ...rectoryLoginConfiguration.Serialization.cs | 114 +++++ ...pAzureActiveDirectoryLoginConfiguration.cs | 2 + ...RegistrationConfiguration.Serialization.cs | 195 ++++++++ ...ctiveDirectoryRegistrationConfiguration.cs | 6 + ...ryValidationConfiguration.Serialization.cs | 127 +++++ ...eActiveDirectoryValidationConfiguration.cs | 3 + ...nerAppAzureFileProperties.Serialization.cs | 143 ++++++ .../Models/ContainerAppAzureFileProperties.cs | 4 + ...taticWebAppsConfiguration.Serialization.cs | 92 ++++ ...ainerAppAzureStaticWebAppsConfiguration.cs | 2 + ...ContainerAppBaseContainer.Serialization.cs | 236 +++++++++ .../Models/ContainerAppBaseContainer.cs | 7 + .../ContainerAppBillingMeter.Serialization.cs | 141 ++++++ .../Models/ContainerAppBillingMeter.cs | 2 + ...AppBillingMeterProperties.Serialization.cs | 129 +++++ .../ContainerAppBillingMeterProperties.cs | 3 + .../Models/ContainerAppCertificatePatch.cs | 1 + ...rAppCertificateProperties.Serialization.cs | 282 +++++++++++ .../ContainerAppCertificateProperties.cs | 11 + ...inerAppClientRegistration.Serialization.cs | 107 ++++ .../Models/ContainerAppClientRegistration.cs | 2 + .../ContainerAppCollection.Serialization.cs | 108 ++++ ...ContainerAppConfiguration.Serialization.cs | 178 +++++++ .../Models/ContainerAppConfiguration.cs | 7 + .../ContainerAppContainer.Serialization.cs | 258 ++++++++++ .../Generated/Models/ContainerAppContainer.cs | 1 + ...tainerAppCookieExpiration.Serialization.cs | 99 ++++ .../Models/ContainerAppCookieExpiration.cs | 2 + .../ContainerAppCorsPolicy.Serialization.cs | 233 +++++++++ .../Models/ContainerAppCorsPolicy.cs | 6 + .../ContainerAppCredentials.Serialization.cs | 165 +++++++ .../Models/ContainerAppCredentials.cs | 5 + .../ContainerAppCustomDomain.Serialization.cs | 113 +++++ .../Models/ContainerAppCustomDomain.cs | 3 + ...CustomDomainConfiguration.Serialization.cs | 202 ++++++++ .../ContainerAppCustomDomainConfiguration.cs | 7 + ...inVerificationFailureInfo.Serialization.cs | 152 ++++++ ...rAppCustomDomainVerificationFailureInfo.cs | 4 + ...ionFailureInfoDetailsItem.Serialization.cs | 129 +++++ ...omainVerificationFailureInfoDetailsItem.cs | 3 + ...tomHostnameAnalysisResult.Serialization.cs | 356 +++++++++++++ ...ontainerAppCustomHostnameAnalysisResult.cs | 12 + ...nectProviderConfiguration.Serialization.cs | 106 ++++ ...ustomOpenIdConnectProviderConfiguration.cs | 3 + ...ntainerAppCustomScaleRule.Serialization.cs | 122 +++++ .../Models/ContainerAppCustomScaleRule.cs | 3 + ...ainerAppDaprConfiguration.Serialization.cs | 185 +++++++ .../Models/ContainerAppDaprConfiguration.cs | 8 + .../ContainerAppDaprMetadata.Serialization.cs | 129 +++++ .../Models/ContainerAppDaprMetadata.cs | 3 + .../ContainerAppDaprSecret.Serialization.cs | 107 ++++ .../Models/ContainerAppDaprSecret.cs | 2 + ...efaultAuthorizationPolicy.Serialization.cs | 113 +++++ .../ContainerAppDefaultAuthorizationPolicy.cs | 2 + ...erAppDiagnosticDataColumn.Serialization.cs | 129 +++++ .../ContainerAppDiagnosticDataColumn.cs | 3 + ...osticDataProviderMetadata.Serialization.cs | 108 ++++ ...tainerAppDiagnosticDataProviderMetadata.cs | 2 + ...erMetadataPropertyBagItem.Serialization.cs | 107 ++++ ...sticDataProviderMetadataPropertyBagItem.cs | 2 + ...DiagnosticDataTableResult.Serialization.cs | 135 +++++ .../ContainerAppDiagnosticDataTableResult.cs | 3 + ...nerAppDiagnosticRendering.Serialization.cs | 122 +++++ .../Models/ContainerAppDiagnosticRendering.cs | 4 + ...AppDiagnosticSupportTopic.Serialization.cs | 107 ++++ .../ContainerAppDiagnosticSupportTopic.cs | 2 + ...pDiagnosticsDataApiResult.Serialization.cs | 91 ++++ .../ContainerAppDiagnosticsDataApiResult.cs | 2 + ...nerAppDiagnosticsMetadata.Serialization.cs | 251 ++++++++++ .../Models/ContainerAppDiagnosticsMetadata.cs | 6 + ...rAppDiagnosticsProperties.Serialization.cs | 128 +++++ .../ContainerAppDiagnosticsProperties.cs | 4 + ...ainerAppDiagnosticsStatus.Serialization.cs | 99 ++++ .../Models/ContainerAppDiagnosticsStatus.cs | 2 + ...erAppEnvironmentAuthToken.Serialization.cs | 201 ++++++++ .../ContainerAppEnvironmentAuthToken.cs | 2 + ...nerAppEnvironmentVariable.Serialization.cs | 129 +++++ .../Models/ContainerAppEnvironmentVariable.cs | 3 + ...tainerAppExtendedLocation.Serialization.cs | 85 ++++ .../Models/ContainerAppExtendedLocation.cs | 2 + ...rAppFacebookConfiguration.Serialization.cs | 128 +++++ .../ContainerAppFacebookConfiguration.cs | 4 + .../ContainerAppForwardProxy.Serialization.cs | 121 +++++ .../Models/ContainerAppForwardProxy.cs | 3 + ...GitHubActionConfiguration.Serialization.cs | 245 +++++++++ .../ContainerAppGitHubActionConfiguration.cs | 9 + ...nerAppGitHubConfiguration.Serialization.cs | 106 ++++ .../Models/ContainerAppGitHubConfiguration.cs | 3 + ...tainerAppGlobalValidation.Serialization.cs | 135 +++++ .../Models/ContainerAppGlobalValidation.cs | 3 + ...nerAppGoogleConfiguration.Serialization.cs | 120 +++++ .../Models/ContainerAppGoogleConfiguration.cs | 4 + ...ontainerAppHttpHeaderInfo.Serialization.cs | 108 ++++ .../Models/ContainerAppHttpHeaderInfo.cs | 2 + ...ntainerAppHttpRequestInfo.Serialization.cs | 155 ++++++ .../Models/ContainerAppHttpRequestInfo.cs | 5 + ...ContainerAppHttpScaleRule.Serialization.cs | 122 +++++ .../Models/ContainerAppHttpScaleRule.cs | 2 + .../ContainerAppHttpSettings.Serialization.cs | 106 ++++ .../Models/ContainerAppHttpSettings.cs | 3 + ...IPSecurityRestrictionRule.Serialization.cs | 140 ++++++ .../ContainerAppIPSecurityRestrictionRule.cs | 4 + ...ityProvidersConfiguration.Serialization.cs | 185 +++++++ ...tainerAppIdentityProvidersConfiguration.cs | 8 + ...erAppIngressConfiguration.Serialization.cs | 266 ++++++++++ .../ContainerAppIngressConfiguration.cs | 12 + ...ContainerAppInitContainer.Serialization.cs | 236 +++++++++ ...tainerAppJobConfiguration.Serialization.cs | 186 +++++++ .../Models/ContainerAppJobConfiguration.cs | 8 + ...tainerAppJobExecutionBase.Serialization.cs | 107 ++++ .../Models/ContainerAppJobExecutionBase.cs | 2 + ...erAppJobExecutionTemplate.Serialization.cs | 108 ++++ .../ContainerAppJobExecutionTemplate.cs | 2 + ...ContainerAppJobExecutions.Serialization.cs | 108 ++++ .../Models/ContainerAppJobExecutions.cs | 2 + .../Generated/Models/ContainerAppJobPatch.cs | 3 + .../Models/ContainerAppJobPatchProperties.cs | 5 + .../ContainerAppJobScale.Serialization.cs | 128 +++++ .../Generated/Models/ContainerAppJobScale.cs | 4 + .../ContainerAppJobScaleRule.Serialization.cs | 122 +++++ .../Models/ContainerAppJobScaleRule.cs | 4 + .../ContainerAppJobTemplate.Serialization.cs | 130 +++++ .../Models/ContainerAppJobTemplate.cs | 3 + ...ontainerAppJobsCollection.Serialization.cs | 108 ++++ ...ontainerAppJwtClaimChecks.Serialization.cs | 134 +++++ .../Models/ContainerAppJwtClaimChecks.cs | 2 + ...LogAnalyticsConfiguration.Serialization.cs | 107 ++++ .../ContainerAppLogAnalyticsConfiguration.cs | 2 + .../Models/ContainerAppLogin.Serialization.cs | 156 ++++++ .../src/Generated/Models/ContainerAppLogin.cs | 5 + .../ContainerAppLoginNonce.Serialization.cs | 100 ++++ .../Models/ContainerAppLoginNonce.cs | 2 + ...ainerAppLogsConfiguration.Serialization.cs | 99 ++++ .../Models/ContainerAppLogsConfiguration.cs | 2 + .../ContainerAppManagedCertificatePatch.cs | 1 + .../ContainerAppNameAvailabilityContent.cs | 2 + ...AppNameAvailabilityResult.Serialization.cs | 114 +++++ .../ContainerAppNameAvailabilityResult.cs | 3 + ...IdConnectClientCredential.Serialization.cs | 99 ++++ ...ntainerAppOpenIdConnectClientCredential.cs | 2 + ...nerAppOpenIdConnectConfig.Serialization.cs | 165 +++++++ .../Models/ContainerAppOpenIdConnectConfig.cs | 5 + ...inerAppOpenIdConnectLogin.Serialization.cs | 121 +++++ .../Models/ContainerAppOpenIdConnectLogin.cs | 2 + ...OpenIdConnectRegistration.Serialization.cs | 113 +++++ .../ContainerAppOpenIdConnectRegistration.cs | 3 + .../Models/ContainerAppProbe.Serialization.cs | 175 +++++++ .../src/Generated/Models/ContainerAppProbe.cs | 9 + ...ontainerAppQueueScaleRule.Serialization.cs | 122 +++++ .../Models/ContainerAppQueueScaleRule.cs | 3 + .../ContainerAppRegistration.Serialization.cs | 107 ++++ .../Models/ContainerAppRegistration.cs | 2 + ...nerAppRegistryCredentials.Serialization.cs | 151 ++++++ .../Models/ContainerAppRegistryCredentials.cs | 4 + .../ContainerAppRegistryInfo.Serialization.cs | 129 +++++ .../Models/ContainerAppRegistryInfo.cs | 3 + ...tainerAppReplicaContainer.Serialization.cs | 231 +++++++++ .../Models/ContainerAppReplicaContainer.cs | 9 + ...rAppRevisionTrafficWeight.Serialization.cs | 136 +++++ .../ContainerAppRevisionTrafficWeight.cs | 4 + .../Models/ContainerAppScale.Serialization.cs | 114 +++++ .../src/Generated/Models/ContainerAppScale.cs | 3 + .../ContainerAppScaleRule.Serialization.cs | 141 ++++++ .../Generated/Models/ContainerAppScaleRule.cs | 5 + ...ContainerAppScaleRuleAuth.Serialization.cs | 107 ++++ .../Models/ContainerAppScaleRuleAuth.cs | 2 + .../ContainerAppSecret.Serialization.cs | 143 ++++++ .../Generated/Models/ContainerAppSecret.cs | 4 + .../ContainerAppServiceBind.Serialization.cs | 99 ++++ .../Models/ContainerAppServiceBind.cs | 2 + .../ContainerAppTcpScaleRule.Serialization.cs | 122 +++++ .../Models/ContainerAppTcpScaleRule.cs | 2 + ...erAppTcpSocketRequestInfo.Serialization.cs | 96 ++++ .../ContainerAppTcpSocketRequestInfo.cs | 2 + .../ContainerAppTemplate.Serialization.cs | 202 ++++++++ .../Generated/Models/ContainerAppTemplate.cs | 7 + ...erAppTwitterConfiguration.Serialization.cs | 92 ++++ .../ContainerAppTwitterConfiguration.cs | 2 + ...nerAppTwitterRegistration.Serialization.cs | 107 ++++ .../Models/ContainerAppTwitterRegistration.cs | 2 + ...ainerAppVnetConfiguration.Serialization.cs | 158 ++++++ .../Models/ContainerAppVnetConfiguration.cs | 5 + .../ContainerAppVolume.Serialization.cs | 166 +++++++ .../Generated/Models/ContainerAppVolume.cs | 5 + .../ContainerAppVolumeMount.Serialization.cs | 129 +++++ .../Models/ContainerAppVolumeMount.cs | 3 + ...ntainerAppWorkloadProfile.Serialization.cs | 135 +++++ .../Models/ContainerAppWorkloadProfile.cs | 4 + ...erAppWorkloadProfileState.Serialization.cs | 127 +++++ .../ContainerAppWorkloadProfileState.cs | 1 + ...oadProfileStateProperties.Serialization.cs | 105 ++++ ...tainerAppWorkloadProfileStateProperties.cs | 3 + ...ontainerAppWritableSecret.Serialization.cs | 143 ++++++ .../Models/ContainerAppWritableSecret.cs | 4 + .../DaprComponentsCollection.Serialization.cs | 108 ++++ .../Models/DaprConfiguration.Serialization.cs | 85 ++++ .../src/Generated/Models/DaprConfiguration.cs | 1 + .../DaprSecretsCollection.Serialization.cs | 87 ++++ .../Generated/Models/DaprSecretsCollection.cs | 1 + .../DiagnosticsCollection.Serialization.cs | 108 ++++ .../Generated/Models/DiagnosticsCollection.cs | 2 + ...EventTriggerConfiguration.Serialization.cs | 105 ++++ .../Models/EventTriggerConfiguration.cs | 3 + .../HttpSettingsRoutes.Serialization.cs | 85 ++++ .../Generated/Models/HttpSettingsRoutes.cs | 1 + .../IngressStickySessions.Serialization.cs | 77 +++ .../Generated/Models/IngressStickySessions.cs | 1 + ...rationManualTriggerConfig.Serialization.cs | 91 ++++ .../JobConfigurationManualTriggerConfig.cs | 2 + ...tionScheduleTriggerConfig.Serialization.cs | 113 +++++ .../JobConfigurationScheduleTriggerConfig.cs | 3 + .../JobExecutionContainer.Serialization.cs | 214 ++++++++ .../Generated/Models/JobExecutionContainer.cs | 6 + .../JobSecretsCollection.Serialization.cs | 87 ++++ .../Generated/Models/JobSecretsCollection.cs | 1 + .../Models/KedaConfiguration.Serialization.cs | 85 ++++ .../src/Generated/Models/KedaConfiguration.cs | 1 + .../Models/LoginRoutes.Serialization.cs | 85 ++++ .../src/Generated/Models/LoginRoutes.cs | 1 + .../Models/LoginScopes.Serialization.cs | 99 ++++ .../src/Generated/Models/LoginScopes.cs | 1 + ...agedCertificateCollection.Serialization.cs | 108 ++++ ...agedCertificateProperties.Serialization.cs | 157 ++++++ .../Models/ManagedCertificateProperties.cs | 5 + ...pertiesPeerAuthentication.Serialization.cs | 77 +++ ...EnvironmentPropertiesPeerAuthentication.cs | 1 + ...ironmentStorageProperties.Serialization.cs | 77 +++ .../ManagedEnvironmentStorageProperties.cs | 1 + ...ronmentStoragesCollection.Serialization.cs | 86 ++++ .../ManagedEnvironmentStoragesCollection.cs | 1 + ...gedEnvironmentsCollection.Serialization.cs | 108 ++++ .../Generated/Models/Mtls.Serialization.cs | 78 +++ .../src/Generated/Models/Mtls.cs | 1 + .../Models/ReplicaCollection.Serialization.cs | 86 ++++ .../src/Generated/Models/ReplicaCollection.cs | 1 + .../RevisionCollection.Serialization.cs | 108 ++++ .../Models/SecretVolumeItem.Serialization.cs | 107 ++++ .../src/Generated/Models/SecretVolumeItem.cs | 2 + .../Models/SecretsCollection.Serialization.cs | 87 ++++ .../src/Generated/Models/SecretsCollection.cs | 1 + .../Generated/Models/Service.Serialization.cs | 63 +++ .../src/Generated/Models/Service.cs | 1 + .../SourceControlCollection.Serialization.cs | 108 ++++ ...adProfileStatesCollection.Serialization.cs | 108 ++++ .../src/autorest.md | 1 + .../src/autorest.md | 1 + .../Generated/Internal/WirePathAttribute.cs | 27 + .../LogAnalyticsQueryData.Serialization.cs | 323 ++++++++++++ .../src/Generated/LogAnalyticsQueryData.cs | 10 + ...LogAnalyticsQueryPackData.Serialization.cs | 230 +++++++++ .../Generated/LogAnalyticsQueryPackData.cs | 4 + .../Models/ClusterListResult.Serialization.cs | 108 ++++ .../DataExportListResult.Serialization.cs | 86 ++++ .../DataSourceListResult.Serialization.cs | 108 ++++ .../LinkedServiceListResult.Serialization.cs | 86 ++++ ...StorageAccountsListResult.Serialization.cs | 86 ++++ ...lyticsQueryPackListResult.Serialization.cs | 108 ++++ .../Models/LogAnalyticsQueryPackPatch.cs | 1 + ...sQueryPackQueryListResult.Serialization.cs | 108 ++++ ...yticsQueryRelatedMetadata.Serialization.cs | 169 +++++++ .../LogAnalyticsQueryRelatedMetadata.cs | 3 + .../LogAnalyticsQuerySearchProperties.cs | 2 + .../LogAnalyticsQuerySearchRelatedMetadata.cs | 3 + ...ightsAvailableServiceTier.Serialization.cs | 163 ++++++ ...OperationalInsightsAvailableServiceTier.cs | 7 + ...cityReservationProperties.Serialization.cs | 92 ++++ ...alInsightsCapacityReservationProperties.cs | 2 + ...lusterAssociatedWorkspace.Serialization.cs | 128 +++++ ...ionalInsightsClusterAssociatedWorkspace.cs | 4 + .../Models/OperationalInsightsClusterPatch.cs | 5 + ...OperationalInsightsColumn.Serialization.cs | 173 +++++++ .../Models/OperationalInsightsColumn.cs | 7 + ...lInsightsIntelligencePack.Serialization.cs | 122 +++++ .../OperationalInsightsIntelligencePack.cs | 3 + ...nsightsKeyVaultProperties.Serialization.cs | 135 +++++ .../OperationalInsightsKeyVaultProperties.cs | 4 + ...alInsightsManagementGroup.Serialization.cs | 213 ++++++++ .../OperationalInsightsManagementGroup.cs | 8 + ...ationalInsightsMetricName.Serialization.cs | 107 ++++ .../Models/OperationalInsightsMetricName.cs | 2 + ...ateLinkScopedResourceInfo.Serialization.cs | 99 ++++ ...alInsightsPrivateLinkScopedResourceInfo.cs | 2 + ...OperationalInsightsSchema.Serialization.cs | 321 ++++++++++++ .../Models/OperationalInsightsSchema.cs | 11 + ...InsightsSearchCoreSummary.Serialization.cs | 96 ++++ .../OperationalInsightsSearchCoreSummary.cs | 2 + ...InsightsSearchSchemaValue.Serialization.cs | 179 +++++++ .../OperationalInsightsSearchSchemaValue.cs | 7 + ...nalInsightsStorageAccount.Serialization.cs | 100 ++++ .../OperationalInsightsStorageAccount.cs | 2 + ...InsightsTableRestoredLogs.Serialization.cs | 129 +++++ .../OperationalInsightsTableRestoredLogs.cs | 4 + ...ghtsTableResultStatistics.Serialization.cs | 105 ++++ ...perationalInsightsTableResultStatistics.cs | 3 + ...nsightsTableSearchResults.Serialization.cs | 187 +++++++ .../OperationalInsightsTableSearchResults.cs | 7 + .../OperationalInsightsTag.Serialization.cs | 108 ++++ .../Models/OperationalInsightsTag.cs | 2 + ...tionalInsightsUsageMetric.Serialization.cs | 164 ++++++ .../Models/OperationalInsightsUsageMetric.cs | 6 + ...lInsightsWorkspaceCapping.Serialization.cs | 113 +++++ .../OperationalInsightsWorkspaceCapping.cs | 3 + ...InsightsWorkspaceFeatures.Serialization.cs | 137 +++++ .../OperationalInsightsWorkspaceFeatures.cs | 6 + ...nalInsightsWorkspacePatch.Serialization.cs | 374 ++++++++++++++ .../OperationalInsightsWorkspacePatch.cs | 16 + ...perationalInsightsWorkspacePurgeContent.cs | 2 + ...OperationalInsightsWorkspacePurgeFilter.cs | 4 + ...ightsWorkspacePurgeResult.Serialization.cs | 86 ++++ ...OperationalInsightsWorkspacePurgeResult.cs | 1 + ...orkspacePurgeStatusResult.Serialization.cs | 74 +++ ...ionalInsightsWorkspacePurgeStatusResult.cs | 1 + ...sightsWorkspaceSharedKeys.Serialization.cs | 107 ++++ .../OperationalInsightsWorkspaceSharedKeys.cs | 2 + ...ionalInsightsWorkspaceSku.Serialization.cs | 103 ++++ .../Models/OperationalInsightsWorkspaceSku.cs | 3 + .../SavedSearchesListResult.Serialization.cs | 86 ++++ .../Models/SavedSearchesListResult.cs | 1 + .../SearchGetSchemaResponse.Serialization.cs | 100 ++++ .../Models/SearchGetSchemaResponse.cs | 2 + .../Models/SearchMetadata.Serialization.cs | 368 ++++++++++++++ .../src/Generated/Models/SearchMetadata.cs | 17 + .../SearchMetadataSchema.Serialization.cs | 99 ++++ .../Generated/Models/SearchMetadataSchema.cs | 2 + .../Models/SearchSort.Serialization.cs | 99 ++++ .../src/Generated/Models/SearchSort.cs | 2 + .../StorageInsightListResult.Serialization.cs | 108 ++++ .../StorageInsightStatus.Serialization.cs | 96 ++++ .../Generated/Models/StorageInsightStatus.cs | 2 + .../Models/TablesListResult.Serialization.cs | 86 ++++ ...istManagementGroupsResult.Serialization.cs | 86 ++++ .../WorkspaceListResult.Serialization.cs | 86 ++++ ...WorkspaceListUsagesResult.Serialization.cs | 86 ++++ ...tionalInsightsClusterData.Serialization.cs | 344 +++++++++++++ .../OperationalInsightsClusterData.cs | 12 + ...nalInsightsDataExportData.Serialization.cs | 267 ++++++++++ .../OperationalInsightsDataExportData.cs | 8 + ...nalInsightsDataSourceData.Serialization.cs | 189 +++++++ .../OperationalInsightsDataSourceData.cs | 4 + ...InsightsLinkedServiceData.Serialization.cs | 195 ++++++++ .../OperationalInsightsLinkedServiceData.cs | 4 + ...LinkedStorageAccountsData.Serialization.cs | 158 ++++++ ...tionalInsightsLinkedStorageAccountsData.cs | 2 + ...alInsightsSavedSearchData.Serialization.cs | 277 +++++++++++ .../OperationalInsightsSavedSearchData.cs | 8 + ...rationalInsightsTableData.Serialization.cs | 294 +++++++++++ .../Generated/OperationalInsightsTableData.cs | 12 + ...onalInsightsWorkspaceData.Serialization.cs | 385 +++++++++++++++ .../OperationalInsightsWorkspaceData.cs | 15 + .../StorageInsightData.Serialization.cs | 265 ++++++++++ .../src/Generated/StorageInsightData.cs | 6 + .../src/autorest.md | 1 + 415 files changed, 31584 insertions(+) create mode 100644 sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Internal/WirePathAttribute.cs create mode 100644 sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Internal/WirePathAttribute.cs diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppAuthConfigData.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppAuthConfigData.Serialization.cs index 97d08adcfcd1c..33f2868a60f5f 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppAuthConfigData.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppAuthConfigData.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers.Models; using Azure.ResourceManager.Models; @@ -227,6 +229,186 @@ internal static ContainerAppAuthConfigData DeserializeContainerAppAuthConfigData serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Platform), out propertyOverride); + if (Optional.IsDefined(Platform) || hasPropertyOverride) + { + builder.Append(" platform: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Platform, options, 4, false, " platform: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(GlobalValidation), out propertyOverride); + if (Optional.IsDefined(GlobalValidation) || hasPropertyOverride) + { + builder.Append(" globalValidation: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, GlobalValidation, options, 4, false, " globalValidation: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IdentityProviders), out propertyOverride); + if (Optional.IsDefined(IdentityProviders) || hasPropertyOverride) + { + builder.Append(" identityProviders: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, IdentityProviders, options, 4, false, " identityProviders: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Login), out propertyOverride); + if (Optional.IsDefined(Login) || hasPropertyOverride) + { + builder.Append(" login: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Login, options, 4, false, " login: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HttpSettings), out propertyOverride); + if (Optional.IsDefined(HttpSettings) || hasPropertyOverride) + { + builder.Append(" httpSettings: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, HttpSettings, options, 4, false, " httpSettings: "); + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -235,6 +417,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriter { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppAuthConfigData)} does not support '{options.Format}' format."); } @@ -251,6 +435,8 @@ ContainerAppAuthConfigData IPersistableModel.Create( using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppAuthConfigData(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppAuthConfigData)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppAuthConfigData.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppAuthConfigData.cs index 33809ee951a4b..0d3ef3cbdef1a 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppAuthConfigData.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppAuthConfigData.cs @@ -78,14 +78,19 @@ internal ContainerAppAuthConfigData(ResourceIdentifier id, string name, Resource } /// The configuration settings of the platform of ContainerApp Service Authentication/Authorization. + [WirePath("properties.platform")] public ContainerAppAuthPlatform Platform { get; set; } /// The configuration settings that determines the validation flow of users using Service Authentication/Authorization. + [WirePath("properties.globalValidation")] public ContainerAppGlobalValidation GlobalValidation { get; set; } /// The configuration settings of each of the identity providers used to configure ContainerApp Service Authentication/Authorization. + [WirePath("properties.identityProviders")] public ContainerAppIdentityProvidersConfiguration IdentityProviders { get; set; } /// The configuration settings of the login flow of users using ContainerApp Service Authentication/Authorization. + [WirePath("properties.login")] public ContainerAppLogin Login { get; set; } /// The configuration settings of the HTTP requests for authentication and authorization requests made against ContainerApp Service Authentication/Authorization. + [WirePath("properties.httpSettings")] public ContainerAppHttpSettings HttpSettings { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppCertificateData.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppCertificateData.Serialization.cs index e911a9d6b479b..309096c3b03cd 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppCertificateData.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppCertificateData.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers.Models; using Azure.ResourceManager.Models; @@ -184,6 +187,174 @@ internal static ContainerAppCertificateData DeserializeContainerAppCertificateDa serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); + builder.Append(" location: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Location.ToString()}'"); + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tags), out propertyOverride); + if (Optional.IsCollectionDefined(Tags) || hasPropertyOverride) + { + if (Tags.Any() || hasPropertyOverride) + { + builder.Append(" tags: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("{"); + foreach (var item in Tags) + { + builder.Append($" '{item.Key}': "); + if (item.Value == null) + { + builder.Append("null"); + continue; + } + if (item.Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{item.Value}'''"); + } + else + { + builder.AppendLine($"'{item.Value}'"); + } + } + builder.AppendLine(" }"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Properties), out propertyOverride); + if (Optional.IsDefined(Properties) || hasPropertyOverride) + { + builder.Append(" properties: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Properties, options, 2, false, " properties: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -192,6 +363,8 @@ BinaryData IPersistableModel.Write(ModelReaderWrite { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppCertificateData)} does not support '{options.Format}' format."); } @@ -208,6 +381,8 @@ ContainerAppCertificateData IPersistableModel.Creat using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppCertificateData(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppCertificateData)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppCertificateData.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppCertificateData.cs index 27ce675cd1aa8..2388553e9ba33 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppCertificateData.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppCertificateData.cs @@ -78,6 +78,7 @@ internal ContainerAppCertificateData() } /// Certificate resource specific properties. + [WirePath("properties")] public ContainerAppCertificateProperties Properties { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppConnectedEnvironmentData.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppConnectedEnvironmentData.Serialization.cs index 5560caa302b4f..acdcf374a0a40 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppConnectedEnvironmentData.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppConnectedEnvironmentData.Serialization.cs @@ -8,9 +8,12 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; using System.Net; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers.Models; using Azure.ResourceManager.Models; @@ -284,6 +287,285 @@ internal static ContainerAppConnectedEnvironmentData DeserializeContainerAppConn serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); + builder.Append(" location: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Location.ToString()}'"); + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tags), out propertyOverride); + if (Optional.IsCollectionDefined(Tags) || hasPropertyOverride) + { + if (Tags.Any() || hasPropertyOverride) + { + builder.Append(" tags: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("{"); + foreach (var item in Tags) + { + builder.Append($" '{item.Key}': "); + if (item.Value == null) + { + builder.Append("null"); + continue; + } + if (item.Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{item.Value}'''"); + } + else + { + builder.AppendLine($"'{item.Value}'"); + } + } + builder.AppendLine(" }"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExtendedLocation), out propertyOverride); + if (Optional.IsDefined(ExtendedLocation) || hasPropertyOverride) + { + builder.Append(" extendedLocation: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, ExtendedLocation, options, 2, false, " extendedLocation: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); + if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) + { + builder.Append(" provisioningState: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ProvisioningState.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DeploymentErrors), out propertyOverride); + if (Optional.IsDefined(DeploymentErrors) || hasPropertyOverride) + { + builder.Append(" deploymentErrors: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (DeploymentErrors.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{DeploymentErrors}'''"); + } + else + { + builder.AppendLine($"'{DeploymentErrors}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DefaultDomain), out propertyOverride); + if (Optional.IsDefined(DefaultDomain) || hasPropertyOverride) + { + builder.Append(" defaultDomain: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (DefaultDomain.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{DefaultDomain}'''"); + } + else + { + builder.AppendLine($"'{DefaultDomain}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StaticIP), out propertyOverride); + if (Optional.IsDefined(StaticIP) || hasPropertyOverride) + { + builder.Append(" staticIp: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{StaticIP.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DaprAIConnectionString), out propertyOverride); + if (Optional.IsDefined(DaprAIConnectionString) || hasPropertyOverride) + { + builder.Append(" daprAIConnectionString: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (DaprAIConnectionString.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{DaprAIConnectionString}'''"); + } + else + { + builder.AppendLine($"'{DaprAIConnectionString}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CustomDomainConfiguration), out propertyOverride); + if (Optional.IsDefined(CustomDomainConfiguration) || hasPropertyOverride) + { + builder.Append(" customDomainConfiguration: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, CustomDomainConfiguration, options, 4, false, " customDomainConfiguration: "); + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -292,6 +574,8 @@ BinaryData IPersistableModel.Write(ModelRe { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppConnectedEnvironmentData)} does not support '{options.Format}' format."); } @@ -308,6 +592,8 @@ ContainerAppConnectedEnvironmentData IPersistableModel The complex type of the extended location. + [WirePath("extendedLocation")] public ContainerAppExtendedLocation ExtendedLocation { get; set; } /// Provisioning state of the Kubernetes Environment. + [WirePath("properties.provisioningState")] public ContainerAppConnectedEnvironmentProvisioningState? ProvisioningState { get; } /// Any errors that occurred during deployment or deployment validation. + [WirePath("properties.deploymentErrors")] public string DeploymentErrors { get; } /// Default Domain Name for the cluster. + [WirePath("properties.defaultDomain")] public string DefaultDomain { get; } /// Static IP of the connectedEnvironment. + [WirePath("properties.staticIp")] public IPAddress StaticIP { get; set; } /// Application Insights connection string used by Dapr to export Service to Service communication telemetry. + [WirePath("properties.daprAIConnectionString")] public string DaprAIConnectionString { get; set; } /// Custom domain configuration for the environment. + [WirePath("properties.customDomainConfiguration")] public ContainerAppCustomDomainConfiguration CustomDomainConfiguration { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppConnectedEnvironmentStorageData.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppConnectedEnvironmentStorageData.Serialization.cs index 7fcd850217aa7..01709b130b18a 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppConnectedEnvironmentStorageData.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppConnectedEnvironmentStorageData.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers.Models; using Azure.ResourceManager.Models; @@ -148,6 +150,127 @@ internal static ContainerAppConnectedEnvironmentStorageData DeserializeContainer serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Properties), out propertyOverride); + if (Optional.IsDefined(Properties) || hasPropertyOverride) + { + builder.Append(" properties: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Properties, options, 2, false, " properties: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -156,6 +279,8 @@ BinaryData IPersistableModel.Write( { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppConnectedEnvironmentStorageData)} does not support '{options.Format}' format."); } @@ -172,6 +297,8 @@ ContainerAppConnectedEnvironmentStorageData IPersistableModel Storage properties. internal ConnectedEnvironmentStorageProperties Properties { get; set; } /// Azure file properties. + [WirePath("properties.azureFile")] public ContainerAppAzureFileProperties ConnectedEnvironmentStorageAzureFile { get => Properties is null ? default : Properties.AzureFile; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppDaprComponentData.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppDaprComponentData.Serialization.cs index 5687c08080933..ee6fb11789769 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppDaprComponentData.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppDaprComponentData.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers.Models; using Azure.ResourceManager.Models; @@ -289,6 +292,298 @@ internal static ContainerAppDaprComponentData DeserializeContainerAppDaprCompone serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ComponentType), out propertyOverride); + if (Optional.IsDefined(ComponentType) || hasPropertyOverride) + { + builder.Append(" componentType: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ComponentType.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ComponentType}'''"); + } + else + { + builder.AppendLine($"'{ComponentType}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Version), out propertyOverride); + if (Optional.IsDefined(Version) || hasPropertyOverride) + { + builder.Append(" version: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Version.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Version}'''"); + } + else + { + builder.AppendLine($"'{Version}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IgnoreErrors), out propertyOverride); + if (Optional.IsDefined(IgnoreErrors) || hasPropertyOverride) + { + builder.Append(" ignoreErrors: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IgnoreErrors.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(InitTimeout), out propertyOverride); + if (Optional.IsDefined(InitTimeout) || hasPropertyOverride) + { + builder.Append(" initTimeout: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (InitTimeout.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{InitTimeout}'''"); + } + else + { + builder.AppendLine($"'{InitTimeout}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Secrets), out propertyOverride); + if (Optional.IsCollectionDefined(Secrets) || hasPropertyOverride) + { + if (Secrets.Any() || hasPropertyOverride) + { + builder.Append(" secrets: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Secrets) + { + AppendChildObject(builder, item, options, 6, true, " secrets: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SecretStoreComponent), out propertyOverride); + if (Optional.IsDefined(SecretStoreComponent) || hasPropertyOverride) + { + builder.Append(" secretStoreComponent: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (SecretStoreComponent.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{SecretStoreComponent}'''"); + } + else + { + builder.AppendLine($"'{SecretStoreComponent}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Metadata), out propertyOverride); + if (Optional.IsCollectionDefined(Metadata) || hasPropertyOverride) + { + if (Metadata.Any() || hasPropertyOverride) + { + builder.Append(" metadata: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Metadata) + { + AppendChildObject(builder, item, options, 6, true, " metadata: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Scopes), out propertyOverride); + if (Optional.IsCollectionDefined(Scopes) || hasPropertyOverride) + { + if (Scopes.Any() || hasPropertyOverride) + { + builder.Append(" scopes: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Scopes) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -297,6 +592,8 @@ BinaryData IPersistableModel.Write(ModelReaderWri { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppDaprComponentData)} does not support '{options.Format}' format."); } @@ -313,6 +610,8 @@ ContainerAppDaprComponentData IPersistableModel.C using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppDaprComponentData(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppDaprComponentData)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppDaprComponentData.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppDaprComponentData.cs index 8e7dbbf67d59e..49fb698e99c3c 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppDaprComponentData.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppDaprComponentData.cs @@ -87,20 +87,28 @@ internal ContainerAppDaprComponentData(ResourceIdentifier id, string name, Resou } /// Component type. + [WirePath("properties.componentType")] public string ComponentType { get; set; } /// Component version. + [WirePath("properties.version")] public string Version { get; set; } /// Boolean describing if the component errors are ignores. + [WirePath("properties.ignoreErrors")] public bool? IgnoreErrors { get; set; } /// Initialization timeout. + [WirePath("properties.initTimeout")] public string InitTimeout { get; set; } /// Collection of secrets used by a Dapr component. + [WirePath("properties.secrets")] public IList Secrets { get; } /// Name of a Dapr component to retrieve component secrets from. + [WirePath("properties.secretStoreComponent")] public string SecretStoreComponent { get; set; } /// Component metadata. + [WirePath("properties.metadata")] public IList Metadata { get; } /// Names of container apps that can use this Dapr component. + [WirePath("properties.scopes")] public IList Scopes { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppData.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppData.Serialization.cs index b83f31dbe724a..8feae7db281f6 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppData.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppData.Serialization.cs @@ -8,9 +8,12 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; using System.Net; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers.Models; using Azure.ResourceManager.Models; @@ -424,6 +427,434 @@ internal static ContainerAppData DeserializeContainerAppData(JsonElement element serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); + builder.Append(" location: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Location.ToString()}'"); + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tags), out propertyOverride); + if (Optional.IsCollectionDefined(Tags) || hasPropertyOverride) + { + if (Tags.Any() || hasPropertyOverride) + { + builder.Append(" tags: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("{"); + foreach (var item in Tags) + { + builder.Append($" '{item.Key}': "); + if (item.Value == null) + { + builder.Append("null"); + continue; + } + if (item.Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{item.Value}'''"); + } + else + { + builder.AppendLine($"'{item.Value}'"); + } + } + builder.AppendLine(" }"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExtendedLocation), out propertyOverride); + if (Optional.IsDefined(ExtendedLocation) || hasPropertyOverride) + { + builder.Append(" extendedLocation: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, ExtendedLocation, options, 2, false, " extendedLocation: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Identity), out propertyOverride); + if (Optional.IsDefined(Identity) || hasPropertyOverride) + { + builder.Append(" identity: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Identity, options, 2, false, " identity: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ManagedBy), out propertyOverride); + if (Optional.IsDefined(ManagedBy) || hasPropertyOverride) + { + builder.Append(" managedBy: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ManagedBy.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ManagedBy}'''"); + } + else + { + builder.AppendLine($"'{ManagedBy}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); + if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) + { + builder.Append(" provisioningState: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ProvisioningState.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ManagedEnvironmentId), out propertyOverride); + if (Optional.IsDefined(ManagedEnvironmentId) || hasPropertyOverride) + { + builder.Append(" managedEnvironmentId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ManagedEnvironmentId.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EnvironmentId), out propertyOverride); + if (Optional.IsDefined(EnvironmentId) || hasPropertyOverride) + { + builder.Append(" environmentId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{EnvironmentId.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(WorkloadProfileName), out propertyOverride); + if (Optional.IsDefined(WorkloadProfileName) || hasPropertyOverride) + { + builder.Append(" workloadProfileName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (WorkloadProfileName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{WorkloadProfileName}'''"); + } + else + { + builder.AppendLine($"'{WorkloadProfileName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LatestRevisionName), out propertyOverride); + if (Optional.IsDefined(LatestRevisionName) || hasPropertyOverride) + { + builder.Append(" latestRevisionName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (LatestRevisionName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{LatestRevisionName}'''"); + } + else + { + builder.AppendLine($"'{LatestRevisionName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LatestReadyRevisionName), out propertyOverride); + if (Optional.IsDefined(LatestReadyRevisionName) || hasPropertyOverride) + { + builder.Append(" latestReadyRevisionName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (LatestReadyRevisionName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{LatestReadyRevisionName}'''"); + } + else + { + builder.AppendLine($"'{LatestReadyRevisionName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LatestRevisionFqdn), out propertyOverride); + if (Optional.IsDefined(LatestRevisionFqdn) || hasPropertyOverride) + { + builder.Append(" latestRevisionFqdn: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (LatestRevisionFqdn.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{LatestRevisionFqdn}'''"); + } + else + { + builder.AppendLine($"'{LatestRevisionFqdn}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CustomDomainVerificationId), out propertyOverride); + if (Optional.IsDefined(CustomDomainVerificationId) || hasPropertyOverride) + { + builder.Append(" customDomainVerificationId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (CustomDomainVerificationId.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{CustomDomainVerificationId}'''"); + } + else + { + builder.AppendLine($"'{CustomDomainVerificationId}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Configuration), out propertyOverride); + if (Optional.IsDefined(Configuration) || hasPropertyOverride) + { + builder.Append(" configuration: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Configuration, options, 4, false, " configuration: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Template), out propertyOverride); + if (Optional.IsDefined(Template) || hasPropertyOverride) + { + builder.Append(" template: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Template, options, 4, false, " template: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(OutboundIPAddressList), out propertyOverride); + if (Optional.IsCollectionDefined(OutboundIPAddressList) || hasPropertyOverride) + { + if (OutboundIPAddressList.Any() || hasPropertyOverride) + { + builder.Append(" outboundIpAddresses: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in OutboundIPAddressList) + { + if (item == null) + { + builder.Append("null"); + continue; + } + builder.AppendLine($" '{item.ToString()}'"); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EventStreamEndpoint), out propertyOverride); + if (Optional.IsDefined(EventStreamEndpoint) || hasPropertyOverride) + { + builder.Append(" eventStreamEndpoint: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{EventStreamEndpoint.AbsoluteUri}'"); + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -432,6 +863,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions op { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppData)} does not support '{options.Format}' format."); } @@ -448,6 +881,8 @@ ContainerAppData IPersistableModel.Create(BinaryData data, Mod using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppData(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppData)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppData.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppData.cs index bff79085ffeb6..ba685778ca556 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppData.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppData.cs @@ -108,34 +108,49 @@ internal ContainerAppData() } /// The complex type of the extended location. + [WirePath("extendedLocation")] public ContainerAppExtendedLocation ExtendedLocation { get; set; } /// managed identities for the Container App to interact with other Azure services without maintaining any secrets or credentials in code. + [WirePath("identity")] public ManagedServiceIdentity Identity { get; set; } /// The fully qualified resource ID of the resource that manages this resource. Indicates if this resource is managed by another Azure resource. If this is present, complete mode deployment will not delete the resource if it is removed from the template since it is managed by another resource. + [WirePath("managedBy")] public string ManagedBy { get; set; } /// Provisioning state of the Container App. + [WirePath("properties.provisioningState")] public ContainerAppProvisioningState? ProvisioningState { get; } /// Deprecated. Resource ID of the Container App's environment. + [WirePath("properties.managedEnvironmentId")] public ResourceIdentifier ManagedEnvironmentId { get; set; } /// Resource ID of environment. + [WirePath("properties.environmentId")] public ResourceIdentifier EnvironmentId { get; set; } /// Workload profile name to pin for container app execution. + [WirePath("properties.workloadProfileName")] public string WorkloadProfileName { get; set; } /// Name of the latest revision of the Container App. + [WirePath("properties.latestRevisionName")] public string LatestRevisionName { get; } /// Name of the latest ready revision of the Container App. + [WirePath("properties.latestReadyRevisionName")] public string LatestReadyRevisionName { get; } /// Fully Qualified Domain Name of the latest revision of the Container App. + [WirePath("properties.latestRevisionFqdn")] public string LatestRevisionFqdn { get; } /// Id used to verify domain name ownership. + [WirePath("properties.customDomainVerificationId")] public string CustomDomainVerificationId { get; } /// Non versioned Container App configuration properties. + [WirePath("properties.configuration")] public ContainerAppConfiguration Configuration { get; set; } /// Container App versioned application definition. + [WirePath("properties.template")] public ContainerAppTemplate Template { get; set; } /// Outbound IP Addresses for container app. + [WirePath("properties.outboundIpAddresses")] public IReadOnlyList OutboundIPAddressList { get; } /// The endpoint of the eventstream of the container app. + [WirePath("properties.eventStreamEndpoint")] public Uri EventStreamEndpoint { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppDiagnosticData.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppDiagnosticData.Serialization.cs index 03d721947fdf6..4854d060aa8ef 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppDiagnosticData.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppDiagnosticData.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers.Models; using Azure.ResourceManager.Models; @@ -148,6 +150,127 @@ internal static ContainerAppDiagnosticData DeserializeContainerAppDiagnosticData serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Properties), out propertyOverride); + if (Optional.IsDefined(Properties) || hasPropertyOverride) + { + builder.Append(" properties: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Properties, options, 2, false, " properties: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -156,6 +279,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriter { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppDiagnosticData)} does not support '{options.Format}' format."); } @@ -172,6 +297,8 @@ ContainerAppDiagnosticData IPersistableModel.Create( using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppDiagnosticData(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppDiagnosticData)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppDiagnosticData.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppDiagnosticData.cs index afbcf72374d9e..3bcf8d719315b 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppDiagnosticData.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppDiagnosticData.cs @@ -70,6 +70,7 @@ internal ContainerAppDiagnosticData(ResourceIdentifier id, string name, Resource } /// Diagnostics resource specific properties. + [WirePath("properties")] public ContainerAppDiagnosticsProperties Properties { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppJobData.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppJobData.Serialization.cs index 31af3f9249493..863ff8173f9d9 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppJobData.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppJobData.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers.Models; using Azure.ResourceManager.Models; @@ -311,6 +314,320 @@ internal static ContainerAppJobData DeserializeContainerAppJobData(JsonElement e serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); + builder.Append(" location: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Location.ToString()}'"); + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tags), out propertyOverride); + if (Optional.IsCollectionDefined(Tags) || hasPropertyOverride) + { + if (Tags.Any() || hasPropertyOverride) + { + builder.Append(" tags: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("{"); + foreach (var item in Tags) + { + builder.Append($" '{item.Key}': "); + if (item.Value == null) + { + builder.Append("null"); + continue; + } + if (item.Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{item.Value}'''"); + } + else + { + builder.AppendLine($"'{item.Value}'"); + } + } + builder.AppendLine(" }"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Identity), out propertyOverride); + if (Optional.IsDefined(Identity) || hasPropertyOverride) + { + builder.Append(" identity: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Identity, options, 2, false, " identity: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); + if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) + { + builder.Append(" provisioningState: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ProvisioningState.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EnvironmentId), out propertyOverride); + if (Optional.IsDefined(EnvironmentId) || hasPropertyOverride) + { + builder.Append(" environmentId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (EnvironmentId.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{EnvironmentId}'''"); + } + else + { + builder.AppendLine($"'{EnvironmentId}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(WorkloadProfileName), out propertyOverride); + if (Optional.IsDefined(WorkloadProfileName) || hasPropertyOverride) + { + builder.Append(" workloadProfileName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (WorkloadProfileName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{WorkloadProfileName}'''"); + } + else + { + builder.AppendLine($"'{WorkloadProfileName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Configuration), out propertyOverride); + if (Optional.IsDefined(Configuration) || hasPropertyOverride) + { + builder.Append(" configuration: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Configuration, options, 4, false, " configuration: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Template), out propertyOverride); + if (Optional.IsDefined(Template) || hasPropertyOverride) + { + builder.Append(" template: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Template, options, 4, false, " template: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(OutboundIPAddresses), out propertyOverride); + if (Optional.IsCollectionDefined(OutboundIPAddresses) || hasPropertyOverride) + { + if (OutboundIPAddresses.Any() || hasPropertyOverride) + { + builder.Append(" outboundIpAddresses: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in OutboundIPAddresses) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EventStreamEndpoint), out propertyOverride); + if (Optional.IsDefined(EventStreamEndpoint) || hasPropertyOverride) + { + builder.Append(" eventStreamEndpoint: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (EventStreamEndpoint.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{EventStreamEndpoint}'''"); + } + else + { + builder.AppendLine($"'{EventStreamEndpoint}'"); + } + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -319,6 +636,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppJobData)} does not support '{options.Format}' format."); } @@ -335,6 +654,8 @@ ContainerAppJobData IPersistableModel.Create(BinaryData dat using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppJobData(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppJobData)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppJobData.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppJobData.cs index fd70748083b80..40211d2d2de89 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppJobData.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppJobData.cs @@ -93,20 +93,28 @@ internal ContainerAppJobData() } /// Managed identities needed by a container app job to interact with other Azure services to not maintain any secrets or credentials in code. + [WirePath("identity")] public ManagedServiceIdentity Identity { get; set; } /// Provisioning state of the Container Apps Job. + [WirePath("properties.provisioningState")] public ContainerAppJobProvisioningState? ProvisioningState { get; } /// Resource ID of environment. + [WirePath("properties.environmentId")] public string EnvironmentId { get; set; } /// Workload profile name to pin for container apps job execution. + [WirePath("properties.workloadProfileName")] public string WorkloadProfileName { get; set; } /// Container Apps Job configuration properties. + [WirePath("properties.configuration")] public ContainerAppJobConfiguration Configuration { get; set; } /// Container Apps job definition. + [WirePath("properties.template")] public ContainerAppJobTemplate Template { get; set; } /// Outbound IP Addresses of a container apps job. + [WirePath("properties.outboundIpAddresses")] public IReadOnlyList OutboundIPAddresses { get; } /// The endpoint of the eventstream of the container apps job. + [WirePath("properties.eventStreamEndpoint")] public string EventStreamEndpoint { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppJobExecutionData.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppJobExecutionData.Serialization.cs index 9e440b0a8c141..9d3f4c7e55475 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppJobExecutionData.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppJobExecutionData.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers.Models; using Azure.ResourceManager.Models; @@ -211,6 +213,174 @@ internal static ContainerAppJobExecutionData DeserializeContainerAppJobExecution serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); + if (Optional.IsDefined(Status) || hasPropertyOverride) + { + builder.Append(" status: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Status.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartOn), out propertyOverride); + if (Optional.IsDefined(StartOn) || hasPropertyOverride) + { + builder.Append(" startTime: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(StartOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EndOn), out propertyOverride); + if (Optional.IsDefined(EndOn) || hasPropertyOverride) + { + builder.Append(" endTime: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(EndOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Template), out propertyOverride); + if (Optional.IsDefined(Template) || hasPropertyOverride) + { + builder.Append(" template: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Template, options, 4, false, " template: "); + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -219,6 +389,8 @@ BinaryData IPersistableModel.Write(ModelReaderWrit { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppJobExecutionData)} does not support '{options.Format}' format."); } @@ -235,6 +407,8 @@ ContainerAppJobExecutionData IPersistableModel.Cre using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppJobExecutionData(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppJobExecutionData)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppJobExecutionData.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppJobExecutionData.cs index 6402f60c1c403..0ef15cdf88637 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppJobExecutionData.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppJobExecutionData.cs @@ -76,12 +76,16 @@ internal ContainerAppJobExecutionData(ResourceIdentifier id, string name, Resour } /// Current running State of the job. + [WirePath("status")] public JobExecutionRunningState? Status { get; } /// Job execution start time. + [WirePath("startTime")] public DateTimeOffset? StartOn { get; } /// Job execution end time. + [WirePath("endTime")] public DateTimeOffset? EndOn { get; } /// Job's execution container. + [WirePath("template")] public ContainerAppJobExecutionTemplate Template { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppManagedCertificateData.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppManagedCertificateData.Serialization.cs index d77ee9218213c..30e34388e9abb 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppManagedCertificateData.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppManagedCertificateData.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers.Models; using Azure.ResourceManager.Models; @@ -184,6 +187,174 @@ internal static ContainerAppManagedCertificateData DeserializeContainerAppManage serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); + builder.Append(" location: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Location.ToString()}'"); + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tags), out propertyOverride); + if (Optional.IsCollectionDefined(Tags) || hasPropertyOverride) + { + if (Tags.Any() || hasPropertyOverride) + { + builder.Append(" tags: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("{"); + foreach (var item in Tags) + { + builder.Append($" '{item.Key}': "); + if (item.Value == null) + { + builder.Append("null"); + continue; + } + if (item.Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{item.Value}'''"); + } + else + { + builder.AppendLine($"'{item.Value}'"); + } + } + builder.AppendLine(" }"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Properties), out propertyOverride); + if (Optional.IsDefined(Properties) || hasPropertyOverride) + { + builder.Append(" properties: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Properties, options, 2, false, " properties: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -192,6 +363,8 @@ BinaryData IPersistableModel.Write(ModelRead { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppManagedCertificateData)} does not support '{options.Format}' format."); } @@ -208,6 +381,8 @@ ContainerAppManagedCertificateData IPersistableModel Certificate resource specific properties. + [WirePath("properties")] public ManagedCertificateProperties Properties { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppManagedEnvironmentData.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppManagedEnvironmentData.Serialization.cs index d424eb7e0a779..525f88f6bc2ed 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppManagedEnvironmentData.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppManagedEnvironmentData.Serialization.cs @@ -8,9 +8,12 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; using System.Net; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers.Models; using Azure.ResourceManager.Models; @@ -438,6 +441,466 @@ internal static ContainerAppManagedEnvironmentData DeserializeContainerAppManage serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); + builder.Append(" location: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Location.ToString()}'"); + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tags), out propertyOverride); + if (Optional.IsCollectionDefined(Tags) || hasPropertyOverride) + { + if (Tags.Any() || hasPropertyOverride) + { + builder.Append(" tags: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("{"); + foreach (var item in Tags) + { + builder.Append($" '{item.Key}': "); + if (item.Value == null) + { + builder.Append("null"); + continue; + } + if (item.Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{item.Value}'''"); + } + else + { + builder.AppendLine($"'{item.Value}'"); + } + } + builder.AppendLine(" }"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); + if (Optional.IsDefined(Kind) || hasPropertyOverride) + { + builder.Append(" kind: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Kind.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Kind}'''"); + } + else + { + builder.AppendLine($"'{Kind}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); + if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) + { + builder.Append(" provisioningState: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ProvisioningState.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DaprAIInstrumentationKey), out propertyOverride); + if (Optional.IsDefined(DaprAIInstrumentationKey) || hasPropertyOverride) + { + builder.Append(" daprAIInstrumentationKey: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (DaprAIInstrumentationKey.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{DaprAIInstrumentationKey}'''"); + } + else + { + builder.AppendLine($"'{DaprAIInstrumentationKey}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DaprAIConnectionString), out propertyOverride); + if (Optional.IsDefined(DaprAIConnectionString) || hasPropertyOverride) + { + builder.Append(" daprAIConnectionString: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (DaprAIConnectionString.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{DaprAIConnectionString}'''"); + } + else + { + builder.AppendLine($"'{DaprAIConnectionString}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(VnetConfiguration), out propertyOverride); + if (Optional.IsDefined(VnetConfiguration) || hasPropertyOverride) + { + builder.Append(" vnetConfiguration: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, VnetConfiguration, options, 4, false, " vnetConfiguration: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DeploymentErrors), out propertyOverride); + if (Optional.IsDefined(DeploymentErrors) || hasPropertyOverride) + { + builder.Append(" deploymentErrors: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (DeploymentErrors.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{DeploymentErrors}'''"); + } + else + { + builder.AppendLine($"'{DeploymentErrors}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DefaultDomain), out propertyOverride); + if (Optional.IsDefined(DefaultDomain) || hasPropertyOverride) + { + builder.Append(" defaultDomain: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (DefaultDomain.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{DefaultDomain}'''"); + } + else + { + builder.AppendLine($"'{DefaultDomain}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StaticIP), out propertyOverride); + if (Optional.IsDefined(StaticIP) || hasPropertyOverride) + { + builder.Append(" staticIp: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{StaticIP.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AppLogsConfiguration), out propertyOverride); + if (Optional.IsDefined(AppLogsConfiguration) || hasPropertyOverride) + { + builder.Append(" appLogsConfiguration: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, AppLogsConfiguration, options, 4, false, " appLogsConfiguration: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsZoneRedundant), out propertyOverride); + if (Optional.IsDefined(IsZoneRedundant) || hasPropertyOverride) + { + builder.Append(" zoneRedundant: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsZoneRedundant.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CustomDomainConfiguration), out propertyOverride); + if (Optional.IsDefined(CustomDomainConfiguration) || hasPropertyOverride) + { + builder.Append(" customDomainConfiguration: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, CustomDomainConfiguration, options, 4, false, " customDomainConfiguration: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EventStreamEndpoint), out propertyOverride); + if (Optional.IsDefined(EventStreamEndpoint) || hasPropertyOverride) + { + builder.Append(" eventStreamEndpoint: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (EventStreamEndpoint.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{EventStreamEndpoint}'''"); + } + else + { + builder.AppendLine($"'{EventStreamEndpoint}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(WorkloadProfiles), out propertyOverride); + if (Optional.IsCollectionDefined(WorkloadProfiles) || hasPropertyOverride) + { + if (WorkloadProfiles.Any() || hasPropertyOverride) + { + builder.Append(" workloadProfiles: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in WorkloadProfiles) + { + AppendChildObject(builder, item, options, 6, true, " workloadProfiles: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KedaConfiguration), out propertyOverride); + if (Optional.IsDefined(KedaConfiguration) || hasPropertyOverride) + { + builder.Append(" kedaConfiguration: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, KedaConfiguration, options, 4, false, " kedaConfiguration: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DaprConfiguration), out propertyOverride); + if (Optional.IsDefined(DaprConfiguration) || hasPropertyOverride) + { + builder.Append(" daprConfiguration: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, DaprConfiguration, options, 4, false, " daprConfiguration: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(InfrastructureResourceGroup), out propertyOverride); + if (Optional.IsDefined(InfrastructureResourceGroup) || hasPropertyOverride) + { + builder.Append(" infrastructureResourceGroup: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (InfrastructureResourceGroup.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{InfrastructureResourceGroup}'''"); + } + else + { + builder.AppendLine($"'{InfrastructureResourceGroup}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PeerAuthentication), out propertyOverride); + if (Optional.IsDefined(PeerAuthentication) || hasPropertyOverride) + { + builder.Append(" peerAuthentication: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, PeerAuthentication, options, 4, false, " peerAuthentication: "); + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -446,6 +909,8 @@ BinaryData IPersistableModel.Write(ModelRead { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppManagedEnvironmentData)} does not support '{options.Format}' format."); } @@ -462,6 +927,8 @@ ContainerAppManagedEnvironmentData IPersistableModel Kind of the Environment. + [WirePath("kind")] public string Kind { get; set; } /// Provisioning state of the Environment. + [WirePath("properties.provisioningState")] public ContainerAppEnvironmentProvisioningState? ProvisioningState { get; } /// Azure Monitor instrumentation key used by Dapr to export Service to Service communication telemetry. + [WirePath("properties.daprAIInstrumentationKey")] public string DaprAIInstrumentationKey { get; set; } /// Application Insights connection string used by Dapr to export Service to Service communication telemetry. + [WirePath("properties.daprAIConnectionString")] public string DaprAIConnectionString { get; set; } /// Vnet configuration for the environment. + [WirePath("properties.vnetConfiguration")] public ContainerAppVnetConfiguration VnetConfiguration { get; set; } /// Any errors that occurred during deployment or deployment validation. + [WirePath("properties.deploymentErrors")] public string DeploymentErrors { get; } /// Default Domain Name for the cluster. + [WirePath("properties.defaultDomain")] public string DefaultDomain { get; } /// Static IP of the Environment. + [WirePath("properties.staticIp")] public IPAddress StaticIP { get; } /// /// Cluster configuration which enables the log daemon to export /// app logs to a destination. Currently only "log-analytics" is /// supported /// + [WirePath("properties.appLogsConfiguration")] public ContainerAppLogsConfiguration AppLogsConfiguration { get; set; } /// Whether or not this Managed Environment is zone-redundant. + [WirePath("properties.zoneRedundant")] public bool? IsZoneRedundant { get; set; } /// Custom domain configuration for the environment. + [WirePath("properties.customDomainConfiguration")] public ContainerAppCustomDomainConfiguration CustomDomainConfiguration { get; set; } /// The endpoint of the eventstream of the Environment. + [WirePath("properties.eventStreamEndpoint")] public string EventStreamEndpoint { get; } /// Workload profiles configured for the Managed Environment. + [WirePath("properties.workloadProfiles")] public IList WorkloadProfiles { get; } /// The configuration of Keda component. internal KedaConfiguration KedaConfiguration { get; set; } /// The version of Keda. + [WirePath("properties.kedaConfiguration.version")] public string KedaVersion { get => KedaConfiguration is null ? default : KedaConfiguration.Version; @@ -156,16 +170,19 @@ public string KedaVersion /// The configuration of Dapr component. internal DaprConfiguration DaprConfiguration { get; set; } /// The version of Dapr. + [WirePath("properties.daprConfiguration.version")] public string DaprVersion { get => DaprConfiguration is null ? default : DaprConfiguration.Version; } /// Name of the platform-managed resource group created for the Managed Environment to host infrastructure resources. If a subnet ID is provided, this resource group will be created in the same subscription as the subnet. + [WirePath("properties.infrastructureResourceGroup")] public string InfrastructureResourceGroup { get; set; } /// Peer authentication settings for the Managed Environment. internal ManagedEnvironmentPropertiesPeerAuthentication PeerAuthentication { get; set; } /// Boolean indicating whether the mutual TLS authentication is enabled. + [WirePath("properties.peerAuthentication.mtls.enabled")] public bool? IsMtlsEnabled { get => PeerAuthentication is null ? default : PeerAuthentication.IsMtlsEnabled; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppManagedEnvironmentStorageData.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppManagedEnvironmentStorageData.Serialization.cs index 08df790ae2648..6cb1fae7df143 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppManagedEnvironmentStorageData.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppManagedEnvironmentStorageData.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers.Models; using Azure.ResourceManager.Models; @@ -148,6 +150,127 @@ internal static ContainerAppManagedEnvironmentStorageData DeserializeContainerAp serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Properties), out propertyOverride); + if (Optional.IsDefined(Properties) || hasPropertyOverride) + { + builder.Append(" properties: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Properties, options, 2, false, " properties: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -156,6 +279,8 @@ BinaryData IPersistableModel.Write(Mo { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppManagedEnvironmentStorageData)} does not support '{options.Format}' format."); } @@ -172,6 +297,8 @@ ContainerAppManagedEnvironmentStorageData IPersistableModel Storage properties. internal ManagedEnvironmentStorageProperties Properties { get; set; } /// Azure file properties. + [WirePath("properties.azureFile")] public ContainerAppAzureFileProperties ManagedEnvironmentStorageAzureFile { get => Properties is null ? default : Properties.AzureFile; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppReplicaData.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppReplicaData.Serialization.cs index 7368bc8c07c1b..ac24ff556f909 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppReplicaData.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppReplicaData.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers.Models; using Azure.ResourceManager.Models; @@ -243,6 +246,211 @@ internal static ContainerAppReplicaData DeserializeContainerAppReplicaData(JsonE serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); + if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) + { + builder.Append(" createdTime: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RunningState), out propertyOverride); + if (Optional.IsDefined(RunningState) || hasPropertyOverride) + { + builder.Append(" runningState: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{RunningState.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RunningStateDetails), out propertyOverride); + if (Optional.IsDefined(RunningStateDetails) || hasPropertyOverride) + { + builder.Append(" runningStateDetails: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (RunningStateDetails.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{RunningStateDetails}'''"); + } + else + { + builder.AppendLine($"'{RunningStateDetails}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Containers), out propertyOverride); + if (Optional.IsCollectionDefined(Containers) || hasPropertyOverride) + { + if (Containers.Any() || hasPropertyOverride) + { + builder.Append(" containers: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Containers) + { + AppendChildObject(builder, item, options, 6, true, " containers: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(InitContainers), out propertyOverride); + if (Optional.IsCollectionDefined(InitContainers) || hasPropertyOverride) + { + if (InitContainers.Any() || hasPropertyOverride) + { + builder.Append(" initContainers: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in InitContainers) + { + AppendChildObject(builder, item, options, 6, true, " initContainers: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -251,6 +459,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpt { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppReplicaData)} does not support '{options.Format}' format."); } @@ -267,6 +477,8 @@ ContainerAppReplicaData IPersistableModel.Create(Binary using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppReplicaData(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppReplicaData)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppReplicaData.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppReplicaData.cs index 42cef88daca7a..321c7b05d6aab 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppReplicaData.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppReplicaData.cs @@ -80,14 +80,19 @@ internal ContainerAppReplicaData(ResourceIdentifier id, string name, ResourceTyp } /// Timestamp describing when the pod was created by controller. + [WirePath("properties.createdTime")] public DateTimeOffset? CreatedOn { get; } /// Current running state of the replica. + [WirePath("properties.runningState")] public ContainerAppReplicaRunningState? RunningState { get; } /// The details of replica current running state. + [WirePath("properties.runningStateDetails")] public string RunningStateDetails { get; } /// The containers collection under a replica. + [WirePath("properties.containers")] public IList Containers { get; } /// The init containers collection under a replica. + [WirePath("properties.initContainers")] public IList InitContainers { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppRevisionData.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppRevisionData.Serialization.cs index 98c6722bdc3b8..6d5d11fa384c2 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppRevisionData.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppRevisionData.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers.Models; using Azure.ResourceManager.Models; @@ -315,6 +317,289 @@ internal static ContainerAppRevisionData DeserializeContainerAppRevisionData(Jso serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); + if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) + { + builder.Append(" createdTime: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastActiveOn), out propertyOverride); + if (Optional.IsDefined(LastActiveOn) || hasPropertyOverride) + { + builder.Append(" lastActiveTime: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(LastActiveOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Fqdn), out propertyOverride); + if (Optional.IsDefined(Fqdn) || hasPropertyOverride) + { + builder.Append(" fqdn: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Fqdn.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Fqdn}'''"); + } + else + { + builder.AppendLine($"'{Fqdn}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Template), out propertyOverride); + if (Optional.IsDefined(Template) || hasPropertyOverride) + { + builder.Append(" template: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Template, options, 4, false, " template: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsActive), out propertyOverride); + if (Optional.IsDefined(IsActive) || hasPropertyOverride) + { + builder.Append(" active: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsActive.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Replicas), out propertyOverride); + if (Optional.IsDefined(Replicas) || hasPropertyOverride) + { + builder.Append(" replicas: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{Replicas.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TrafficWeight), out propertyOverride); + if (Optional.IsDefined(TrafficWeight) || hasPropertyOverride) + { + builder.Append(" trafficWeight: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{TrafficWeight.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningError), out propertyOverride); + if (Optional.IsDefined(ProvisioningError) || hasPropertyOverride) + { + builder.Append(" provisioningError: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ProvisioningError.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ProvisioningError}'''"); + } + else + { + builder.AppendLine($"'{ProvisioningError}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HealthState), out propertyOverride); + if (Optional.IsDefined(HealthState) || hasPropertyOverride) + { + builder.Append(" healthState: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{HealthState.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); + if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) + { + builder.Append(" provisioningState: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ProvisioningState.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RunningState), out propertyOverride); + if (Optional.IsDefined(RunningState) || hasPropertyOverride) + { + builder.Append(" runningState: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{RunningState.Value.ToString()}'"); + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -323,6 +608,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOp { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppRevisionData)} does not support '{options.Format}' format."); } @@ -339,6 +626,8 @@ ContainerAppRevisionData IPersistableModel.Create(Bina using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppRevisionData(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppRevisionData)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppRevisionData.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppRevisionData.cs index b8838c72847f5..9cf0c8c6b17a5 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppRevisionData.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppRevisionData.cs @@ -100,30 +100,41 @@ internal ContainerAppRevisionData(ResourceIdentifier id, string name, ResourceTy /// Timestamp describing when the revision was created /// by controller /// + [WirePath("properties.createdTime")] public DateTimeOffset? CreatedOn { get; } /// Timestamp describing when the revision was last active. Only meaningful when revision is inactive. + [WirePath("properties.lastActiveTime")] public DateTimeOffset? LastActiveOn { get; } /// Fully qualified domain name of the revision. + [WirePath("properties.fqdn")] public string Fqdn { get; } /// /// Container App Revision Template with all possible settings and the /// defaults if user did not provide them. The defaults are populated /// as they were at the creation time /// + [WirePath("properties.template")] public ContainerAppTemplate Template { get; } /// Boolean describing if the Revision is Active. + [WirePath("properties.active")] public bool? IsActive { get; } /// Number of pods currently running for this revision. + [WirePath("properties.replicas")] public int? Replicas { get; } /// Traffic weight assigned to this revision. + [WirePath("properties.trafficWeight")] public int? TrafficWeight { get; } /// Optional Field - Platform Error Message. + [WirePath("properties.provisioningError")] public string ProvisioningError { get; } /// Current health State of the revision. + [WirePath("properties.healthState")] public ContainerAppRevisionHealthState? HealthState { get; } /// Current provisioning State of the revision. + [WirePath("properties.provisioningState")] public ContainerAppRevisionProvisioningState? ProvisioningState { get; } /// Current running state of the revision. + [WirePath("properties.runningState")] public RevisionRunningState? RunningState { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppSourceControlData.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppSourceControlData.Serialization.cs index 9e039c55336db..61ed7d18f6c7b 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppSourceControlData.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppSourceControlData.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers.Models; using Azure.ResourceManager.Models; @@ -207,6 +209,180 @@ internal static ContainerAppSourceControlData DeserializeContainerAppSourceContr serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(OperationState), out propertyOverride); + if (Optional.IsDefined(OperationState) || hasPropertyOverride) + { + builder.Append(" operationState: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{OperationState.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RepoUri), out propertyOverride); + if (Optional.IsDefined(RepoUri) || hasPropertyOverride) + { + builder.Append(" repoUrl: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{RepoUri.AbsoluteUri}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Branch), out propertyOverride); + if (Optional.IsDefined(Branch) || hasPropertyOverride) + { + builder.Append(" branch: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Branch.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Branch}'''"); + } + else + { + builder.AppendLine($"'{Branch}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(GitHubActionConfiguration), out propertyOverride); + if (Optional.IsDefined(GitHubActionConfiguration) || hasPropertyOverride) + { + builder.Append(" githubActionConfiguration: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, GitHubActionConfiguration, options, 4, false, " githubActionConfiguration: "); + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -215,6 +391,8 @@ BinaryData IPersistableModel.Write(ModelReaderWri { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppSourceControlData)} does not support '{options.Format}' format."); } @@ -231,6 +409,8 @@ ContainerAppSourceControlData IPersistableModel.C using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppSourceControlData(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppSourceControlData)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppSourceControlData.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppSourceControlData.cs index 818705ec8aac8..1aac7e5648e33 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppSourceControlData.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppSourceControlData.cs @@ -80,16 +80,20 @@ internal ContainerAppSourceControlData(ResourceIdentifier id, string name, Resou } /// Current provisioning State of the operation. + [WirePath("properties.operationState")] public ContainerAppSourceControlOperationState? OperationState { get; } /// The repo url which will be integrated to ContainerApp. + [WirePath("properties.repoUrl")] public Uri RepoUri { get; set; } /// The branch which will trigger the auto deployment. + [WirePath("properties.branch")] public string Branch { get; set; } /// /// Container App Revision Template with all possible settings and the /// defaults if user did not provide them. The defaults are populated /// as they were at the creation time /// + [WirePath("properties.githubActionConfiguration")] public ContainerAppGitHubActionConfiguration GitHubActionConfiguration { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Internal/WirePathAttribute.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Internal/WirePathAttribute.cs new file mode 100644 index 0000000000000..7475beb2a5ad2 --- /dev/null +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Internal/WirePathAttribute.cs @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.AppContainers +{ + [AttributeUsage(AttributeTargets.Property)] + internal class WirePathAttribute : Attribute + { + private string _wirePath; + + public WirePathAttribute(string wirePath) + { + _wirePath = wirePath; + } + + public override string ToString() + { + return _wirePath; + } + } +} diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/AllowedAudiencesValidation.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/AllowedAudiencesValidation.Serialization.cs index e3406829ae262..e2400b310e51b 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/AllowedAudiencesValidation.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/AllowedAudiencesValidation.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -103,6 +106,98 @@ internal static AllowedAudiencesValidation DeserializeAllowedAudiencesValidation return new AllowedAudiencesValidation(allowedAudiences ?? new ChangeTrackingList(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AllowedAudiences), out propertyOverride); + if (Optional.IsCollectionDefined(AllowedAudiences) || hasPropertyOverride) + { + if (AllowedAudiences.Any() || hasPropertyOverride) + { + builder.Append(" allowedAudiences: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in AllowedAudiences) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -111,6 +206,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriter { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(AllowedAudiencesValidation)} does not support '{options.Format}' format."); } @@ -127,6 +224,8 @@ AllowedAudiencesValidation IPersistableModel.Create( using JsonDocument document = JsonDocument.Parse(data); return DeserializeAllowedAudiencesValidation(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(AllowedAudiencesValidation)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/AllowedAudiencesValidation.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/AllowedAudiencesValidation.cs index 9de47138f32db..97514bffeec85 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/AllowedAudiencesValidation.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/AllowedAudiencesValidation.cs @@ -62,6 +62,7 @@ internal AllowedAudiencesValidation(IList allowedAudiences, IDictionary< } /// The configuration settings of the allowed list of audiences from which to validate the JWT token. + [WirePath("allowedAudiences")] public IList AllowedAudiences { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/AppContainerResources.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/AppContainerResources.Serialization.cs index 8aa9037d88219..be3ba9108644a 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/AppContainerResources.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/AppContainerResources.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -115,6 +117,121 @@ internal static AppContainerResources DeserializeAppContainerResources(JsonEleme return new AppContainerResources(cpu, memory, ephemeralStorage, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Cpu), out propertyOverride); + if (Optional.IsDefined(Cpu) || hasPropertyOverride) + { + builder.Append(" cpu: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Cpu.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Memory), out propertyOverride); + if (Optional.IsDefined(Memory) || hasPropertyOverride) + { + builder.Append(" memory: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Memory.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Memory}'''"); + } + else + { + builder.AppendLine($"'{Memory}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EphemeralStorage), out propertyOverride); + if (Optional.IsDefined(EphemeralStorage) || hasPropertyOverride) + { + builder.Append(" ephemeralStorage: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (EphemeralStorage.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{EphemeralStorage}'''"); + } + else + { + builder.AppendLine($"'{EphemeralStorage}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -123,6 +240,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptio { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(AppContainerResources)} does not support '{options.Format}' format."); } @@ -139,6 +258,8 @@ AppContainerResources IPersistableModel.Create(BinaryData using JsonDocument document = JsonDocument.Parse(data); return DeserializeAppContainerResources(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(AppContainerResources)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/AppContainerResources.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/AppContainerResources.cs index 508a57c3e7b31..551e7de26e98e 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/AppContainerResources.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/AppContainerResources.cs @@ -64,10 +64,13 @@ internal AppContainerResources(double? cpu, string memory, string ephemeralStora } /// Required CPU in cores, e.g. 0.5. + [WirePath("cpu")] public double? Cpu { get; set; } /// Required memory, e.g. "250Mb". + [WirePath("memory")] public string Memory { get; set; } /// Ephemeral Storage, e.g. "1Gi". + [WirePath("ephemeralStorage")] public string EphemeralStorage { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/AuthConfigCollection.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/AuthConfigCollection.Serialization.cs index ef1739c221ddf..ed8ab9ddc0964 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/AuthConfigCollection.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/AuthConfigCollection.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -107,6 +110,107 @@ internal static AuthConfigCollection DeserializeAuthConfigCollection(JsonElement return new AuthConfigCollection(value, nextLink, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (Optional.IsDefined(NextLink) || hasPropertyOverride) + { + builder.Append(" nextLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -115,6 +219,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOption { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(AuthConfigCollection)} does not support '{options.Format}' format."); } @@ -131,6 +237,8 @@ AuthConfigCollection IPersistableModel.Create(BinaryData d using JsonDocument document = JsonDocument.Parse(data); return DeserializeAuthConfigCollection(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(AuthConfigCollection)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/AvailableWorkloadProfilesCollection.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/AvailableWorkloadProfilesCollection.Serialization.cs index 25c82d417719d..8b74d6d46e8de 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/AvailableWorkloadProfilesCollection.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/AvailableWorkloadProfilesCollection.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -107,6 +110,107 @@ internal static AvailableWorkloadProfilesCollection DeserializeAvailableWorkload return new AvailableWorkloadProfilesCollection(value, nextLink, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (Optional.IsDefined(NextLink) || hasPropertyOverride) + { + builder.Append(" nextLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -115,6 +219,8 @@ BinaryData IPersistableModel.Write(ModelRea { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(AvailableWorkloadProfilesCollection)} does not support '{options.Format}' format."); } @@ -131,6 +237,8 @@ AvailableWorkloadProfilesCollection IPersistableModel propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ClientId), out propertyOverride); + if (Optional.IsDefined(ClientId) || hasPropertyOverride) + { + builder.Append(" clientId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ClientId.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ClientId}'''"); + } + else + { + builder.AppendLine($"'{ClientId}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -97,6 +178,8 @@ BinaryData IPersistableModel.Write(ModelReaderWr { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(AzureStaticWebAppsRegistration)} does not support '{options.Format}' format."); } @@ -113,6 +196,8 @@ AzureStaticWebAppsRegistration IPersistableModel using JsonDocument document = JsonDocument.Parse(data); return DeserializeAzureStaticWebAppsRegistration(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(AzureStaticWebAppsRegistration)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/AzureStaticWebAppsRegistration.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/AzureStaticWebAppsRegistration.cs index a960af0302ddc..266595bf70c5c 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/AzureStaticWebAppsRegistration.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/AzureStaticWebAppsRegistration.cs @@ -60,6 +60,7 @@ internal AzureStaticWebAppsRegistration(string clientId, IDictionary The Client ID of the app used for login. + [WirePath("clientId")] public string ClientId { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/BillingMeterCollection.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/BillingMeterCollection.Serialization.cs index 4bef2afe16c84..297b0c0e97130 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/BillingMeterCollection.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/BillingMeterCollection.Serialization.cs @@ -8,8 +8,12 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; +using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models { @@ -95,6 +99,85 @@ internal static BillingMeterCollection DeserializeBillingMeterCollection(JsonEle return new BillingMeterCollection(value, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -103,6 +186,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpti { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(BillingMeterCollection)} does not support '{options.Format}' format."); } @@ -119,6 +204,8 @@ BillingMeterCollection IPersistableModel.Create(BinaryDa using JsonDocument document = JsonDocument.Parse(data); return DeserializeBillingMeterCollection(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(BillingMeterCollection)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/BillingMeterCollection.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/BillingMeterCollection.cs index c152fe573a9f2..cd0580a47f6c5 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/BillingMeterCollection.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/BillingMeterCollection.cs @@ -72,6 +72,7 @@ internal BillingMeterCollection() } /// Collection of billing meters. + [WirePath("value")] public IReadOnlyList Value { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/CertificateCollection.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/CertificateCollection.Serialization.cs index 5122d5848bef1..25878be62b83b 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/CertificateCollection.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/CertificateCollection.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -107,6 +110,107 @@ internal static CertificateCollection DeserializeCertificateCollection(JsonEleme return new CertificateCollection(value, nextLink, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (Optional.IsDefined(NextLink) || hasPropertyOverride) + { + builder.Append(" nextLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -115,6 +219,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptio { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(CertificateCollection)} does not support '{options.Format}' format."); } @@ -131,6 +237,8 @@ CertificateCollection IPersistableModel.Create(BinaryData using JsonDocument document = JsonDocument.Parse(data); return DeserializeCertificateCollection(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(CertificateCollection)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ConnectedEnvironmentCollection.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ConnectedEnvironmentCollection.Serialization.cs index cb6900013420e..9e5bbc789d5ba 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ConnectedEnvironmentCollection.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ConnectedEnvironmentCollection.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -114,6 +117,107 @@ internal static ConnectedEnvironmentCollection DeserializeConnectedEnvironmentCo return new ConnectedEnvironmentCollection(value ?? new ChangeTrackingList(), nextLink, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (Optional.IsDefined(NextLink) || hasPropertyOverride) + { + builder.Append(" nextLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -122,6 +226,8 @@ BinaryData IPersistableModel.Write(ModelReaderWr { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ConnectedEnvironmentCollection)} does not support '{options.Format}' format."); } @@ -138,6 +244,8 @@ ConnectedEnvironmentCollection IPersistableModel using JsonDocument document = JsonDocument.Parse(data); return DeserializeConnectedEnvironmentCollection(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ConnectedEnvironmentCollection)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ConnectedEnvironmentStorageProperties.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ConnectedEnvironmentStorageProperties.Serialization.cs index 999e2ac24cb9c..5bad7d13af25b 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ConnectedEnvironmentStorageProperties.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ConnectedEnvironmentStorageProperties.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -93,6 +95,77 @@ internal static ConnectedEnvironmentStorageProperties DeserializeConnectedEnviro return new ConnectedEnvironmentStorageProperties(azureFile, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AzureFile), out propertyOverride); + if (Optional.IsDefined(AzureFile) || hasPropertyOverride) + { + builder.Append(" azureFile: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, AzureFile, options, 2, false, " azureFile: "); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -101,6 +174,8 @@ BinaryData IPersistableModel.Write(ModelR { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ConnectedEnvironmentStorageProperties)} does not support '{options.Format}' format."); } @@ -117,6 +192,8 @@ ConnectedEnvironmentStorageProperties IPersistableModel Azure file properties. + [WirePath("azureFile")] public ContainerAppAzureFileProperties AzureFile { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ConnectedEnvironmentStoragesCollection.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ConnectedEnvironmentStoragesCollection.Serialization.cs index b2c076128cd5b..0fb2e02e80c3a 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ConnectedEnvironmentStoragesCollection.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ConnectedEnvironmentStoragesCollection.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -96,6 +99,85 @@ internal static ConnectedEnvironmentStoragesCollection DeserializeConnectedEnvir return new ConnectedEnvironmentStoragesCollection(value, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -104,6 +186,8 @@ BinaryData IPersistableModel.Write(Model { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ConnectedEnvironmentStoragesCollection)} does not support '{options.Format}' format."); } @@ -120,6 +204,8 @@ ConnectedEnvironmentStoragesCollection IPersistableModel Collection of storage resources. + [WirePath("value")] public IReadOnlyList Value { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAllowedPrincipals.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAllowedPrincipals.Serialization.cs index 4ce53227cde13..456ee208dfecd 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAllowedPrincipals.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAllowedPrincipals.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -128,6 +131,133 @@ internal static ContainerAppAllowedPrincipals DeserializeContainerAppAllowedPrin return new ContainerAppAllowedPrincipals(groups ?? new ChangeTrackingList(), identities ?? new ChangeTrackingList(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Groups), out propertyOverride); + if (Optional.IsCollectionDefined(Groups) || hasPropertyOverride) + { + if (Groups.Any() || hasPropertyOverride) + { + builder.Append(" groups: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Groups) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Identities), out propertyOverride); + if (Optional.IsCollectionDefined(Identities) || hasPropertyOverride) + { + if (Identities.Any() || hasPropertyOverride) + { + builder.Append(" identities: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Identities) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -136,6 +266,8 @@ BinaryData IPersistableModel.Write(ModelReaderWri { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppAllowedPrincipals)} does not support '{options.Format}' format."); } @@ -152,6 +284,8 @@ ContainerAppAllowedPrincipals IPersistableModel.C using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppAllowedPrincipals(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppAllowedPrincipals)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAllowedPrincipals.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAllowedPrincipals.cs index ba5af6b6216cb..f7924983b9f08 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAllowedPrincipals.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAllowedPrincipals.cs @@ -65,8 +65,10 @@ internal ContainerAppAllowedPrincipals(IList groups, IList ident } /// The list of the allowed groups. + [WirePath("groups")] public IList Groups { get; } /// The list of the allowed identities. + [WirePath("identities")] public IList Identities { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAppleConfiguration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAppleConfiguration.Serialization.cs index 630ff611c3545..64924d5213783 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAppleConfiguration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAppleConfiguration.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -123,6 +125,106 @@ internal static ContainerAppAppleConfiguration DeserializeContainerAppAppleConfi return new ContainerAppAppleConfiguration(enabled, registration, login, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); + if (Optional.IsDefined(IsEnabled) || hasPropertyOverride) + { + builder.Append(" enabled: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsEnabled.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Registration), out propertyOverride); + if (Optional.IsDefined(Registration) || hasPropertyOverride) + { + builder.Append(" registration: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Registration, options, 2, false, " registration: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Login), out propertyOverride); + if (Optional.IsDefined(Login) || hasPropertyOverride) + { + builder.Append(" login: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Login, options, 2, false, " login: "); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -131,6 +233,8 @@ BinaryData IPersistableModel.Write(ModelReaderWr { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppAppleConfiguration)} does not support '{options.Format}' format."); } @@ -147,6 +251,8 @@ ContainerAppAppleConfiguration IPersistableModel using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppAppleConfiguration(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppAppleConfiguration)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAppleConfiguration.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAppleConfiguration.cs index 20c343d753c08..ce1ad02fcbaf6 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAppleConfiguration.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAppleConfiguration.cs @@ -64,12 +64,15 @@ internal ContainerAppAppleConfiguration(bool? isEnabled, ContainerAppAppleRegist } /// <code>false</code> if the Apple provider should not be enabled despite the set registration; otherwise, <code>true</code>. + [WirePath("enabled")] public bool? IsEnabled { get; set; } /// The configuration settings of the Apple registration. + [WirePath("registration")] public ContainerAppAppleRegistrationConfiguration Registration { get; set; } /// The configuration settings of the login flow. internal LoginScopes Login { get; set; } /// A list of the scopes that should be requested while authenticating. + [WirePath("login.scopes")] public IList LoginScopes { get diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAppleRegistrationConfiguration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAppleRegistrationConfiguration.Serialization.cs index 77008d6e2c197..e4557889cd13f 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAppleRegistrationConfiguration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAppleRegistrationConfiguration.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -100,6 +102,107 @@ internal static ContainerAppAppleRegistrationConfiguration DeserializeContainerA return new ContainerAppAppleRegistrationConfiguration(clientId, clientSecretSettingName, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ClientId), out propertyOverride); + if (Optional.IsDefined(ClientId) || hasPropertyOverride) + { + builder.Append(" clientId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ClientId.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ClientId}'''"); + } + else + { + builder.AppendLine($"'{ClientId}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ClientSecretSettingName), out propertyOverride); + if (Optional.IsDefined(ClientSecretSettingName) || hasPropertyOverride) + { + builder.Append(" clientSecretSettingName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ClientSecretSettingName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ClientSecretSettingName}'''"); + } + else + { + builder.AppendLine($"'{ClientSecretSettingName}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -108,6 +211,8 @@ BinaryData IPersistableModel.Write(M { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppAppleRegistrationConfiguration)} does not support '{options.Format}' format."); } @@ -124,6 +229,8 @@ ContainerAppAppleRegistrationConfiguration IPersistableModel The Client ID of the app used for login. + [WirePath("clientId")] public string ClientId { get; set; } /// The app setting name that contains the client secret. + [WirePath("clientSecretSettingName")] public string ClientSecretSettingName { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAuthPlatform.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAuthPlatform.Serialization.cs index 07ed070d78464..a9d15c7187e21 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAuthPlatform.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAuthPlatform.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -104,6 +106,100 @@ internal static ContainerAppAuthPlatform DeserializeContainerAppAuthPlatform(Jso return new ContainerAppAuthPlatform(enabled, runtimeVersion, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); + if (Optional.IsDefined(IsEnabled) || hasPropertyOverride) + { + builder.Append(" enabled: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsEnabled.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RuntimeVersion), out propertyOverride); + if (Optional.IsDefined(RuntimeVersion) || hasPropertyOverride) + { + builder.Append(" runtimeVersion: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (RuntimeVersion.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{RuntimeVersion}'''"); + } + else + { + builder.AppendLine($"'{RuntimeVersion}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -112,6 +208,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOp { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppAuthPlatform)} does not support '{options.Format}' format."); } @@ -128,6 +226,8 @@ ContainerAppAuthPlatform IPersistableModel.Create(Bina using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppAuthPlatform(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppAuthPlatform)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAuthPlatform.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAuthPlatform.cs index 20325e746a086..cfa65096a536b 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAuthPlatform.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAuthPlatform.cs @@ -65,11 +65,13 @@ internal ContainerAppAuthPlatform(bool? isEnabled, string runtimeVersion, IDicti } /// <code>true</code> if the Authentication / Authorization feature is enabled for the current app; otherwise, <code>false</code>. + [WirePath("enabled")] public bool? IsEnabled { get; set; } /// /// The RuntimeVersion of the Authentication / Authorization feature in use for the current app. /// The setting in this value can control the behavior of certain features in the Authentication / Authorization module. /// + [WirePath("runtimeVersion")] public string RuntimeVersion { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAuthToken.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAuthToken.Serialization.cs index d7c1146d68353..05c2dce78fa5a 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAuthToken.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAuthToken.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; using Azure.ResourceManager.Models; @@ -211,6 +214,200 @@ internal static ContainerAppAuthToken DeserializeContainerAppAuthToken(JsonEleme serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); + builder.Append(" location: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Location.ToString()}'"); + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tags), out propertyOverride); + if (Optional.IsCollectionDefined(Tags) || hasPropertyOverride) + { + if (Tags.Any() || hasPropertyOverride) + { + builder.Append(" tags: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("{"); + foreach (var item in Tags) + { + builder.Append($" '{item.Key}': "); + if (item.Value == null) + { + builder.Append("null"); + continue; + } + if (item.Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{item.Value}'''"); + } + else + { + builder.AppendLine($"'{item.Value}'"); + } + } + builder.AppendLine(" }"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Token), out propertyOverride); + if (Optional.IsDefined(Token) || hasPropertyOverride) + { + builder.Append(" token: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Token.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Token}'''"); + } + else + { + builder.AppendLine($"'{Token}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExpireOn), out propertyOverride); + if (Optional.IsDefined(ExpireOn) || hasPropertyOverride) + { + builder.Append(" expires: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(ExpireOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -219,6 +416,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptio { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppAuthToken)} does not support '{options.Format}' format."); } @@ -235,6 +434,8 @@ ContainerAppAuthToken IPersistableModel.Create(BinaryData using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppAuthToken(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppAuthToken)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAuthToken.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAuthToken.cs index c609d245f0d17..e61217ff979b4 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAuthToken.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAuthToken.cs @@ -76,8 +76,10 @@ internal ContainerAppAuthToken() } /// Auth token value. + [WirePath("properties.token")] public string Token { get; } /// Token expiration date. + [WirePath("properties.expires")] public DateTimeOffset? ExpireOn { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAvailableWorkloadProfile.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAvailableWorkloadProfile.Serialization.cs index 93a48a70c085e..f9965b65d1dce 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAvailableWorkloadProfile.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAvailableWorkloadProfile.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; using Azure.ResourceManager.Models; @@ -164,6 +166,141 @@ internal static ContainerAppAvailableWorkloadProfile DeserializeContainerAppAvai serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); + if (Optional.IsDefined(Location) || hasPropertyOverride) + { + builder.Append(" location: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Location.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Properties), out propertyOverride); + if (Optional.IsDefined(Properties) || hasPropertyOverride) + { + builder.Append(" properties: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Properties, options, 2, false, " properties: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -172,6 +309,8 @@ BinaryData IPersistableModel.Write(ModelRe { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppAvailableWorkloadProfile)} does not support '{options.Format}' format."); } @@ -188,6 +327,8 @@ ContainerAppAvailableWorkloadProfile IPersistableModel Region of the workload profile. + [WirePath("location")] public AzureLocation? Location { get; set; } /// Revision resource specific properties. + [WirePath("properties")] public ContainerAppAvailableWorkloadProfileProperties Properties { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAvailableWorkloadProfileProperties.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAvailableWorkloadProfileProperties.Serialization.cs index dc9a184c9348b..35c21f29ea5ad 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAvailableWorkloadProfileProperties.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAvailableWorkloadProfileProperties.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -151,6 +153,149 @@ internal static ContainerAppAvailableWorkloadProfileProperties DeserializeContai serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Category), out propertyOverride); + if (Optional.IsDefined(Category) || hasPropertyOverride) + { + builder.Append(" category: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Category.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Category}'''"); + } + else + { + builder.AppendLine($"'{Category}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Applicability), out propertyOverride); + if (Optional.IsDefined(Applicability) || hasPropertyOverride) + { + builder.Append(" applicability: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Applicability.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Cores), out propertyOverride); + if (Optional.IsDefined(Cores) || hasPropertyOverride) + { + builder.Append(" cores: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{Cores.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MemoryInGiB), out propertyOverride); + if (Optional.IsDefined(MemoryInGiB) || hasPropertyOverride) + { + builder.Append(" memoryGiB: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{MemoryInGiB.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayName), out propertyOverride); + if (Optional.IsDefined(DisplayName) || hasPropertyOverride) + { + builder.Append(" displayName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (DisplayName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{DisplayName}'''"); + } + else + { + builder.AppendLine($"'{DisplayName}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -159,6 +304,8 @@ BinaryData IPersistableModel.Wri { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppAvailableWorkloadProfileProperties)} does not support '{options.Format}' format."); } @@ -175,6 +322,8 @@ ContainerAppAvailableWorkloadProfileProperties IPersistableModel Used to categorize workload profiles. + [WirePath("category")] public string Category { get; set; } /// indicates whether the profile is default for the location. + [WirePath("applicability")] public ContainerAppAvailableWorkloadProfileApplicability? Applicability { get; set; } /// Number of cores in CPU. + [WirePath("cores")] public int? Cores { get; set; } /// Memory in GiB. + [WirePath("memoryGiB")] public int? MemoryInGiB { get; set; } /// The everyday name of the workload profile. + [WirePath("displayName")] public string DisplayName { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAzureActiveDirectoryConfiguration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAzureActiveDirectoryConfiguration.Serialization.cs index 5fdc8ac323d28..faf600f7ba5d9 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAzureActiveDirectoryConfiguration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAzureActiveDirectoryConfiguration.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -159,6 +161,135 @@ internal static ContainerAppAzureActiveDirectoryConfiguration DeserializeContain serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); + if (Optional.IsDefined(IsEnabled) || hasPropertyOverride) + { + builder.Append(" enabled: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsEnabled.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Registration), out propertyOverride); + if (Optional.IsDefined(Registration) || hasPropertyOverride) + { + builder.Append(" registration: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Registration, options, 2, false, " registration: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Login), out propertyOverride); + if (Optional.IsDefined(Login) || hasPropertyOverride) + { + builder.Append(" login: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Login, options, 2, false, " login: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Validation), out propertyOverride); + if (Optional.IsDefined(Validation) || hasPropertyOverride) + { + builder.Append(" validation: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Validation, options, 2, false, " validation: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsAutoProvisioned), out propertyOverride); + if (Optional.IsDefined(IsAutoProvisioned) || hasPropertyOverride) + { + builder.Append(" isAutoProvisioned: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsAutoProvisioned.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -167,6 +298,8 @@ BinaryData IPersistableModel.Writ { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppAzureActiveDirectoryConfiguration)} does not support '{options.Format}' format."); } @@ -183,6 +316,8 @@ ContainerAppAzureActiveDirectoryConfiguration IPersistableModel <code>false</code> if the Azure Active Directory provider should not be enabled despite the set registration; otherwise, <code>true</code>. + [WirePath("enabled")] public bool? IsEnabled { get; set; } /// The configuration settings of the Azure Active Directory app registration. + [WirePath("registration")] public ContainerAppAzureActiveDirectoryRegistrationConfiguration Registration { get; set; } /// The configuration settings of the Azure Active Directory login flow. + [WirePath("login")] public ContainerAppAzureActiveDirectoryLoginConfiguration Login { get; set; } /// The configuration settings of the Azure Active Directory token validation flow. + [WirePath("validation")] public ContainerAppAzureActiveDirectoryValidationConfiguration Validation { get; set; } /// /// Gets a value indicating whether the Azure AD configuration was auto-provisioned using 1st party tooling. /// This is an internal flag primarily intended to support the Azure Management Portal. Users should not /// read or write to this property. /// + [WirePath("isAutoProvisioned")] public bool? IsAutoProvisioned { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAzureActiveDirectoryLoginConfiguration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAzureActiveDirectoryLoginConfiguration.Serialization.cs index c23ac004b6dfc..f69552370d76b 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAzureActiveDirectoryLoginConfiguration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAzureActiveDirectoryLoginConfiguration.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -118,6 +121,113 @@ internal static ContainerAppAzureActiveDirectoryLoginConfiguration DeserializeCo return new ContainerAppAzureActiveDirectoryLoginConfiguration(loginParameters ?? new ChangeTrackingList(), disableWWWAuthenticate, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LoginParameters), out propertyOverride); + if (Optional.IsCollectionDefined(LoginParameters) || hasPropertyOverride) + { + if (LoginParameters.Any() || hasPropertyOverride) + { + builder.Append(" loginParameters: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in LoginParameters) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsWwwAuthenticationDisabled), out propertyOverride); + if (Optional.IsDefined(IsWwwAuthenticationDisabled) || hasPropertyOverride) + { + builder.Append(" disableWWWAuthenticate: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsWwwAuthenticationDisabled.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -126,6 +236,8 @@ BinaryData IPersistableModel { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppAzureActiveDirectoryLoginConfiguration)} does not support '{options.Format}' format."); } @@ -142,6 +254,8 @@ ContainerAppAzureActiveDirectoryLoginConfiguration IPersistableModel loginP /// Login parameters to send to the OpenID Connect authorization endpoint when /// a user logs in. Each parameter must be in the form "key=value". /// + [WirePath("loginParameters")] public IList LoginParameters { get; } /// <code>true</code> if the www-authenticate provider should be omitted from the request; otherwise, <code>false</code>. + [WirePath("disableWWWAuthenticate")] public bool? IsWwwAuthenticationDisabled { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAzureActiveDirectoryRegistrationConfiguration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAzureActiveDirectoryRegistrationConfiguration.Serialization.cs index 8617c517e2ef8..feab3dd77a8be 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAzureActiveDirectoryRegistrationConfiguration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAzureActiveDirectoryRegistrationConfiguration.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -151,6 +153,195 @@ internal static ContainerAppAzureActiveDirectoryRegistrationConfiguration Deseri serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(OpenIdIssuer), out propertyOverride); + if (Optional.IsDefined(OpenIdIssuer) || hasPropertyOverride) + { + builder.Append(" openIdIssuer: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (OpenIdIssuer.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{OpenIdIssuer}'''"); + } + else + { + builder.AppendLine($"'{OpenIdIssuer}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ClientId), out propertyOverride); + if (Optional.IsDefined(ClientId) || hasPropertyOverride) + { + builder.Append(" clientId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ClientId.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ClientId}'''"); + } + else + { + builder.AppendLine($"'{ClientId}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ClientSecretSettingName), out propertyOverride); + if (Optional.IsDefined(ClientSecretSettingName) || hasPropertyOverride) + { + builder.Append(" clientSecretSettingName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ClientSecretSettingName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ClientSecretSettingName}'''"); + } + else + { + builder.AppendLine($"'{ClientSecretSettingName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ClientSecretCertificateThumbprint), out propertyOverride); + if (Optional.IsDefined(ClientSecretCertificateThumbprint) || hasPropertyOverride) + { + builder.Append(" clientSecretCertificateThumbprint: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ClientSecretCertificateThumbprint.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ClientSecretCertificateThumbprint}'''"); + } + else + { + builder.AppendLine($"'{ClientSecretCertificateThumbprint}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ClientSecretCertificateSubjectAlternativeName), out propertyOverride); + if (Optional.IsDefined(ClientSecretCertificateSubjectAlternativeName) || hasPropertyOverride) + { + builder.Append(" clientSecretCertificateSubjectAlternativeName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ClientSecretCertificateSubjectAlternativeName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ClientSecretCertificateSubjectAlternativeName}'''"); + } + else + { + builder.AppendLine($"'{ClientSecretCertificateSubjectAlternativeName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ClientSecretCertificateIssuer), out propertyOverride); + if (Optional.IsDefined(ClientSecretCertificateIssuer) || hasPropertyOverride) + { + builder.Append(" clientSecretCertificateIssuer: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ClientSecretCertificateIssuer.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ClientSecretCertificateIssuer}'''"); + } + else + { + builder.AppendLine($"'{ClientSecretCertificateIssuer}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -159,6 +350,8 @@ BinaryData IPersistableModel + [WirePath("openIdIssuer")] public string OpenIdIssuer { get; set; } /// /// The Client ID of this relying party application, known as the client_id. @@ -101,23 +102,28 @@ internal ContainerAppAzureActiveDirectoryRegistrationConfiguration(string openId /// other 3rd party OpenID Connect providers. /// More information on OpenID Connect: http://openid.net/specs/openid-connect-core-1_0.html /// + [WirePath("clientId")] public string ClientId { get; set; } /// The app setting name that contains the client secret of the relying party application. + [WirePath("clientSecretSettingName")] public string ClientSecretSettingName { get; set; } /// /// An alternative to the client secret, that is the thumbprint of a certificate used for signing purposes. This property acts as /// a replacement for the Client Secret. It is also optional. /// + [WirePath("clientSecretCertificateThumbprint")] public string ClientSecretCertificateThumbprint { get; set; } /// /// An alternative to the client secret thumbprint, that is the subject alternative name of a certificate used for signing purposes. This property acts as /// a replacement for the Client Secret Certificate Thumbprint. It is also optional. /// + [WirePath("clientSecretCertificateSubjectAlternativeName")] public string ClientSecretCertificateSubjectAlternativeName { get; set; } /// /// An alternative to the client secret thumbprint, that is the issuer of a certificate used for signing purposes. This property acts as /// a replacement for the Client Secret Certificate Thumbprint. It is also optional. /// + [WirePath("clientSecretCertificateIssuer")] public string ClientSecretCertificateIssuer { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAzureActiveDirectoryValidationConfiguration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAzureActiveDirectoryValidationConfiguration.Serialization.cs index 05aff5f8efb84..0570571723430 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAzureActiveDirectoryValidationConfiguration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAzureActiveDirectoryValidationConfiguration.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -133,6 +136,126 @@ internal static ContainerAppAzureActiveDirectoryValidationConfiguration Deserial return new ContainerAppAzureActiveDirectoryValidationConfiguration(jwtClaimChecks, allowedAudiences ?? new ChangeTrackingList(), defaultAuthorizationPolicy, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(JwtClaimChecks), out propertyOverride); + if (Optional.IsDefined(JwtClaimChecks) || hasPropertyOverride) + { + builder.Append(" jwtClaimChecks: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, JwtClaimChecks, options, 2, false, " jwtClaimChecks: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AllowedAudiences), out propertyOverride); + if (Optional.IsCollectionDefined(AllowedAudiences) || hasPropertyOverride) + { + if (AllowedAudiences.Any() || hasPropertyOverride) + { + builder.Append(" allowedAudiences: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in AllowedAudiences) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DefaultAuthorizationPolicy), out propertyOverride); + if (Optional.IsDefined(DefaultAuthorizationPolicy) || hasPropertyOverride) + { + builder.Append(" defaultAuthorizationPolicy: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, DefaultAuthorizationPolicy, options, 2, false, " defaultAuthorizationPolicy: "); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -141,6 +264,8 @@ BinaryData IPersistableModel The configuration settings of the checks that should be made while validating the JWT Claims. + [WirePath("jwtClaimChecks")] public ContainerAppJwtClaimChecks JwtClaimChecks { get; set; } /// The list of audiences that can make successful authentication/authorization requests. + [WirePath("allowedAudiences")] public IList AllowedAudiences { get; } /// The configuration settings of the default authorization policy. + [WirePath("defaultAuthorizationPolicy")] public ContainerAppDefaultAuthorizationPolicy DefaultAuthorizationPolicy { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAzureFileProperties.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAzureFileProperties.Serialization.cs index 64ecf1d861f48..9e85a26e04d9b 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAzureFileProperties.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAzureFileProperties.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -126,6 +128,143 @@ internal static ContainerAppAzureFileProperties DeserializeContainerAppAzureFile return new ContainerAppAzureFileProperties(accountName, accountKey, accessMode, shareName, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AccountName), out propertyOverride); + if (Optional.IsDefined(AccountName) || hasPropertyOverride) + { + builder.Append(" accountName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (AccountName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{AccountName}'''"); + } + else + { + builder.AppendLine($"'{AccountName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AccountKey), out propertyOverride); + if (Optional.IsDefined(AccountKey) || hasPropertyOverride) + { + builder.Append(" accountKey: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (AccountKey.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{AccountKey}'''"); + } + else + { + builder.AppendLine($"'{AccountKey}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AccessMode), out propertyOverride); + if (Optional.IsDefined(AccessMode) || hasPropertyOverride) + { + builder.Append(" accessMode: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{AccessMode.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ShareName), out propertyOverride); + if (Optional.IsDefined(ShareName) || hasPropertyOverride) + { + builder.Append(" shareName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ShareName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ShareName}'''"); + } + else + { + builder.AppendLine($"'{ShareName}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -134,6 +273,8 @@ BinaryData IPersistableModel.Write(ModelReaderW { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppAzureFileProperties)} does not support '{options.Format}' format."); } @@ -150,6 +291,8 @@ ContainerAppAzureFileProperties IPersistableModel Storage account name for azure file. + [WirePath("accountName")] public string AccountName { get; set; } /// Storage account key for azure file. + [WirePath("accountKey")] public string AccountKey { get; set; } /// Access mode for storage. + [WirePath("accessMode")] public ContainerAppAccessMode? AccessMode { get; set; } /// Azure file share name. + [WirePath("shareName")] public string ShareName { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAzureStaticWebAppsConfiguration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAzureStaticWebAppsConfiguration.Serialization.cs index 22480718e7476..d961fda2c5ffb 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAzureStaticWebAppsConfiguration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAzureStaticWebAppsConfiguration.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -108,6 +110,92 @@ internal static ContainerAppAzureStaticWebAppsConfiguration DeserializeContainer return new ContainerAppAzureStaticWebAppsConfiguration(enabled, registration, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); + if (Optional.IsDefined(IsEnabled) || hasPropertyOverride) + { + builder.Append(" enabled: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsEnabled.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Registration), out propertyOverride); + if (Optional.IsDefined(Registration) || hasPropertyOverride) + { + builder.Append(" registration: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Registration, options, 2, false, " registration: "); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -116,6 +204,8 @@ BinaryData IPersistableModel.Write( { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppAzureStaticWebAppsConfiguration)} does not support '{options.Format}' format."); } @@ -132,6 +222,8 @@ ContainerAppAzureStaticWebAppsConfiguration IPersistableModel <code>false</code> if the Azure Static Web Apps provider should not be enabled despite the set registration; otherwise, <code>true</code>. + [WirePath("enabled")] public bool? IsEnabled { get; set; } /// The configuration settings of the Azure Static Web Apps registration. internal AzureStaticWebAppsRegistration Registration { get; set; } /// The Client ID of the app used for login. + [WirePath("registration.clientId")] public string RegistrationClientId { get => Registration is null ? default : Registration.ClientId; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppBaseContainer.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppBaseContainer.Serialization.cs index 595908d5bd37d..ad31ecf8bf648 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppBaseContainer.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppBaseContainer.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -223,6 +226,235 @@ internal static ContainerAppBaseContainer DeserializeContainerAppBaseContainer(J serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Image), out propertyOverride); + if (Optional.IsDefined(Image) || hasPropertyOverride) + { + builder.Append(" image: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Image.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Image}'''"); + } + else + { + builder.AppendLine($"'{Image}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Command), out propertyOverride); + if (Optional.IsCollectionDefined(Command) || hasPropertyOverride) + { + if (Command.Any() || hasPropertyOverride) + { + builder.Append(" command: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Command) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Args), out propertyOverride); + if (Optional.IsCollectionDefined(Args) || hasPropertyOverride) + { + if (Args.Any() || hasPropertyOverride) + { + builder.Append(" args: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Args) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Env), out propertyOverride); + if (Optional.IsCollectionDefined(Env) || hasPropertyOverride) + { + if (Env.Any() || hasPropertyOverride) + { + builder.Append(" env: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Env) + { + AppendChildObject(builder, item, options, 4, true, " env: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Resources), out propertyOverride); + if (Optional.IsDefined(Resources) || hasPropertyOverride) + { + builder.Append(" resources: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Resources, options, 2, false, " resources: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(VolumeMounts), out propertyOverride); + if (Optional.IsCollectionDefined(VolumeMounts) || hasPropertyOverride) + { + if (VolumeMounts.Any() || hasPropertyOverride) + { + builder.Append(" volumeMounts: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in VolumeMounts) + { + AppendChildObject(builder, item, options, 4, true, " volumeMounts: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -231,6 +463,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterO { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppBaseContainer)} does not support '{options.Format}' format."); } @@ -247,6 +481,8 @@ ContainerAppBaseContainer IPersistableModel.Create(Bi using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppBaseContainer(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppBaseContainer)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppBaseContainer.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppBaseContainer.cs index 5c1f90baa6e50..68b4eb2428bc9 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppBaseContainer.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppBaseContainer.cs @@ -77,18 +77,25 @@ internal ContainerAppBaseContainer(string image, string name, IList comm } /// Container image tag. + [WirePath("image")] public string Image { get; set; } /// Custom container name. + [WirePath("name")] public string Name { get; set; } /// Container start command. + [WirePath("command")] public IList Command { get; } /// Container start command arguments. + [WirePath("args")] public IList Args { get; } /// Container environment variables. + [WirePath("env")] public IList Env { get; } /// Container resource requirements. + [WirePath("resources")] public AppContainerResources Resources { get; set; } /// Container volume mounts. + [WirePath("volumeMounts")] public IList VolumeMounts { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppBillingMeter.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppBillingMeter.Serialization.cs index 33f3ff8039add..dfd331c251ca5 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppBillingMeter.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppBillingMeter.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; using Azure.ResourceManager.Models; @@ -164,6 +166,141 @@ internal static ContainerAppBillingMeter DeserializeContainerAppBillingMeter(Jso serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); + if (Optional.IsDefined(Location) || hasPropertyOverride) + { + builder.Append(" location: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Location.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Properties), out propertyOverride); + if (Optional.IsDefined(Properties) || hasPropertyOverride) + { + builder.Append(" properties: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Properties, options, 2, false, " properties: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -172,6 +309,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOp { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppBillingMeter)} does not support '{options.Format}' format."); } @@ -188,6 +327,8 @@ ContainerAppBillingMeter IPersistableModel.Create(Bina using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppBillingMeter(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppBillingMeter)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppBillingMeter.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppBillingMeter.cs index 816a74008d6f1..fb1cafe2405a0 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppBillingMeter.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppBillingMeter.cs @@ -68,8 +68,10 @@ internal ContainerAppBillingMeter(ResourceIdentifier id, string name, ResourceTy } /// Region for the billing meter. + [WirePath("location")] public AzureLocation? Location { get; set; } /// Revision resource specific properties. + [WirePath("properties")] public ContainerAppBillingMeterProperties Properties { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppBillingMeterProperties.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppBillingMeterProperties.Serialization.cs index 38f0108dcc192..c6f0a7adbe21b 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppBillingMeterProperties.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppBillingMeterProperties.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -111,6 +113,129 @@ internal static ContainerAppBillingMeterProperties DeserializeContainerAppBillin return new ContainerAppBillingMeterProperties(category, meterType, displayName, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(WorkloadProfileCategory), out propertyOverride); + if (Optional.IsDefined(WorkloadProfileCategory) || hasPropertyOverride) + { + builder.Append(" category: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (WorkloadProfileCategory.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{WorkloadProfileCategory}'''"); + } + else + { + builder.AppendLine($"'{WorkloadProfileCategory}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MeterType), out propertyOverride); + if (Optional.IsDefined(MeterType) || hasPropertyOverride) + { + builder.Append(" meterType: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (MeterType.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{MeterType}'''"); + } + else + { + builder.AppendLine($"'{MeterType}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayName), out propertyOverride); + if (Optional.IsDefined(DisplayName) || hasPropertyOverride) + { + builder.Append(" displayName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (DisplayName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{DisplayName}'''"); + } + else + { + builder.AppendLine($"'{DisplayName}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -119,6 +244,8 @@ BinaryData IPersistableModel.Write(ModelRead { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppBillingMeterProperties)} does not support '{options.Format}' format."); } @@ -135,6 +262,8 @@ ContainerAppBillingMeterProperties IPersistableModel Used to categorize billing meters. + [WirePath("category")] public string WorkloadProfileCategory { get; set; } /// Billing meter type. + [WirePath("meterType")] public string MeterType { get; set; } /// The everyday name of the billing meter. + [WirePath("displayName")] public string DisplayName { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCertificatePatch.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCertificatePatch.cs index fa90132291028..9be781701e5ce 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCertificatePatch.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCertificatePatch.cs @@ -62,6 +62,7 @@ internal ContainerAppCertificatePatch(IDictionary tags, IDiction } /// Application-specific metadata in the form of key-value pairs. + [WirePath("tags")] public IDictionary Tags { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCertificateProperties.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCertificateProperties.Serialization.cs index 724870a603121..5c8074a2505ab 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCertificateProperties.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCertificateProperties.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -245,6 +248,281 @@ internal static ContainerAppCertificateProperties DeserializeContainerAppCertifi serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); + if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) + { + builder.Append(" provisioningState: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ProvisioningState.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Password), out propertyOverride); + if (Optional.IsDefined(Password) || hasPropertyOverride) + { + builder.Append(" password: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Password.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Password}'''"); + } + else + { + builder.AppendLine($"'{Password}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SubjectName), out propertyOverride); + if (Optional.IsDefined(SubjectName) || hasPropertyOverride) + { + builder.Append(" subjectName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (SubjectName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{SubjectName}'''"); + } + else + { + builder.AppendLine($"'{SubjectName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SubjectAlternativeNames), out propertyOverride); + if (Optional.IsCollectionDefined(SubjectAlternativeNames) || hasPropertyOverride) + { + if (SubjectAlternativeNames.Any() || hasPropertyOverride) + { + builder.Append(" subjectAlternativeNames: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in SubjectAlternativeNames) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsDefined(Value) || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Issuer), out propertyOverride); + if (Optional.IsDefined(Issuer) || hasPropertyOverride) + { + builder.Append(" issuer: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Issuer.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Issuer}'''"); + } + else + { + builder.AppendLine($"'{Issuer}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IssueOn), out propertyOverride); + if (Optional.IsDefined(IssueOn) || hasPropertyOverride) + { + builder.Append(" issueDate: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(IssueOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExpireOn), out propertyOverride); + if (Optional.IsDefined(ExpireOn) || hasPropertyOverride) + { + builder.Append(" expirationDate: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(ExpireOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Thumbprint), out propertyOverride); + if (Optional.IsDefined(Thumbprint) || hasPropertyOverride) + { + builder.Append(" thumbprint: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Thumbprint.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Thumbprint}'''"); + } + else + { + builder.AppendLine($"'{Thumbprint}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsValid), out propertyOverride); + if (Optional.IsDefined(IsValid) || hasPropertyOverride) + { + builder.Append(" valid: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsValid.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PublicKeyHash), out propertyOverride); + if (Optional.IsDefined(PublicKeyHash) || hasPropertyOverride) + { + builder.Append(" publicKeyHash: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (PublicKeyHash.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{PublicKeyHash}'''"); + } + else + { + builder.AppendLine($"'{PublicKeyHash}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -253,6 +531,8 @@ BinaryData IPersistableModel.Write(ModelReade { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppCertificateProperties)} does not support '{options.Format}' format."); } @@ -269,6 +549,8 @@ ContainerAppCertificateProperties IPersistableModel Provisioning state of the certificate. + [WirePath("provisioningState")] public ContainerAppCertificateProvisioningState? ProvisioningState { get; } /// Certificate password. + [WirePath("password")] public string Password { get; set; } /// Subject name of the certificate. + [WirePath("subjectName")] public string SubjectName { get; } /// Subject alternative names the certificate applies to. + [WirePath("subjectAlternativeNames")] public IReadOnlyList SubjectAlternativeNames { get; } /// PFX or PEM blob. + [WirePath("value")] public byte[] Value { get; set; } /// Certificate issuer. + [WirePath("issuer")] public string Issuer { get; } /// Certificate issue Date. + [WirePath("issueDate")] public DateTimeOffset? IssueOn { get; } /// Certificate expiration date. + [WirePath("expirationDate")] public DateTimeOffset? ExpireOn { get; } /// Certificate thumbprint. + [WirePath("thumbprint")] public string Thumbprint { get; } /// Is the certificate valid?. + [WirePath("valid")] public bool? IsValid { get; } /// Public key hash. + [WirePath("publicKeyHash")] public string PublicKeyHash { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppClientRegistration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppClientRegistration.Serialization.cs index 74d11de68b332..f00edd8fe599d 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppClientRegistration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppClientRegistration.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -100,6 +102,107 @@ internal static ContainerAppClientRegistration DeserializeContainerAppClientRegi return new ContainerAppClientRegistration(clientId, clientSecretSettingName, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ClientId), out propertyOverride); + if (Optional.IsDefined(ClientId) || hasPropertyOverride) + { + builder.Append(" clientId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ClientId.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ClientId}'''"); + } + else + { + builder.AppendLine($"'{ClientId}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ClientSecretSettingName), out propertyOverride); + if (Optional.IsDefined(ClientSecretSettingName) || hasPropertyOverride) + { + builder.Append(" clientSecretSettingName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ClientSecretSettingName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ClientSecretSettingName}'''"); + } + else + { + builder.AppendLine($"'{ClientSecretSettingName}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -108,6 +211,8 @@ BinaryData IPersistableModel.Write(ModelReaderWr { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppClientRegistration)} does not support '{options.Format}' format."); } @@ -124,6 +229,8 @@ ContainerAppClientRegistration IPersistableModel using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppClientRegistration(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppClientRegistration)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppClientRegistration.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppClientRegistration.cs index ae9c55050df86..7ab366ee6d5f5 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppClientRegistration.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppClientRegistration.cs @@ -62,8 +62,10 @@ internal ContainerAppClientRegistration(string clientId, string clientSecretSett } /// The Client ID of the app used for login. + [WirePath("clientId")] public string ClientId { get; set; } /// The app setting name that contains the client secret. + [WirePath("clientSecretSettingName")] public string ClientSecretSettingName { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCollection.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCollection.Serialization.cs index f20ea7f466ec9..55dd05419e67e 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCollection.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCollection.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -107,6 +110,107 @@ internal static ContainerAppCollection DeserializeContainerAppCollection(JsonEle return new ContainerAppCollection(value, nextLink, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (Optional.IsDefined(NextLink) || hasPropertyOverride) + { + builder.Append(" nextLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -115,6 +219,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpti { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppCollection)} does not support '{options.Format}' format."); } @@ -131,6 +237,8 @@ ContainerAppCollection IPersistableModel.Create(BinaryDa using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppCollection(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppCollection)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppConfiguration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppConfiguration.Serialization.cs index 8a50589d4723a..63573c66b9852 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppConfiguration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppConfiguration.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -211,6 +214,177 @@ internal static ContainerAppConfiguration DeserializeContainerAppConfiguration(J serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Secrets), out propertyOverride); + if (Optional.IsCollectionDefined(Secrets) || hasPropertyOverride) + { + if (Secrets.Any() || hasPropertyOverride) + { + builder.Append(" secrets: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Secrets) + { + AppendChildObject(builder, item, options, 4, true, " secrets: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ActiveRevisionsMode), out propertyOverride); + if (Optional.IsDefined(ActiveRevisionsMode) || hasPropertyOverride) + { + builder.Append(" activeRevisionsMode: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ActiveRevisionsMode.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Ingress), out propertyOverride); + if (Optional.IsDefined(Ingress) || hasPropertyOverride) + { + builder.Append(" ingress: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Ingress, options, 2, false, " ingress: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Registries), out propertyOverride); + if (Optional.IsCollectionDefined(Registries) || hasPropertyOverride) + { + if (Registries.Any() || hasPropertyOverride) + { + builder.Append(" registries: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Registries) + { + AppendChildObject(builder, item, options, 4, true, " registries: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Dapr), out propertyOverride); + if (Optional.IsDefined(Dapr) || hasPropertyOverride) + { + builder.Append(" dapr: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Dapr, options, 2, false, " dapr: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MaxInactiveRevisions), out propertyOverride); + if (Optional.IsDefined(MaxInactiveRevisions) || hasPropertyOverride) + { + builder.Append(" maxInactiveRevisions: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{MaxInactiveRevisions.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Service), out propertyOverride); + if (Optional.IsDefined(Service) || hasPropertyOverride) + { + builder.Append(" service: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Service, options, 2, false, " service: "); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -219,6 +393,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterO { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppConfiguration)} does not support '{options.Format}' format."); } @@ -235,6 +411,8 @@ ContainerAppConfiguration IPersistableModel.Create(Bi using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppConfiguration(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppConfiguration)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppConfiguration.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppConfiguration.cs index a235562ea9c2b..30afd94a58e3e 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppConfiguration.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppConfiguration.cs @@ -78,23 +78,30 @@ internal ContainerAppConfiguration(IList secrets, Co } /// Collection of secrets used by a Container app. + [WirePath("secrets")] public IList Secrets { get; } /// /// ActiveRevisionsMode controls how active revisions are handled for the Container app: /// <list><item>Multiple: multiple revisions can be active.</item><item>Single: Only one revision can be active at a time. Revision weights can not be used in this mode. If no value if provided, this is the default.</item></list> /// + [WirePath("activeRevisionsMode")] public ContainerAppActiveRevisionsMode? ActiveRevisionsMode { get; set; } /// Ingress configurations. + [WirePath("ingress")] public ContainerAppIngressConfiguration Ingress { get; set; } /// Collection of private container registry credentials for containers used by the Container app. + [WirePath("registries")] public IList Registries { get; } /// Dapr configuration for the Container App. + [WirePath("dapr")] public ContainerAppDaprConfiguration Dapr { get; set; } /// Optional. Max inactive revisions a Container App can have. + [WirePath("maxInactiveRevisions")] public int? MaxInactiveRevisions { get; set; } /// Container App to be a dev Container App Service. internal Service Service { get; set; } /// Dev ContainerApp service type. + [WirePath("service.type")] public string ServiceType { get => Service is null ? default : Service.ServiceType; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppContainer.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppContainer.Serialization.cs index ab8c5bbd433f2..f496095b1ca85 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppContainer.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppContainer.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -249,6 +252,257 @@ internal static ContainerAppContainer DeserializeContainerAppContainer(JsonEleme probes ?? new ChangeTrackingList()); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Probes), out propertyOverride); + if (Optional.IsCollectionDefined(Probes) || hasPropertyOverride) + { + if (Probes.Any() || hasPropertyOverride) + { + builder.Append(" probes: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Probes) + { + AppendChildObject(builder, item, options, 4, true, " probes: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Image), out propertyOverride); + if (Optional.IsDefined(Image) || hasPropertyOverride) + { + builder.Append(" image: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Image.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Image}'''"); + } + else + { + builder.AppendLine($"'{Image}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Command), out propertyOverride); + if (Optional.IsCollectionDefined(Command) || hasPropertyOverride) + { + if (Command.Any() || hasPropertyOverride) + { + builder.Append(" command: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Command) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Args), out propertyOverride); + if (Optional.IsCollectionDefined(Args) || hasPropertyOverride) + { + if (Args.Any() || hasPropertyOverride) + { + builder.Append(" args: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Args) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Env), out propertyOverride); + if (Optional.IsCollectionDefined(Env) || hasPropertyOverride) + { + if (Env.Any() || hasPropertyOverride) + { + builder.Append(" env: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Env) + { + AppendChildObject(builder, item, options, 4, true, " env: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Resources), out propertyOverride); + if (Optional.IsDefined(Resources) || hasPropertyOverride) + { + builder.Append(" resources: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Resources, options, 2, false, " resources: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(VolumeMounts), out propertyOverride); + if (Optional.IsCollectionDefined(VolumeMounts) || hasPropertyOverride) + { + if (VolumeMounts.Any() || hasPropertyOverride) + { + builder.Append(" volumeMounts: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in VolumeMounts) + { + AppendChildObject(builder, item, options, 4, true, " volumeMounts: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -257,6 +511,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptio { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppContainer)} does not support '{options.Format}' format."); } @@ -273,6 +529,8 @@ ContainerAppContainer IPersistableModel.Create(BinaryData using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppContainer(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppContainer)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppContainer.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppContainer.cs index 493cbb5797d1d..44d9e2f9cc6ae 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppContainer.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppContainer.cs @@ -36,6 +36,7 @@ internal ContainerAppContainer(string image, string name, IList command, } /// List of probes for the container. + [WirePath("probes")] public IList Probes { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCookieExpiration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCookieExpiration.Serialization.cs index 9027f8ff7d58a..43a3781cc1e55 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCookieExpiration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCookieExpiration.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -104,6 +106,99 @@ internal static ContainerAppCookieExpiration DeserializeContainerAppCookieExpira return new ContainerAppCookieExpiration(convention, timeToExpiration, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Convention), out propertyOverride); + if (Optional.IsDefined(Convention) || hasPropertyOverride) + { + builder.Append(" convention: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Convention.Value.ToSerialString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TimeToExpiration), out propertyOverride); + if (Optional.IsDefined(TimeToExpiration) || hasPropertyOverride) + { + builder.Append(" timeToExpiration: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (TimeToExpiration.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{TimeToExpiration}'''"); + } + else + { + builder.AppendLine($"'{TimeToExpiration}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -112,6 +207,8 @@ BinaryData IPersistableModel.Write(ModelReaderWrit { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppCookieExpiration)} does not support '{options.Format}' format."); } @@ -128,6 +225,8 @@ ContainerAppCookieExpiration IPersistableModel.Cre using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppCookieExpiration(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppCookieExpiration)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCookieExpiration.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCookieExpiration.cs index dd675f9bd9396..f626c98c73ad8 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCookieExpiration.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCookieExpiration.cs @@ -62,8 +62,10 @@ internal ContainerAppCookieExpiration(ContainerAppCookieExpirationConvention? co } /// The convention used when determining the session cookie's expiration. + [WirePath("convention")] public ContainerAppCookieExpirationConvention? Convention { get; set; } /// The time after the request is made when the session cookie should expire. + [WirePath("timeToExpiration")] public string TimeToExpiration { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCorsPolicy.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCorsPolicy.Serialization.cs index 19da10b2c5b3d..63d17ad954177 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCorsPolicy.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCorsPolicy.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -208,6 +211,232 @@ internal static ContainerAppCorsPolicy DeserializeContainerAppCorsPolicy(JsonEle serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AllowedOrigins), out propertyOverride); + if (Optional.IsCollectionDefined(AllowedOrigins) || hasPropertyOverride) + { + if (AllowedOrigins.Any() || hasPropertyOverride) + { + builder.Append(" allowedOrigins: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in AllowedOrigins) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AllowedMethods), out propertyOverride); + if (Optional.IsCollectionDefined(AllowedMethods) || hasPropertyOverride) + { + if (AllowedMethods.Any() || hasPropertyOverride) + { + builder.Append(" allowedMethods: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in AllowedMethods) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AllowedHeaders), out propertyOverride); + if (Optional.IsCollectionDefined(AllowedHeaders) || hasPropertyOverride) + { + if (AllowedHeaders.Any() || hasPropertyOverride) + { + builder.Append(" allowedHeaders: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in AllowedHeaders) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExposeHeaders), out propertyOverride); + if (Optional.IsCollectionDefined(ExposeHeaders) || hasPropertyOverride) + { + if (ExposeHeaders.Any() || hasPropertyOverride) + { + builder.Append(" exposeHeaders: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in ExposeHeaders) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MaxAge), out propertyOverride); + if (Optional.IsDefined(MaxAge) || hasPropertyOverride) + { + builder.Append(" maxAge: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{MaxAge.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AllowCredentials), out propertyOverride); + if (Optional.IsDefined(AllowCredentials) || hasPropertyOverride) + { + builder.Append(" allowCredentials: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = AllowCredentials.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -216,6 +445,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpti { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppCorsPolicy)} does not support '{options.Format}' format."); } @@ -232,6 +463,8 @@ ContainerAppCorsPolicy IPersistableModel.Create(BinaryDa using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppCorsPolicy(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppCorsPolicy)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCorsPolicy.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCorsPolicy.cs index 94b28686657ae..ef606cc3c140e 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCorsPolicy.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCorsPolicy.cs @@ -85,16 +85,22 @@ internal ContainerAppCorsPolicy() } /// Specifies the content for the access-control-allow-origins header. + [WirePath("allowedOrigins")] public IList AllowedOrigins { get; } /// Specifies the content for the access-control-allow-methods header. + [WirePath("allowedMethods")] public IList AllowedMethods { get; } /// Specifies the content for the access-control-allow-headers header. + [WirePath("allowedHeaders")] public IList AllowedHeaders { get; } /// Specifies the content for the access-control-expose-headers header. + [WirePath("exposeHeaders")] public IList ExposeHeaders { get; } /// Specifies the content for the access-control-max-age header. + [WirePath("maxAge")] public int? MaxAge { get; set; } /// Specifies whether the resource allows credentials. + [WirePath("allowCredentials")] public bool? AllowCredentials { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCredentials.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCredentials.Serialization.cs index 84ad19343907e..4c12edd8f780e 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCredentials.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCredentials.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -143,6 +145,165 @@ internal static ContainerAppCredentials DeserializeContainerAppCredentials(JsonE serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ClientId), out propertyOverride); + if (Optional.IsDefined(ClientId) || hasPropertyOverride) + { + builder.Append(" clientId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ClientId.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ClientId}'''"); + } + else + { + builder.AppendLine($"'{ClientId}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ClientSecret), out propertyOverride); + if (Optional.IsDefined(ClientSecret) || hasPropertyOverride) + { + builder.Append(" clientSecret: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ClientSecret.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ClientSecret}'''"); + } + else + { + builder.AppendLine($"'{ClientSecret}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TenantId), out propertyOverride); + if (Optional.IsDefined(TenantId) || hasPropertyOverride) + { + builder.Append(" tenantId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{TenantId.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); + if (Optional.IsDefined(Kind) || hasPropertyOverride) + { + builder.Append(" kind: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Kind.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Kind}'''"); + } + else + { + builder.AppendLine($"'{Kind}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SubscriptionId), out propertyOverride); + if (Optional.IsDefined(SubscriptionId) || hasPropertyOverride) + { + builder.Append(" subscriptionId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (SubscriptionId.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{SubscriptionId}'''"); + } + else + { + builder.AppendLine($"'{SubscriptionId}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -151,6 +312,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpt { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppCredentials)} does not support '{options.Format}' format."); } @@ -167,6 +330,8 @@ ContainerAppCredentials IPersistableModel.Create(Binary using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppCredentials(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppCredentials)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCredentials.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCredentials.cs index 10ead48986a87..965e4918d88a9 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCredentials.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCredentials.cs @@ -68,14 +68,19 @@ internal ContainerAppCredentials(string clientId, string clientSecret, Guid? ten } /// Client Id. + [WirePath("clientId")] public string ClientId { get; set; } /// Client Secret. + [WirePath("clientSecret")] public string ClientSecret { get; set; } /// Tenant Id. + [WirePath("tenantId")] public Guid? TenantId { get; set; } /// Kind of auth github does for deploying the template. + [WirePath("kind")] public string Kind { get; set; } /// Subscription Id. + [WirePath("subscriptionId")] public string SubscriptionId { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomDomain.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomDomain.Serialization.cs index 23a46656c61b5..f0815574f2442 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomDomain.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomDomain.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -116,6 +118,113 @@ internal static ContainerAppCustomDomain DeserializeContainerAppCustomDomain(Jso return new ContainerAppCustomDomain(name, bindingType, certificateId, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BindingType), out propertyOverride); + if (Optional.IsDefined(BindingType) || hasPropertyOverride) + { + builder.Append(" bindingType: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{BindingType.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CertificateId), out propertyOverride); + if (Optional.IsDefined(CertificateId) || hasPropertyOverride) + { + builder.Append(" certificateId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{CertificateId.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -124,6 +233,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOp { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppCustomDomain)} does not support '{options.Format}' format."); } @@ -140,6 +251,8 @@ ContainerAppCustomDomain IPersistableModel.Create(Bina using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppCustomDomain(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppCustomDomain)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomDomain.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomDomain.cs index ebb55936ae225..fd98bb8d31134 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomDomain.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomDomain.cs @@ -76,10 +76,13 @@ internal ContainerAppCustomDomain() } /// Hostname. + [WirePath("name")] public string Name { get; set; } /// Custom Domain binding type. + [WirePath("bindingType")] public ContainerAppCustomDomainBindingType? BindingType { get; set; } /// Resource Id of the Certificate to be bound to this hostname. Must exist in the Managed Environment. + [WirePath("certificateId")] public ResourceIdentifier CertificateId { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomDomainConfiguration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomDomainConfiguration.Serialization.cs index 3250102a2514b..a9177a412394d 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomDomainConfiguration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomDomainConfiguration.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -171,6 +173,202 @@ internal static ContainerAppCustomDomainConfiguration DeserializeContainerAppCus serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CustomDomainVerificationId), out propertyOverride); + if (Optional.IsDefined(CustomDomainVerificationId) || hasPropertyOverride) + { + builder.Append(" customDomainVerificationId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (CustomDomainVerificationId.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{CustomDomainVerificationId}'''"); + } + else + { + builder.AppendLine($"'{CustomDomainVerificationId}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DnsSuffix), out propertyOverride); + if (Optional.IsDefined(DnsSuffix) || hasPropertyOverride) + { + builder.Append(" dnsSuffix: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (DnsSuffix.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{DnsSuffix}'''"); + } + else + { + builder.AppendLine($"'{DnsSuffix}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CertificateValue), out propertyOverride); + if (Optional.IsDefined(CertificateValue) || hasPropertyOverride) + { + builder.Append(" certificateValue: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{CertificateValue.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CertificatePassword), out propertyOverride); + if (Optional.IsDefined(CertificatePassword) || hasPropertyOverride) + { + builder.Append(" certificatePassword: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (CertificatePassword.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{CertificatePassword}'''"); + } + else + { + builder.AppendLine($"'{CertificatePassword}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExpireOn), out propertyOverride); + if (Optional.IsDefined(ExpireOn) || hasPropertyOverride) + { + builder.Append(" expirationDate: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(ExpireOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Thumbprint), out propertyOverride); + if (Optional.IsDefined(Thumbprint) || hasPropertyOverride) + { + builder.Append(" thumbprint: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Thumbprint.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Thumbprint}'''"); + } + else + { + builder.AppendLine($"'{Thumbprint}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SubjectName), out propertyOverride); + if (Optional.IsDefined(SubjectName) || hasPropertyOverride) + { + builder.Append(" subjectName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (SubjectName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{SubjectName}'''"); + } + else + { + builder.AppendLine($"'{SubjectName}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -179,6 +377,8 @@ BinaryData IPersistableModel.Write(ModelR { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppCustomDomainConfiguration)} does not support '{options.Format}' format."); } @@ -195,6 +395,8 @@ ContainerAppCustomDomainConfiguration IPersistableModel Id used to verify domain name ownership. + [WirePath("customDomainVerificationId")] public string CustomDomainVerificationId { get; } /// Dns suffix for the environment domain. + [WirePath("dnsSuffix")] public string DnsSuffix { get; set; } /// PFX or PEM blob. + [WirePath("certificateValue")] public byte[] CertificateValue { get; set; } /// Certificate password. + [WirePath("certificatePassword")] public string CertificatePassword { get; set; } /// Certificate expiration date. + [WirePath("expirationDate")] public DateTimeOffset? ExpireOn { get; } /// Certificate thumbprint. + [WirePath("thumbprint")] public string Thumbprint { get; } /// Subject name of the certificate. + [WirePath("subjectName")] public string SubjectName { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomDomainVerificationFailureInfo.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomDomainVerificationFailureInfo.Serialization.cs index 90a5c808f9e41..9cb3df3eb3fe0 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomDomainVerificationFailureInfo.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomDomainVerificationFailureInfo.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -136,6 +139,151 @@ internal static ContainerAppCustomDomainVerificationFailureInfo DeserializeConta return new ContainerAppCustomDomainVerificationFailureInfo(code, message, target, details ?? new ChangeTrackingList(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Code), out propertyOverride); + if (Optional.IsDefined(Code) || hasPropertyOverride) + { + builder.Append(" code: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Code.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Code}'''"); + } + else + { + builder.AppendLine($"'{Code}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Message), out propertyOverride); + if (Optional.IsDefined(Message) || hasPropertyOverride) + { + builder.Append(" message: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Message.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Message}'''"); + } + else + { + builder.AppendLine($"'{Message}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Target), out propertyOverride); + if (Optional.IsDefined(Target) || hasPropertyOverride) + { + builder.Append(" target: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Target.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Target}'''"); + } + else + { + builder.AppendLine($"'{Target}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Details), out propertyOverride); + if (Optional.IsCollectionDefined(Details) || hasPropertyOverride) + { + if (Details.Any() || hasPropertyOverride) + { + builder.Append(" details: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Details) + { + AppendChildObject(builder, item, options, 4, true, " details: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -144,6 +292,8 @@ BinaryData IPersistableModel.Wr { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppCustomDomainVerificationFailureInfo)} does not support '{options.Format}' format."); } @@ -160,6 +310,8 @@ ContainerAppCustomDomainVerificationFailureInfo IPersistableModel Standardized string to programmatically identify the error. + [WirePath("code")] public string Code { get; } /// Detailed error description and debugging information. + [WirePath("message")] public string Message { get; } /// Detailed error description and debugging information. + [WirePath("target")] public string Target { get; } /// Details or the error. + [WirePath("details")] public IReadOnlyList Details { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomDomainVerificationFailureInfoDetailsItem.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomDomainVerificationFailureInfoDetailsItem.Serialization.cs index 939a1b0f510e1..ec61633adf8ac 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomDomainVerificationFailureInfoDetailsItem.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomDomainVerificationFailureInfoDetailsItem.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -111,6 +113,129 @@ internal static ContainerAppCustomDomainVerificationFailureInfoDetailsItem Deser return new ContainerAppCustomDomainVerificationFailureInfoDetailsItem(code, message, target, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Code), out propertyOverride); + if (Optional.IsDefined(Code) || hasPropertyOverride) + { + builder.Append(" code: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Code.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Code}'''"); + } + else + { + builder.AppendLine($"'{Code}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Message), out propertyOverride); + if (Optional.IsDefined(Message) || hasPropertyOverride) + { + builder.Append(" message: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Message.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Message}'''"); + } + else + { + builder.AppendLine($"'{Message}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Target), out propertyOverride); + if (Optional.IsDefined(Target) || hasPropertyOverride) + { + builder.Append(" target: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Target.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Target}'''"); + } + else + { + builder.AppendLine($"'{Target}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -119,6 +244,8 @@ BinaryData IPersistableModel Standardized string to programmatically identify the error. + [WirePath("code")] public string Code { get; } /// Detailed error description and debugging information. + [WirePath("message")] public string Message { get; } /// Detailed error description and debugging information. + [WirePath("target")] public string Target { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomHostnameAnalysisResult.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomHostnameAnalysisResult.Serialization.cs index e71406875341a..b03a0c5467943 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomHostnameAnalysisResult.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomHostnameAnalysisResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -313,6 +316,355 @@ internal static ContainerAppCustomHostnameAnalysisResult DeserializeContainerApp serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HostName), out propertyOverride); + if (Optional.IsDefined(HostName) || hasPropertyOverride) + { + builder.Append(" hostName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (HostName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{HostName}'''"); + } + else + { + builder.AppendLine($"'{HostName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsHostnameAlreadyVerified), out propertyOverride); + if (Optional.IsDefined(IsHostnameAlreadyVerified) || hasPropertyOverride) + { + builder.Append(" isHostnameAlreadyVerified: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsHostnameAlreadyVerified.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CustomDomainVerificationTest), out propertyOverride); + if (Optional.IsDefined(CustomDomainVerificationTest) || hasPropertyOverride) + { + builder.Append(" customDomainVerificationTest: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{CustomDomainVerificationTest.Value.ToSerialString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CustomDomainVerificationFailureInfo), out propertyOverride); + if (Optional.IsDefined(CustomDomainVerificationFailureInfo) || hasPropertyOverride) + { + builder.Append(" customDomainVerificationFailureInfo: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, CustomDomainVerificationFailureInfo, options, 2, false, " customDomainVerificationFailureInfo: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HasConflictOnManagedEnvironment), out propertyOverride); + if (Optional.IsDefined(HasConflictOnManagedEnvironment) || hasPropertyOverride) + { + builder.Append(" hasConflictOnManagedEnvironment: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = HasConflictOnManagedEnvironment.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ConflictWithEnvironmentCustomDomain), out propertyOverride); + if (Optional.IsDefined(ConflictWithEnvironmentCustomDomain) || hasPropertyOverride) + { + builder.Append(" conflictWithEnvironmentCustomDomain: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = ConflictWithEnvironmentCustomDomain.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ConflictingContainerAppResourceId), out propertyOverride); + if (Optional.IsDefined(ConflictingContainerAppResourceId) || hasPropertyOverride) + { + builder.Append(" conflictingContainerAppResourceId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ConflictingContainerAppResourceId.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ConflictingContainerAppResourceId}'''"); + } + else + { + builder.AppendLine($"'{ConflictingContainerAppResourceId}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CNameRecords), out propertyOverride); + if (Optional.IsCollectionDefined(CNameRecords) || hasPropertyOverride) + { + if (CNameRecords.Any() || hasPropertyOverride) + { + builder.Append(" cNameRecords: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in CNameRecords) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TxtRecords), out propertyOverride); + if (Optional.IsCollectionDefined(TxtRecords) || hasPropertyOverride) + { + if (TxtRecords.Any() || hasPropertyOverride) + { + builder.Append(" txtRecords: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in TxtRecords) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ARecords), out propertyOverride); + if (Optional.IsCollectionDefined(ARecords) || hasPropertyOverride) + { + if (ARecords.Any() || hasPropertyOverride) + { + builder.Append(" aRecords: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in ARecords) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AlternateCNameRecords), out propertyOverride); + if (Optional.IsCollectionDefined(AlternateCNameRecords) || hasPropertyOverride) + { + if (AlternateCNameRecords.Any() || hasPropertyOverride) + { + builder.Append(" alternateCNameRecords: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in AlternateCNameRecords) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AlternateTxtRecords), out propertyOverride); + if (Optional.IsCollectionDefined(AlternateTxtRecords) || hasPropertyOverride) + { + if (AlternateTxtRecords.Any() || hasPropertyOverride) + { + builder.Append(" alternateTxtRecords: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in AlternateTxtRecords) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -321,6 +673,8 @@ BinaryData IPersistableModel.Write(Mod { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppCustomHostnameAnalysisResult)} does not support '{options.Format}' format."); } @@ -337,6 +691,8 @@ ContainerAppCustomHostnameAnalysisResult IPersistableModel Host name that was analyzed. + [WirePath("hostName")] public string HostName { get; } /// <code>true</code> if hostname is already verified; otherwise, <code>false</code>. + [WirePath("isHostnameAlreadyVerified")] public bool? IsHostnameAlreadyVerified { get; } /// DNS verification test result. + [WirePath("customDomainVerificationTest")] public ContainerAppDnsVerificationTestResult? CustomDomainVerificationTest { get; } /// Raw failure information if DNS verification fails. + [WirePath("customDomainVerificationFailureInfo")] public ContainerAppCustomDomainVerificationFailureInfo CustomDomainVerificationFailureInfo { get; } /// <code>true</code> if there is a conflict on the Container App's managed environment; otherwise, <code>false</code>. + [WirePath("hasConflictOnManagedEnvironment")] public bool? HasConflictOnManagedEnvironment { get; } /// <code>true</code> if there is a conflict on the Container App's managed environment level custom domain; otherwise, <code>false</code>. + [WirePath("conflictWithEnvironmentCustomDomain")] public bool? ConflictWithEnvironmentCustomDomain { get; } /// Name of the conflicting Container App on the Managed Environment if it's within the same subscription. + [WirePath("conflictingContainerAppResourceId")] public string ConflictingContainerAppResourceId { get; } /// CName records visible for this hostname. + [WirePath("cNameRecords")] public IReadOnlyList CNameRecords { get; } /// TXT records visible for this hostname. + [WirePath("txtRecords")] public IReadOnlyList TxtRecords { get; } /// A records visible for this hostname. + [WirePath("aRecords")] public IReadOnlyList ARecords { get; } /// Alternate CName records visible for this hostname. + [WirePath("alternateCNameRecords")] public IReadOnlyList AlternateCNameRecords { get; } /// Alternate TXT records visible for this hostname. + [WirePath("alternateTxtRecords")] public IReadOnlyList AlternateTxtRecords { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomOpenIdConnectProviderConfiguration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomOpenIdConnectProviderConfiguration.Serialization.cs index 6f6bf6da1a3c0..ddf98a39805e5 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomOpenIdConnectProviderConfiguration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomOpenIdConnectProviderConfiguration.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -123,6 +125,106 @@ internal static ContainerAppCustomOpenIdConnectProviderConfiguration Deserialize return new ContainerAppCustomOpenIdConnectProviderConfiguration(enabled, registration, login, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); + if (Optional.IsDefined(IsEnabled) || hasPropertyOverride) + { + builder.Append(" enabled: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsEnabled.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Registration), out propertyOverride); + if (Optional.IsDefined(Registration) || hasPropertyOverride) + { + builder.Append(" registration: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Registration, options, 2, false, " registration: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Login), out propertyOverride); + if (Optional.IsDefined(Login) || hasPropertyOverride) + { + builder.Append(" login: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Login, options, 2, false, " login: "); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -131,6 +233,8 @@ BinaryData IPersistableModel <code>false</code> if the custom Open ID provider provider should not be enabled; otherwise, <code>true</code>. + [WirePath("enabled")] public bool? IsEnabled { get; set; } /// The configuration settings of the app registration for the custom Open ID Connect provider. + [WirePath("registration")] public ContainerAppOpenIdConnectRegistration Registration { get; set; } /// The configuration settings of the login flow of the custom Open ID Connect provider. + [WirePath("login")] public ContainerAppOpenIdConnectLogin Login { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomScaleRule.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomScaleRule.Serialization.cs index ecbedc32c2d33..8f9ebbf119a58 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomScaleRule.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomScaleRule.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -140,6 +143,121 @@ internal static ContainerAppCustomScaleRule DeserializeContainerAppCustomScaleRu return new ContainerAppCustomScaleRule(type, metadata ?? new ChangeTrackingDictionary(), auth ?? new ChangeTrackingList(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Metadata), out propertyOverride); + if (Optional.IsCollectionDefined(Metadata) || hasPropertyOverride) + { + if (Metadata.Any() || hasPropertyOverride) + { + builder.Append(" metadata: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("{"); + foreach (var item in Metadata) + { + builder.Append($" '{item.Key}': "); + if (item.Value == null) + { + builder.Append("null"); + continue; + } + if (item.Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{item.Value}'''"); + } + else + { + builder.AppendLine($"'{item.Value}'"); + } + } + builder.AppendLine(" }"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Auth), out propertyOverride); + if (Optional.IsCollectionDefined(Auth) || hasPropertyOverride) + { + if (Auth.Any() || hasPropertyOverride) + { + builder.Append(" auth: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Auth) + { + AppendChildObject(builder, item, options, 4, true, " auth: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -148,6 +266,8 @@ BinaryData IPersistableModel.Write(ModelReaderWrite { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppCustomScaleRule)} does not support '{options.Format}' format."); } @@ -164,6 +284,8 @@ ContainerAppCustomScaleRule IPersistableModel.Creat using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppCustomScaleRule(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppCustomScaleRule)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomScaleRule.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomScaleRule.cs index eaffdc024c8b6..d9d9550d79357 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomScaleRule.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomScaleRule.cs @@ -74,10 +74,13 @@ internal ContainerAppCustomScaleRule(string customScaleRuleType, IDictionary + [WirePath("type")] public string CustomScaleRuleType { get; set; } /// Metadata properties to describe custom scale rule. + [WirePath("metadata")] public IDictionary Metadata { get; } /// Authentication secrets for the custom scale rule. + [WirePath("auth")] public IList Auth { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDaprConfiguration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDaprConfiguration.Serialization.cs index 1c28f7ee80155..0937663c029ed 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDaprConfiguration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDaprConfiguration.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -203,6 +205,185 @@ internal static ContainerAppDaprConfiguration DeserializeContainerAppDaprConfigu serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); + if (Optional.IsDefined(IsEnabled) || hasPropertyOverride) + { + builder.Append(" enabled: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsEnabled.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AppId), out propertyOverride); + if (Optional.IsDefined(AppId) || hasPropertyOverride) + { + builder.Append(" appId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (AppId.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{AppId}'''"); + } + else + { + builder.AppendLine($"'{AppId}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AppProtocol), out propertyOverride); + if (Optional.IsDefined(AppProtocol) || hasPropertyOverride) + { + builder.Append(" appProtocol: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{AppProtocol.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AppPort), out propertyOverride); + if (Optional.IsDefined(AppPort) || hasPropertyOverride) + { + builder.Append(" appPort: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{AppPort.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HttpReadBufferSize), out propertyOverride); + if (Optional.IsDefined(HttpReadBufferSize) || hasPropertyOverride) + { + builder.Append(" httpReadBufferSize: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{HttpReadBufferSize.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HttpMaxRequestSize), out propertyOverride); + if (Optional.IsDefined(HttpMaxRequestSize) || hasPropertyOverride) + { + builder.Append(" httpMaxRequestSize: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{HttpMaxRequestSize.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LogLevel), out propertyOverride); + if (Optional.IsDefined(LogLevel) || hasPropertyOverride) + { + builder.Append(" logLevel: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{LogLevel.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsApiLoggingEnabled), out propertyOverride); + if (Optional.IsDefined(IsApiLoggingEnabled) || hasPropertyOverride) + { + builder.Append(" enableApiLogging: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsApiLoggingEnabled.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -211,6 +392,8 @@ BinaryData IPersistableModel.Write(ModelReaderWri { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppDaprConfiguration)} does not support '{options.Format}' format."); } @@ -227,6 +410,8 @@ ContainerAppDaprConfiguration IPersistableModel.C using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppDaprConfiguration(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppDaprConfiguration)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDaprConfiguration.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDaprConfiguration.cs index be79cd41064b1..1649cabfd26ce 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDaprConfiguration.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDaprConfiguration.cs @@ -74,20 +74,28 @@ internal ContainerAppDaprConfiguration(bool? isEnabled, string appId, ContainerA } /// Boolean indicating if the Dapr side car is enabled. + [WirePath("enabled")] public bool? IsEnabled { get; set; } /// Dapr application identifier. + [WirePath("appId")] public string AppId { get; set; } /// Tells Dapr which protocol your application is using. Valid options are http and grpc. Default is http. + [WirePath("appProtocol")] public ContainerAppProtocol? AppProtocol { get; set; } /// Tells Dapr which port your application is listening on. + [WirePath("appPort")] public int? AppPort { get; set; } /// Dapr max size of http header read buffer in KB to handle when sending multi-KB headers. Default is 65KB. + [WirePath("httpReadBufferSize")] public int? HttpReadBufferSize { get; set; } /// Increasing max size of request body http and grpc servers parameter in MB to handle uploading of big files. Default is 4 MB. + [WirePath("httpMaxRequestSize")] public int? HttpMaxRequestSize { get; set; } /// Sets the log level for the Dapr sidecar. Allowed values are debug, info, warn, error. Default is info. + [WirePath("logLevel")] public ContainerAppDaprLogLevel? LogLevel { get; set; } /// Enables API logging for the Dapr sidecar. + [WirePath("enableApiLogging")] public bool? IsApiLoggingEnabled { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDaprMetadata.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDaprMetadata.Serialization.cs index 74f6099396c72..8ad649851fbc5 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDaprMetadata.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDaprMetadata.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -111,6 +113,129 @@ internal static ContainerAppDaprMetadata DeserializeContainerAppDaprMetadata(Jso return new ContainerAppDaprMetadata(name, value, secretRef, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsDefined(Value) || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Value}'''"); + } + else + { + builder.AppendLine($"'{Value}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SecretRef), out propertyOverride); + if (Optional.IsDefined(SecretRef) || hasPropertyOverride) + { + builder.Append(" secretRef: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (SecretRef.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{SecretRef}'''"); + } + else + { + builder.AppendLine($"'{SecretRef}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -119,6 +244,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOp { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppDaprMetadata)} does not support '{options.Format}' format."); } @@ -135,6 +262,8 @@ ContainerAppDaprMetadata IPersistableModel.Create(Bina using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppDaprMetadata(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppDaprMetadata)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDaprMetadata.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDaprMetadata.cs index 5fb5d472bf36d..4c9d9de57ee73 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDaprMetadata.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDaprMetadata.cs @@ -64,10 +64,13 @@ internal ContainerAppDaprMetadata(string name, string value, string secretRef, I } /// Metadata property name. + [WirePath("name")] public string Name { get; set; } /// Metadata property value. + [WirePath("value")] public string Value { get; set; } /// Name of the Dapr Component secret from which to pull the metadata property value. + [WirePath("secretRef")] public string SecretRef { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDaprSecret.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDaprSecret.Serialization.cs index 11a007be76e18..af75a95a090af 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDaprSecret.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDaprSecret.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -100,6 +102,107 @@ internal static ContainerAppDaprSecret DeserializeContainerAppDaprSecret(JsonEle return new ContainerAppDaprSecret(name, value, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsDefined(Value) || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Value}'''"); + } + else + { + builder.AppendLine($"'{Value}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -108,6 +211,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpti { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppDaprSecret)} does not support '{options.Format}' format."); } @@ -124,6 +229,8 @@ ContainerAppDaprSecret IPersistableModel.Create(BinaryDa using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppDaprSecret(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppDaprSecret)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDaprSecret.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDaprSecret.cs index 454e77e6c2090..8a8405e83dcb1 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDaprSecret.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDaprSecret.cs @@ -62,8 +62,10 @@ internal ContainerAppDaprSecret(string name, string value, IDictionary Secret Name. + [WirePath("name")] public string Name { get; } /// Secret Value. + [WirePath("value")] public string Value { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDefaultAuthorizationPolicy.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDefaultAuthorizationPolicy.Serialization.cs index 11e6f2322d6ea..2918c9c388992 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDefaultAuthorizationPolicy.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDefaultAuthorizationPolicy.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -118,6 +121,112 @@ internal static ContainerAppDefaultAuthorizationPolicy DeserializeContainerAppDe return new ContainerAppDefaultAuthorizationPolicy(allowedPrincipals, allowedApplications ?? new ChangeTrackingList(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AllowedPrincipals), out propertyOverride); + if (Optional.IsDefined(AllowedPrincipals) || hasPropertyOverride) + { + builder.Append(" allowedPrincipals: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, AllowedPrincipals, options, 2, false, " allowedPrincipals: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AllowedApplications), out propertyOverride); + if (Optional.IsCollectionDefined(AllowedApplications) || hasPropertyOverride) + { + if (AllowedApplications.Any() || hasPropertyOverride) + { + builder.Append(" allowedApplications: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in AllowedApplications) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -126,6 +235,8 @@ BinaryData IPersistableModel.Write(Model { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppDefaultAuthorizationPolicy)} does not support '{options.Format}' format."); } @@ -142,6 +253,8 @@ ContainerAppDefaultAuthorizationPolicy IPersistableModel The configuration settings of the Azure Active Directory allowed principals. + [WirePath("allowedPrincipals")] public ContainerAppAllowedPrincipals AllowedPrincipals { get; set; } /// The configuration settings of the Azure Active Directory allowed applications. + [WirePath("allowedApplications")] public IList AllowedApplications { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticDataColumn.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticDataColumn.Serialization.cs index 1af1483d0ff64..313fba2a5f632 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticDataColumn.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticDataColumn.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -111,6 +113,129 @@ internal static ContainerAppDiagnosticDataColumn DeserializeContainerAppDiagnost return new ContainerAppDiagnosticDataColumn(columnName, dataType, columnType, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ColumnName), out propertyOverride); + if (Optional.IsDefined(ColumnName) || hasPropertyOverride) + { + builder.Append(" columnName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ColumnName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ColumnName}'''"); + } + else + { + builder.AppendLine($"'{ColumnName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DataType), out propertyOverride); + if (Optional.IsDefined(DataType) || hasPropertyOverride) + { + builder.Append(" dataType: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (DataType.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{DataType}'''"); + } + else + { + builder.AppendLine($"'{DataType}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ColumnType), out propertyOverride); + if (Optional.IsDefined(ColumnType) || hasPropertyOverride) + { + builder.Append(" columnType: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ColumnType.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ColumnType}'''"); + } + else + { + builder.AppendLine($"'{ColumnType}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -119,6 +244,8 @@ BinaryData IPersistableModel.Write(ModelReader { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppDiagnosticDataColumn)} does not support '{options.Format}' format."); } @@ -135,6 +262,8 @@ ContainerAppDiagnosticDataColumn IPersistableModel Column name. + [WirePath("columnName")] public string ColumnName { get; set; } /// Data type of the column. + [WirePath("dataType")] public string DataType { get; set; } /// Column type. + [WirePath("columnType")] public string ColumnType { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticDataProviderMetadata.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticDataProviderMetadata.Serialization.cs index 26da47eb7a77a..49f5c14083a59 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticDataProviderMetadata.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticDataProviderMetadata.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -114,6 +117,107 @@ internal static ContainerAppDiagnosticDataProviderMetadata DeserializeContainerA return new ContainerAppDiagnosticDataProviderMetadata(providerName, propertyBag ?? new ChangeTrackingList(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProviderName), out propertyOverride); + if (Optional.IsDefined(ProviderName) || hasPropertyOverride) + { + builder.Append(" providerName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ProviderName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ProviderName}'''"); + } + else + { + builder.AppendLine($"'{ProviderName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PropertyBag), out propertyOverride); + if (Optional.IsCollectionDefined(PropertyBag) || hasPropertyOverride) + { + if (PropertyBag.Any() || hasPropertyOverride) + { + builder.Append(" propertyBag: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in PropertyBag) + { + AppendChildObject(builder, item, options, 4, true, " propertyBag: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -122,6 +226,8 @@ BinaryData IPersistableModel.Write(M { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppDiagnosticDataProviderMetadata)} does not support '{options.Format}' format."); } @@ -138,6 +244,8 @@ ContainerAppDiagnosticDataProviderMetadata IPersistableModel Name of data provider. + [WirePath("providerName")] public string ProviderName { get; set; } /// Collection of properties. + [WirePath("propertyBag")] public IList PropertyBag { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticDataProviderMetadataPropertyBagItem.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticDataProviderMetadataPropertyBagItem.Serialization.cs index 3a889021bfac2..3b459e563a6c2 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticDataProviderMetadataPropertyBagItem.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticDataProviderMetadataPropertyBagItem.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -100,6 +102,107 @@ internal static ContainerAppDiagnosticDataProviderMetadataPropertyBagItem Deseri return new ContainerAppDiagnosticDataProviderMetadataPropertyBagItem(name, value, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsDefined(Value) || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Value}'''"); + } + else + { + builder.AppendLine($"'{Value}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -108,6 +211,8 @@ BinaryData IPersistableModel Property name. + [WirePath("name")] public string Name { get; set; } /// Property value. + [WirePath("value")] public string Value { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticDataTableResult.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticDataTableResult.Serialization.cs index 982bd4e2dbe02..d912c0a3dc174 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticDataTableResult.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticDataTableResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -158,6 +161,134 @@ internal static ContainerAppDiagnosticDataTableResult DeserializeContainerAppDia return new ContainerAppDiagnosticDataTableResult(tableName, columns ?? new ChangeTrackingList(), rows ?? new ChangeTrackingList(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TableName), out propertyOverride); + if (Optional.IsDefined(TableName) || hasPropertyOverride) + { + builder.Append(" tableName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (TableName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{TableName}'''"); + } + else + { + builder.AppendLine($"'{TableName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Columns), out propertyOverride); + if (Optional.IsCollectionDefined(Columns) || hasPropertyOverride) + { + if (Columns.Any() || hasPropertyOverride) + { + builder.Append(" columns: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Columns) + { + AppendChildObject(builder, item, options, 4, true, " columns: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Rows), out propertyOverride); + if (Optional.IsCollectionDefined(Rows) || hasPropertyOverride) + { + if (Rows.Any() || hasPropertyOverride) + { + builder.Append(" rows: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Rows) + { + if (item == null) + { + builder.Append("null"); + continue; + } + builder.AppendLine($" '{item.ToString()}'"); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -166,6 +297,8 @@ BinaryData IPersistableModel.Write(ModelR { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppDiagnosticDataTableResult)} does not support '{options.Format}' format."); } @@ -182,6 +315,8 @@ ContainerAppDiagnosticDataTableResult IPersistableModel Table name. + [WirePath("tableName")] public string TableName { get; set; } /// Columns in the table. + [WirePath("columns")] public IList Columns { get; } /// /// Rows in the table @@ -100,6 +102,7 @@ internal ContainerAppDiagnosticDataTableResult(string tableName, IList /// /// + [WirePath("rows")] public IList Rows { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticRendering.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticRendering.Serialization.cs index a061ccaf4d4b4..4299859ddd1e7 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticRendering.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticRendering.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -130,6 +132,122 @@ internal static ContainerAppDiagnosticRendering DeserializeContainerAppDiagnosti return new ContainerAppDiagnosticRendering(type, title, description, isVisible, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Title), out propertyOverride); + if (Optional.IsDefined(Title) || hasPropertyOverride) + { + builder.Append(" title: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Title.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Title}'''"); + } + else + { + builder.AppendLine($"'{Title}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); + if (Optional.IsDefined(Description) || hasPropertyOverride) + { + builder.Append(" description: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Description.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Description}'''"); + } + else + { + builder.AppendLine($"'{Description}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsVisible), out propertyOverride); + if (Optional.IsDefined(IsVisible) || hasPropertyOverride) + { + builder.Append(" isVisible: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsVisible.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -138,6 +256,8 @@ BinaryData IPersistableModel.Write(ModelReaderW { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppDiagnosticRendering)} does not support '{options.Format}' format."); } @@ -154,6 +274,8 @@ ContainerAppDiagnosticRendering IPersistableModel Rendering type. + [WirePath("type")] public int? DiagnosticRenderingType { get; set; } /// Title of the table. + [WirePath("title")] public string Title { get; set; } /// Description of the table. + [WirePath("description")] public string Description { get; set; } /// Flag if the table should be rendered. + [WirePath("isVisible")] public bool? IsVisible { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticSupportTopic.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticSupportTopic.Serialization.cs index 74282a7af1653..60972ed56c6bc 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticSupportTopic.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticSupportTopic.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -100,6 +102,107 @@ internal static ContainerAppDiagnosticSupportTopic DeserializeContainerAppDiagno return new ContainerAppDiagnosticSupportTopic(id, pesId, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Id.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Id}'''"); + } + else + { + builder.AppendLine($"'{Id}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PesId), out propertyOverride); + if (Optional.IsDefined(PesId) || hasPropertyOverride) + { + builder.Append(" pesId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (PesId.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{PesId}'''"); + } + else + { + builder.AppendLine($"'{PesId}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -108,6 +211,8 @@ BinaryData IPersistableModel.Write(ModelRead { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppDiagnosticSupportTopic)} does not support '{options.Format}' format."); } @@ -124,6 +229,8 @@ ContainerAppDiagnosticSupportTopic IPersistableModel Unique topic identifier. + [WirePath("id")] public string Id { get; } /// PES identifier. + [WirePath("pesId")] public string PesId { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticsDataApiResult.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticsDataApiResult.Serialization.cs index 315fdd7aaa745..018970e850a84 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticsDataApiResult.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticsDataApiResult.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -108,6 +110,91 @@ internal static ContainerAppDiagnosticsDataApiResult DeserializeContainerAppDiag return new ContainerAppDiagnosticsDataApiResult(table, renderingProperties, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Table), out propertyOverride); + if (Optional.IsDefined(Table) || hasPropertyOverride) + { + builder.Append(" table: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Table, options, 2, false, " table: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RenderingProperties), out propertyOverride); + if (Optional.IsDefined(RenderingProperties) || hasPropertyOverride) + { + builder.Append(" renderingProperties: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, RenderingProperties, options, 2, false, " renderingProperties: "); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -116,6 +203,8 @@ BinaryData IPersistableModel.Write(ModelRe { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppDiagnosticsDataApiResult)} does not support '{options.Format}' format."); } @@ -132,6 +221,8 @@ ContainerAppDiagnosticsDataApiResult IPersistableModel Table response. + [WirePath("table")] public ContainerAppDiagnosticDataTableResult Table { get; set; } /// Details of the table response. + [WirePath("renderingProperties")] public ContainerAppDiagnosticRendering RenderingProperties { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticsMetadata.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticsMetadata.Serialization.cs index 63d22604ae520..330ce0755cec1 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticsMetadata.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticsMetadata.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; using Azure.ResourceManager.Models; @@ -236,6 +239,250 @@ internal static ContainerAppDiagnosticsMetadata DeserializeContainerAppDiagnosti serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); + if (Optional.IsDefined(Description) || hasPropertyOverride) + { + builder.Append(" description: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Description.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Description}'''"); + } + else + { + builder.AppendLine($"'{Description}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Author), out propertyOverride); + if (Optional.IsDefined(Author) || hasPropertyOverride) + { + builder.Append(" author: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Author.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Author}'''"); + } + else + { + builder.AppendLine($"'{Author}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Category), out propertyOverride); + if (Optional.IsDefined(Category) || hasPropertyOverride) + { + builder.Append(" category: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Category.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Category}'''"); + } + else + { + builder.AppendLine($"'{Category}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SupportTopicList), out propertyOverride); + if (Optional.IsCollectionDefined(SupportTopicList) || hasPropertyOverride) + { + if (SupportTopicList.Any() || hasPropertyOverride) + { + builder.Append(" supportTopicList: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in SupportTopicList) + { + AppendChildObject(builder, item, options, 4, true, " supportTopicList: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AnalysisTypes), out propertyOverride); + if (Optional.IsCollectionDefined(AnalysisTypes) || hasPropertyOverride) + { + if (AnalysisTypes.Any() || hasPropertyOverride) + { + builder.Append(" analysisTypes: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in AnalysisTypes) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Score), out propertyOverride); + if (Optional.IsDefined(Score) || hasPropertyOverride) + { + builder.Append(" score: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Score.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -244,6 +491,8 @@ BinaryData IPersistableModel.Write(ModelReaderW { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppDiagnosticsMetadata)} does not support '{options.Format}' format."); } @@ -260,6 +509,8 @@ ContainerAppDiagnosticsMetadata IPersistableModel Details of the diagnostics info. + [WirePath("description")] public string Description { get; } /// Authors' names of the detector. + [WirePath("author")] public string Author { get; } /// Category of the detector. + [WirePath("category")] public string Category { get; } /// List of support topics. + [WirePath("supportTopicList")] public IList SupportTopicList { get; } /// List of analysis types. + [WirePath("analysisTypes")] public IList AnalysisTypes { get; } /// Authors' names of the detector. + [WirePath("score")] public float? Score { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticsProperties.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticsProperties.Serialization.cs index fed09e88d0fe4..949afad22254b 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticsProperties.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticsProperties.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -148,6 +151,127 @@ internal static ContainerAppDiagnosticsProperties DeserializeContainerAppDiagnos return new ContainerAppDiagnosticsProperties(metadata, dataset ?? new ChangeTrackingList(), status, dataProviderMetadata, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Metadata), out propertyOverride); + if (Optional.IsDefined(Metadata) || hasPropertyOverride) + { + builder.Append(" metadata: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Metadata, options, 2, false, " metadata: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Dataset), out propertyOverride); + if (Optional.IsCollectionDefined(Dataset) || hasPropertyOverride) + { + if (Dataset.Any() || hasPropertyOverride) + { + builder.Append(" dataset: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Dataset) + { + AppendChildObject(builder, item, options, 4, true, " dataset: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); + if (Optional.IsDefined(Status) || hasPropertyOverride) + { + builder.Append(" status: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Status, options, 2, false, " status: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DataProviderMetadata), out propertyOverride); + if (Optional.IsDefined(DataProviderMetadata) || hasPropertyOverride) + { + builder.Append(" dataProviderMetadata: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, DataProviderMetadata, options, 2, false, " dataProviderMetadata: "); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -156,6 +280,8 @@ BinaryData IPersistableModel.Write(ModelReade { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppDiagnosticsProperties)} does not support '{options.Format}' format."); } @@ -172,6 +298,8 @@ ContainerAppDiagnosticsProperties IPersistableModel Metadata of the diagnostics response. + [WirePath("metadata")] public ContainerAppDiagnosticsMetadata Metadata { get; set; } /// Set of data collections associated with the response. + [WirePath("dataset")] public IList Dataset { get; } /// Status of the diagnostics response. + [WirePath("status")] public ContainerAppDiagnosticsStatus Status { get; set; } /// List of data providers' metadata. + [WirePath("dataProviderMetadata")] public ContainerAppDiagnosticDataProviderMetadata DataProviderMetadata { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticsStatus.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticsStatus.Serialization.cs index 2b48b1dab10a0..bbd6a7c9a1681 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticsStatus.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticsStatus.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -104,6 +106,99 @@ internal static ContainerAppDiagnosticsStatus DeserializeContainerAppDiagnostics return new ContainerAppDiagnosticsStatus(message, statusId, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Message), out propertyOverride); + if (Optional.IsDefined(Message) || hasPropertyOverride) + { + builder.Append(" message: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Message.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Message}'''"); + } + else + { + builder.AppendLine($"'{Message}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StatusId), out propertyOverride); + if (Optional.IsDefined(StatusId) || hasPropertyOverride) + { + builder.Append(" statusId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{StatusId.Value}"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -112,6 +207,8 @@ BinaryData IPersistableModel.Write(ModelReaderWri { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppDiagnosticsStatus)} does not support '{options.Format}' format."); } @@ -128,6 +225,8 @@ ContainerAppDiagnosticsStatus IPersistableModel.C using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppDiagnosticsStatus(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppDiagnosticsStatus)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticsStatus.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticsStatus.cs index 453140d54d7d7..8df45a32e5ce9 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticsStatus.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticsStatus.cs @@ -62,8 +62,10 @@ internal ContainerAppDiagnosticsStatus(string message, int? statusId, IDictionar } /// Diagnostic message. + [WirePath("message")] public string Message { get; set; } /// Status. + [WirePath("statusId")] public int? StatusId { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppEnvironmentAuthToken.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppEnvironmentAuthToken.Serialization.cs index 8f6348df4ef5f..dd04e5cafe04c 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppEnvironmentAuthToken.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppEnvironmentAuthToken.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; using Azure.ResourceManager.Models; @@ -211,6 +214,200 @@ internal static ContainerAppEnvironmentAuthToken DeserializeContainerAppEnvironm serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); + builder.Append(" location: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Location.ToString()}'"); + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tags), out propertyOverride); + if (Optional.IsCollectionDefined(Tags) || hasPropertyOverride) + { + if (Tags.Any() || hasPropertyOverride) + { + builder.Append(" tags: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("{"); + foreach (var item in Tags) + { + builder.Append($" '{item.Key}': "); + if (item.Value == null) + { + builder.Append("null"); + continue; + } + if (item.Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{item.Value}'''"); + } + else + { + builder.AppendLine($"'{item.Value}'"); + } + } + builder.AppendLine(" }"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Token), out propertyOverride); + if (Optional.IsDefined(Token) || hasPropertyOverride) + { + builder.Append(" token: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Token.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Token}'''"); + } + else + { + builder.AppendLine($"'{Token}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExpireOn), out propertyOverride); + if (Optional.IsDefined(ExpireOn) || hasPropertyOverride) + { + builder.Append(" expires: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(ExpireOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -219,6 +416,8 @@ BinaryData IPersistableModel.Write(ModelReader { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppEnvironmentAuthToken)} does not support '{options.Format}' format."); } @@ -235,6 +434,8 @@ ContainerAppEnvironmentAuthToken IPersistableModel Auth token value. + [WirePath("properties.token")] public string Token { get; } /// Token expiration date. + [WirePath("properties.expires")] public DateTimeOffset? ExpireOn { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppEnvironmentVariable.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppEnvironmentVariable.Serialization.cs index b704af55371d6..cd6f292b5e34d 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppEnvironmentVariable.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppEnvironmentVariable.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -111,6 +113,129 @@ internal static ContainerAppEnvironmentVariable DeserializeContainerAppEnvironme return new ContainerAppEnvironmentVariable(name, value, secretRef, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsDefined(Value) || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Value}'''"); + } + else + { + builder.AppendLine($"'{Value}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SecretRef), out propertyOverride); + if (Optional.IsDefined(SecretRef) || hasPropertyOverride) + { + builder.Append(" secretRef: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (SecretRef.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{SecretRef}'''"); + } + else + { + builder.AppendLine($"'{SecretRef}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -119,6 +244,8 @@ BinaryData IPersistableModel.Write(ModelReaderW { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppEnvironmentVariable)} does not support '{options.Format}' format."); } @@ -135,6 +262,8 @@ ContainerAppEnvironmentVariable IPersistableModel Environment variable name. + [WirePath("name")] public string Name { get; set; } /// Non-secret environment variable value. + [WirePath("value")] public string Value { get; set; } /// Name of the Container App secret from which to pull the environment variable value. + [WirePath("secretRef")] public string SecretRef { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppExtendedLocation.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppExtendedLocation.Serialization.cs index 12acc2fcd8f4c..feeab7e1959eb 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppExtendedLocation.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppExtendedLocation.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -104,6 +106,85 @@ internal static ContainerAppExtendedLocation DeserializeContainerAppExtendedLoca return new ContainerAppExtendedLocation(name, type, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -112,6 +193,8 @@ BinaryData IPersistableModel.Write(ModelReaderWrit { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppExtendedLocation)} does not support '{options.Format}' format."); } @@ -128,6 +211,8 @@ ContainerAppExtendedLocation IPersistableModel.Cre using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppExtendedLocation(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppExtendedLocation)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppExtendedLocation.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppExtendedLocation.cs index ea17871747baf..0afe40cc68db3 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppExtendedLocation.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppExtendedLocation.cs @@ -62,8 +62,10 @@ internal ContainerAppExtendedLocation(string name, ContainerAppExtendedLocationT } /// The name of the extended location. + [WirePath("name")] public string Name { get; set; } /// The type of the extended location. + [WirePath("type")] public ContainerAppExtendedLocationType? ExtendedLocationType { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppFacebookConfiguration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppFacebookConfiguration.Serialization.cs index 1e4fbca35c584..bf306af2e2745 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppFacebookConfiguration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppFacebookConfiguration.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -134,6 +136,128 @@ internal static ContainerAppFacebookConfiguration DeserializeContainerAppFaceboo return new ContainerAppFacebookConfiguration(enabled, registration, graphApiVersion, login, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); + if (Optional.IsDefined(IsEnabled) || hasPropertyOverride) + { + builder.Append(" enabled: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsEnabled.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Registration), out propertyOverride); + if (Optional.IsDefined(Registration) || hasPropertyOverride) + { + builder.Append(" registration: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Registration, options, 2, false, " registration: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(GraphApiVersion), out propertyOverride); + if (Optional.IsDefined(GraphApiVersion) || hasPropertyOverride) + { + builder.Append(" graphApiVersion: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (GraphApiVersion.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{GraphApiVersion}'''"); + } + else + { + builder.AppendLine($"'{GraphApiVersion}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Login), out propertyOverride); + if (Optional.IsDefined(Login) || hasPropertyOverride) + { + builder.Append(" login: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Login, options, 2, false, " login: "); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -142,6 +266,8 @@ BinaryData IPersistableModel.Write(ModelReade { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppFacebookConfiguration)} does not support '{options.Format}' format."); } @@ -158,6 +284,8 @@ ContainerAppFacebookConfiguration IPersistableModel <code>false</code> if the Facebook provider should not be enabled despite the set registration; otherwise, <code>true</code>. + [WirePath("enabled")] public bool? IsEnabled { get; set; } /// The configuration settings of the app registration for the Facebook provider. + [WirePath("registration")] public ContainerAppRegistration Registration { get; set; } /// The version of the Facebook api to be used while logging in. + [WirePath("graphApiVersion")] public string GraphApiVersion { get; set; } /// The configuration settings of the login flow. internal LoginScopes Login { get; set; } /// A list of the scopes that should be requested while authenticating. + [WirePath("login.scopes")] public IList LoginScopes { get diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppForwardProxy.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppForwardProxy.Serialization.cs index 846c641e4d4f4..45fe922a5b328 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppForwardProxy.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppForwardProxy.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -115,6 +117,121 @@ internal static ContainerAppForwardProxy DeserializeContainerAppForwardProxy(Jso return new ContainerAppForwardProxy(convention, customHostHeaderName, customProtoHeaderName, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Convention), out propertyOverride); + if (Optional.IsDefined(Convention) || hasPropertyOverride) + { + builder.Append(" convention: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Convention.Value.ToSerialString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CustomHostHeaderName), out propertyOverride); + if (Optional.IsDefined(CustomHostHeaderName) || hasPropertyOverride) + { + builder.Append(" customHostHeaderName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (CustomHostHeaderName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{CustomHostHeaderName}'''"); + } + else + { + builder.AppendLine($"'{CustomHostHeaderName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CustomProtoHeaderName), out propertyOverride); + if (Optional.IsDefined(CustomProtoHeaderName) || hasPropertyOverride) + { + builder.Append(" customProtoHeaderName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (CustomProtoHeaderName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{CustomProtoHeaderName}'''"); + } + else + { + builder.AppendLine($"'{CustomProtoHeaderName}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -123,6 +240,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOp { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppForwardProxy)} does not support '{options.Format}' format."); } @@ -139,6 +258,8 @@ ContainerAppForwardProxy IPersistableModel.Create(Bina using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppForwardProxy(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppForwardProxy)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppForwardProxy.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppForwardProxy.cs index 07cc164919552..a6695ed9e3b72 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppForwardProxy.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppForwardProxy.cs @@ -64,10 +64,13 @@ internal ContainerAppForwardProxy(ContainerAppForwardProxyConvention? convention } /// The convention used to determine the url of the request made. + [WirePath("convention")] public ContainerAppForwardProxyConvention? Convention { get; set; } /// The name of the header containing the host of the request. + [WirePath("customHostHeaderName")] public string CustomHostHeaderName { get; set; } /// The name of the header containing the scheme of the request. + [WirePath("customProtoHeaderName")] public string CustomProtoHeaderName { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppGitHubActionConfiguration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppGitHubActionConfiguration.Serialization.cs index 7fdcfe481d381..52b26a422f508 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppGitHubActionConfiguration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppGitHubActionConfiguration.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -195,6 +197,245 @@ internal static ContainerAppGitHubActionConfiguration DeserializeContainerAppGit serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RegistryInfo), out propertyOverride); + if (Optional.IsDefined(RegistryInfo) || hasPropertyOverride) + { + builder.Append(" registryInfo: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, RegistryInfo, options, 2, false, " registryInfo: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AzureCredentials), out propertyOverride); + if (Optional.IsDefined(AzureCredentials) || hasPropertyOverride) + { + builder.Append(" azureCredentials: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, AzureCredentials, options, 2, false, " azureCredentials: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ContextPath), out propertyOverride); + if (Optional.IsDefined(ContextPath) || hasPropertyOverride) + { + builder.Append(" contextPath: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ContextPath.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ContextPath}'''"); + } + else + { + builder.AppendLine($"'{ContextPath}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(GitHubPersonalAccessToken), out propertyOverride); + if (Optional.IsDefined(GitHubPersonalAccessToken) || hasPropertyOverride) + { + builder.Append(" githubPersonalAccessToken: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (GitHubPersonalAccessToken.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{GitHubPersonalAccessToken}'''"); + } + else + { + builder.AppendLine($"'{GitHubPersonalAccessToken}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Image), out propertyOverride); + if (Optional.IsDefined(Image) || hasPropertyOverride) + { + builder.Append(" image: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Image.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Image}'''"); + } + else + { + builder.AppendLine($"'{Image}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PublishType), out propertyOverride); + if (Optional.IsDefined(PublishType) || hasPropertyOverride) + { + builder.Append(" publishType: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (PublishType.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{PublishType}'''"); + } + else + { + builder.AppendLine($"'{PublishType}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(OS), out propertyOverride); + if (Optional.IsDefined(OS) || hasPropertyOverride) + { + builder.Append(" os: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (OS.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{OS}'''"); + } + else + { + builder.AppendLine($"'{OS}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RuntimeStack), out propertyOverride); + if (Optional.IsDefined(RuntimeStack) || hasPropertyOverride) + { + builder.Append(" runtimeStack: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (RuntimeStack.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{RuntimeStack}'''"); + } + else + { + builder.AppendLine($"'{RuntimeStack}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RuntimeVersion), out propertyOverride); + if (Optional.IsDefined(RuntimeVersion) || hasPropertyOverride) + { + builder.Append(" runtimeVersion: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (RuntimeVersion.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{RuntimeVersion}'''"); + } + else + { + builder.AppendLine($"'{RuntimeVersion}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -203,6 +444,8 @@ BinaryData IPersistableModel.Write(ModelR { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppGitHubActionConfiguration)} does not support '{options.Format}' format."); } @@ -219,6 +462,8 @@ ContainerAppGitHubActionConfiguration IPersistableModel Registry configurations. + [WirePath("registryInfo")] public ContainerAppRegistryInfo RegistryInfo { get; set; } /// AzureCredentials configurations. + [WirePath("azureCredentials")] public ContainerAppCredentials AzureCredentials { get; set; } /// Context path. + [WirePath("contextPath")] public string ContextPath { get; set; } /// One time Github PAT to configure github environment. + [WirePath("githubPersonalAccessToken")] public string GitHubPersonalAccessToken { get; set; } /// Image name. + [WirePath("image")] public string Image { get; set; } /// Code or Image. + [WirePath("publishType")] public string PublishType { get; set; } /// Operation system. + [WirePath("os")] public string OS { get; set; } /// Runtime stack. + [WirePath("runtimeStack")] public string RuntimeStack { get; set; } /// Runtime version. + [WirePath("runtimeVersion")] public string RuntimeVersion { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppGitHubConfiguration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppGitHubConfiguration.Serialization.cs index 2c01af381c1c0..2b41edd14691b 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppGitHubConfiguration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppGitHubConfiguration.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -123,6 +125,106 @@ internal static ContainerAppGitHubConfiguration DeserializeContainerAppGitHubCon return new ContainerAppGitHubConfiguration(enabled, registration, login, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); + if (Optional.IsDefined(IsEnabled) || hasPropertyOverride) + { + builder.Append(" enabled: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsEnabled.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Registration), out propertyOverride); + if (Optional.IsDefined(Registration) || hasPropertyOverride) + { + builder.Append(" registration: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Registration, options, 2, false, " registration: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Login), out propertyOverride); + if (Optional.IsDefined(Login) || hasPropertyOverride) + { + builder.Append(" login: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Login, options, 2, false, " login: "); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -131,6 +233,8 @@ BinaryData IPersistableModel.Write(ModelReaderW { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppGitHubConfiguration)} does not support '{options.Format}' format."); } @@ -147,6 +251,8 @@ ContainerAppGitHubConfiguration IPersistableModel <code>false</code> if the GitHub provider should not be enabled despite the set registration; otherwise, <code>true</code>. + [WirePath("enabled")] public bool? IsEnabled { get; set; } /// The configuration settings of the app registration for the GitHub provider. + [WirePath("registration")] public ContainerAppClientRegistration Registration { get; set; } /// The configuration settings of the login flow. internal LoginScopes Login { get; set; } /// A list of the scopes that should be requested while authenticating. + [WirePath("login.scopes")] public IList LoginScopes { get diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppGlobalValidation.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppGlobalValidation.Serialization.cs index 80705590b1f05..4d97a0abcf940 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppGlobalValidation.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppGlobalValidation.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -129,6 +132,134 @@ internal static ContainerAppGlobalValidation DeserializeContainerAppGlobalValida return new ContainerAppGlobalValidation(unauthenticatedClientAction, redirectToProvider, excludedPaths ?? new ChangeTrackingList(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(UnauthenticatedClientAction), out propertyOverride); + if (Optional.IsDefined(UnauthenticatedClientAction) || hasPropertyOverride) + { + builder.Append(" unauthenticatedClientAction: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{UnauthenticatedClientAction.Value.ToSerialString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RedirectToProvider), out propertyOverride); + if (Optional.IsDefined(RedirectToProvider) || hasPropertyOverride) + { + builder.Append(" redirectToProvider: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (RedirectToProvider.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{RedirectToProvider}'''"); + } + else + { + builder.AppendLine($"'{RedirectToProvider}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExcludedPaths), out propertyOverride); + if (Optional.IsCollectionDefined(ExcludedPaths) || hasPropertyOverride) + { + if (ExcludedPaths.Any() || hasPropertyOverride) + { + builder.Append(" excludedPaths: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in ExcludedPaths) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -137,6 +268,8 @@ BinaryData IPersistableModel.Write(ModelReaderWrit { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppGlobalValidation)} does not support '{options.Format}' format."); } @@ -153,6 +286,8 @@ ContainerAppGlobalValidation IPersistableModel.Cre using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppGlobalValidation(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppGlobalValidation)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppGlobalValidation.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppGlobalValidation.cs index e26d24cb3370e..1f57bd0e56598 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppGlobalValidation.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppGlobalValidation.cs @@ -70,14 +70,17 @@ internal ContainerAppGlobalValidation(ContainerAppUnauthenticatedClientActionV2? } /// The action to take when an unauthenticated client attempts to access the app. + [WirePath("unauthenticatedClientAction")] public ContainerAppUnauthenticatedClientActionV2? UnauthenticatedClientAction { get; set; } /// /// The default authentication provider to use when multiple providers are configured. /// This setting is only needed if multiple providers are configured and the unauthenticated client /// action is set to "RedirectToLoginPage". /// + [WirePath("redirectToProvider")] public string RedirectToProvider { get; set; } /// The paths for which unauthenticated flow would not be redirected to the login page. + [WirePath("excludedPaths")] public IList ExcludedPaths { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppGoogleConfiguration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppGoogleConfiguration.Serialization.cs index d1bba341cdbcc..ed71f5bb33f64 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppGoogleConfiguration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppGoogleConfiguration.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -138,6 +140,120 @@ internal static ContainerAppGoogleConfiguration DeserializeContainerAppGoogleCon return new ContainerAppGoogleConfiguration(enabled, registration, login, validation, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); + if (Optional.IsDefined(IsEnabled) || hasPropertyOverride) + { + builder.Append(" enabled: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsEnabled.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Registration), out propertyOverride); + if (Optional.IsDefined(Registration) || hasPropertyOverride) + { + builder.Append(" registration: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Registration, options, 2, false, " registration: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Login), out propertyOverride); + if (Optional.IsDefined(Login) || hasPropertyOverride) + { + builder.Append(" login: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Login, options, 2, false, " login: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Validation), out propertyOverride); + if (Optional.IsDefined(Validation) || hasPropertyOverride) + { + builder.Append(" validation: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Validation, options, 2, false, " validation: "); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -146,6 +262,8 @@ BinaryData IPersistableModel.Write(ModelReaderW { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppGoogleConfiguration)} does not support '{options.Format}' format."); } @@ -162,6 +280,8 @@ ContainerAppGoogleConfiguration IPersistableModel <code>false</code> if the Google provider should not be enabled despite the set registration; otherwise, <code>true</code>. + [WirePath("enabled")] public bool? IsEnabled { get; set; } /// The configuration settings of the app registration for the Google provider. + [WirePath("registration")] public ContainerAppClientRegistration Registration { get; set; } /// The configuration settings of the login flow. internal LoginScopes Login { get; set; } /// A list of the scopes that should be requested while authenticating. + [WirePath("login.scopes")] public IList LoginScopes { get @@ -85,6 +88,7 @@ public IList LoginScopes /// The configuration settings of the Azure Active Directory token validation flow. internal AllowedAudiencesValidation Validation { get; set; } /// The configuration settings of the allowed list of audiences from which to validate the JWT token. + [WirePath("validation.allowedAudiences")] public IList ValidationAllowedAudiences { get diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpHeaderInfo.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpHeaderInfo.Serialization.cs index 339569b5c493b..acf5259063c7e 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpHeaderInfo.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpHeaderInfo.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; +using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models { @@ -93,6 +96,107 @@ internal static ContainerAppHttpHeaderInfo DeserializeContainerAppHttpHeaderInfo return new ContainerAppHttpHeaderInfo(name, value, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsDefined(Value) || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Value}'''"); + } + else + { + builder.AppendLine($"'{Value}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -101,6 +205,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriter { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppHttpHeaderInfo)} does not support '{options.Format}' format."); } @@ -117,6 +223,8 @@ ContainerAppHttpHeaderInfo IPersistableModel.Create( using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppHttpHeaderInfo(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppHttpHeaderInfo)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpHeaderInfo.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpHeaderInfo.cs index 4f27b1b9024d7..ec41627afd223 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpHeaderInfo.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpHeaderInfo.cs @@ -76,8 +76,10 @@ internal ContainerAppHttpHeaderInfo() } /// The header field name. + [WirePath("name")] public string Name { get; set; } /// The header field value. + [WirePath("value")] public string Value { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpRequestInfo.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpRequestInfo.Serialization.cs index 07645245f9b5f..366092a30af39 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpRequestInfo.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpRequestInfo.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -154,6 +157,154 @@ internal static ContainerAppHttpRequestInfo DeserializeContainerAppHttpRequestIn serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Host), out propertyOverride); + if (Optional.IsDefined(Host) || hasPropertyOverride) + { + builder.Append(" host: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Host.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Host}'''"); + } + else + { + builder.AppendLine($"'{Host}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HttpHeaders), out propertyOverride); + if (Optional.IsCollectionDefined(HttpHeaders) || hasPropertyOverride) + { + if (HttpHeaders.Any() || hasPropertyOverride) + { + builder.Append(" httpHeaders: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in HttpHeaders) + { + AppendChildObject(builder, item, options, 4, true, " httpHeaders: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Path), out propertyOverride); + if (Optional.IsDefined(Path) || hasPropertyOverride) + { + builder.Append(" path: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Path.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Path}'''"); + } + else + { + builder.AppendLine($"'{Path}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Port), out propertyOverride); + builder.Append(" port: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{Port}"); + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Scheme), out propertyOverride); + if (Optional.IsDefined(Scheme) || hasPropertyOverride) + { + builder.Append(" scheme: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Scheme.Value.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -162,6 +313,8 @@ BinaryData IPersistableModel.Write(ModelReaderWrite { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppHttpRequestInfo)} does not support '{options.Format}' format."); } @@ -178,6 +331,8 @@ ContainerAppHttpRequestInfo IPersistableModel.Creat using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppHttpRequestInfo(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppHttpRequestInfo)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpRequestInfo.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpRequestInfo.cs index 52705ba212463..1b42e37520992 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpRequestInfo.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpRequestInfo.cs @@ -77,14 +77,19 @@ internal ContainerAppHttpRequestInfo() } /// Host name to connect to, defaults to the pod IP. You probably want to set "Host" in httpHeaders instead. + [WirePath("host")] public string Host { get; set; } /// Custom headers to set in the request. HTTP allows repeated headers. + [WirePath("httpHeaders")] public IList HttpHeaders { get; } /// Path to access on the HTTP server. + [WirePath("path")] public string Path { get; set; } /// Name or number of the port to access on the container. Number must be in the range 1 to 65535. Name must be an IANA_SVC_NAME. + [WirePath("port")] public int Port { get; set; } /// Scheme to use for connecting to the host. Defaults to HTTP. + [WirePath("scheme")] public ContainerAppHttpScheme? Scheme { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpScaleRule.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpScaleRule.Serialization.cs index 19a87be29e9c6..72b6ef0af056e 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpScaleRule.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpScaleRule.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -129,6 +132,121 @@ internal static ContainerAppHttpScaleRule DeserializeContainerAppHttpScaleRule(J return new ContainerAppHttpScaleRule(metadata ?? new ChangeTrackingDictionary(), auth ?? new ChangeTrackingList(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Metadata), out propertyOverride); + if (Optional.IsCollectionDefined(Metadata) || hasPropertyOverride) + { + if (Metadata.Any() || hasPropertyOverride) + { + builder.Append(" metadata: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("{"); + foreach (var item in Metadata) + { + builder.Append($" '{item.Key}': "); + if (item.Value == null) + { + builder.Append("null"); + continue; + } + if (item.Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{item.Value}'''"); + } + else + { + builder.AppendLine($"'{item.Value}'"); + } + } + builder.AppendLine(" }"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Auth), out propertyOverride); + if (Optional.IsCollectionDefined(Auth) || hasPropertyOverride) + { + if (Auth.Any() || hasPropertyOverride) + { + builder.Append(" auth: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Auth) + { + AppendChildObject(builder, item, options, 4, true, " auth: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -137,6 +255,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterO { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppHttpScaleRule)} does not support '{options.Format}' format."); } @@ -153,6 +273,8 @@ ContainerAppHttpScaleRule IPersistableModel.Create(Bi using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppHttpScaleRule(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppHttpScaleRule)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpScaleRule.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpScaleRule.cs index 549b974c9ef7d..ee722c6a32377 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpScaleRule.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpScaleRule.cs @@ -66,8 +66,10 @@ internal ContainerAppHttpScaleRule(IDictionary metadata, IList Metadata properties to describe http scale rule. + [WirePath("metadata")] public IDictionary Metadata { get; } /// Authentication secrets for the custom scale rule. + [WirePath("auth")] public IList Auth { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpSettings.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpSettings.Serialization.cs index 2bd7a2147b114..fa986b4b2197e 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpSettings.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpSettings.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -123,6 +125,106 @@ internal static ContainerAppHttpSettings DeserializeContainerAppHttpSettings(Jso return new ContainerAppHttpSettings(requireHttps, routes, forwardProxy, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RequireHttps), out propertyOverride); + if (Optional.IsDefined(RequireHttps) || hasPropertyOverride) + { + builder.Append(" requireHttps: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = RequireHttps.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Routes), out propertyOverride); + if (Optional.IsDefined(Routes) || hasPropertyOverride) + { + builder.Append(" routes: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Routes, options, 2, false, " routes: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ForwardProxy), out propertyOverride); + if (Optional.IsDefined(ForwardProxy) || hasPropertyOverride) + { + builder.Append(" forwardProxy: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, ForwardProxy, options, 2, false, " forwardProxy: "); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -131,6 +233,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOp { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppHttpSettings)} does not support '{options.Format}' format."); } @@ -147,6 +251,8 @@ ContainerAppHttpSettings IPersistableModel.Create(Bina using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppHttpSettings(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppHttpSettings)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpSettings.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpSettings.cs index 0efcfdcc2b51f..4ad8a02f46f78 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpSettings.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpSettings.cs @@ -64,10 +64,12 @@ internal ContainerAppHttpSettings(bool? requireHttps, HttpSettingsRoutes routes, } /// <code>false</code> if the authentication/authorization responses not having the HTTPS scheme are permissible; otherwise, <code>true</code>. + [WirePath("requireHttps")] public bool? RequireHttps { get; set; } /// The configuration settings of the paths HTTP requests. internal HttpSettingsRoutes Routes { get; set; } /// The prefix that should precede all the authentication/authorization paths. + [WirePath("routes.apiPrefix")] public string RoutesApiPrefix { get => Routes is null ? default : Routes.ApiPrefix; @@ -80,6 +82,7 @@ public string RoutesApiPrefix } /// The configuration settings of a forward proxy used to make the requests. + [WirePath("forwardProxy")] public ContainerAppForwardProxy ForwardProxy { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppIPSecurityRestrictionRule.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppIPSecurityRestrictionRule.Serialization.cs index 02b8d0987772e..57e8630d7fb08 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppIPSecurityRestrictionRule.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppIPSecurityRestrictionRule.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -113,6 +115,140 @@ internal static ContainerAppIPSecurityRestrictionRule DeserializeContainerAppIPS return new ContainerAppIPSecurityRestrictionRule(name, description, ipAddressRange, action, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); + if (Optional.IsDefined(Description) || hasPropertyOverride) + { + builder.Append(" description: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Description.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Description}'''"); + } + else + { + builder.AppendLine($"'{Description}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IPAddressRange), out propertyOverride); + if (Optional.IsDefined(IPAddressRange) || hasPropertyOverride) + { + builder.Append(" ipAddressRange: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (IPAddressRange.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{IPAddressRange}'''"); + } + else + { + builder.AppendLine($"'{IPAddressRange}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Action), out propertyOverride); + builder.Append(" action: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Action.ToString()}'"); + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -121,6 +257,8 @@ BinaryData IPersistableModel.Write(ModelR { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppIPSecurityRestrictionRule)} does not support '{options.Format}' format."); } @@ -137,6 +275,8 @@ ContainerAppIPSecurityRestrictionRule IPersistableModel Name for the IP restriction rule. + [WirePath("name")] public string Name { get; set; } /// Describe the IP restriction rule that is being sent to the container-app. This is an optional field. + [WirePath("description")] public string Description { get; set; } /// CIDR notation to match incoming IP address. + [WirePath("ipAddressRange")] public string IPAddressRange { get; set; } /// Allow or Deny rules to determine for incoming IP. Note: Rules can only consist of ALL Allow or ALL Deny. + [WirePath("action")] public ContainerAppIPRuleAction Action { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppIdentityProvidersConfiguration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppIdentityProvidersConfiguration.Serialization.cs index cc549a4b5bacb..156ba28e294b4 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppIdentityProvidersConfiguration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppIdentityProvidersConfiguration.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -218,6 +221,184 @@ internal static ContainerAppIdentityProvidersConfiguration DeserializeContainerA serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AzureActiveDirectory), out propertyOverride); + if (Optional.IsDefined(AzureActiveDirectory) || hasPropertyOverride) + { + builder.Append(" azureActiveDirectory: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, AzureActiveDirectory, options, 2, false, " azureActiveDirectory: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Facebook), out propertyOverride); + if (Optional.IsDefined(Facebook) || hasPropertyOverride) + { + builder.Append(" facebook: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Facebook, options, 2, false, " facebook: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(GitHub), out propertyOverride); + if (Optional.IsDefined(GitHub) || hasPropertyOverride) + { + builder.Append(" gitHub: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, GitHub, options, 2, false, " gitHub: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Google), out propertyOverride); + if (Optional.IsDefined(Google) || hasPropertyOverride) + { + builder.Append(" google: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Google, options, 2, false, " google: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Twitter), out propertyOverride); + if (Optional.IsDefined(Twitter) || hasPropertyOverride) + { + builder.Append(" twitter: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Twitter, options, 2, false, " twitter: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Apple), out propertyOverride); + if (Optional.IsDefined(Apple) || hasPropertyOverride) + { + builder.Append(" apple: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Apple, options, 2, false, " apple: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AzureStaticWebApps), out propertyOverride); + if (Optional.IsDefined(AzureStaticWebApps) || hasPropertyOverride) + { + builder.Append(" azureStaticWebApps: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, AzureStaticWebApps, options, 2, false, " azureStaticWebApps: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CustomOpenIdConnectProviders), out propertyOverride); + if (Optional.IsCollectionDefined(CustomOpenIdConnectProviders) || hasPropertyOverride) + { + if (CustomOpenIdConnectProviders.Any() || hasPropertyOverride) + { + builder.Append(" customOpenIdConnectProviders: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("{"); + foreach (var item in CustomOpenIdConnectProviders) + { + builder.Append($" '{item.Key}': "); + AppendChildObject(builder, item.Value, options, 4, false, " customOpenIdConnectProviders: "); + } + builder.AppendLine(" }"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -226,6 +407,8 @@ BinaryData IPersistableModel.Write(M { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppIdentityProvidersConfiguration)} does not support '{options.Format}' format."); } @@ -242,6 +425,8 @@ ContainerAppIdentityProvidersConfiguration IPersistableModel The configuration settings of the Azure Active directory provider. + [WirePath("azureActiveDirectory")] public ContainerAppAzureActiveDirectoryConfiguration AzureActiveDirectory { get; set; } /// The configuration settings of the Facebook provider. + [WirePath("facebook")] public ContainerAppFacebookConfiguration Facebook { get; set; } /// The configuration settings of the GitHub provider. + [WirePath("gitHub")] public ContainerAppGitHubConfiguration GitHub { get; set; } /// The configuration settings of the Google provider. + [WirePath("google")] public ContainerAppGoogleConfiguration Google { get; set; } /// The configuration settings of the Twitter provider. + [WirePath("twitter")] public ContainerAppTwitterConfiguration Twitter { get; set; } /// The configuration settings of the Apple provider. + [WirePath("apple")] public ContainerAppAppleConfiguration Apple { get; set; } /// The configuration settings of the Azure Static Web Apps provider. + [WirePath("azureStaticWebApps")] public ContainerAppAzureStaticWebAppsConfiguration AzureStaticWebApps { get; set; } /// /// The map of the name of the alias of each custom Open ID Connect provider to the /// configuration settings of the custom Open ID Connect provider. /// + [WirePath("customOpenIdConnectProviders")] public IDictionary CustomOpenIdConnectProviders { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppIngressConfiguration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppIngressConfiguration.Serialization.cs index 2c8b47f1f264c..107e9719a3880 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppIngressConfiguration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppIngressConfiguration.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -297,6 +300,265 @@ internal static ContainerAppIngressConfiguration DeserializeContainerAppIngressC serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Fqdn), out propertyOverride); + if (Optional.IsDefined(Fqdn) || hasPropertyOverride) + { + builder.Append(" fqdn: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Fqdn.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Fqdn}'''"); + } + else + { + builder.AppendLine($"'{Fqdn}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(External), out propertyOverride); + if (Optional.IsDefined(External) || hasPropertyOverride) + { + builder.Append(" external: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = External.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TargetPort), out propertyOverride); + if (Optional.IsDefined(TargetPort) || hasPropertyOverride) + { + builder.Append(" targetPort: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{TargetPort.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExposedPort), out propertyOverride); + if (Optional.IsDefined(ExposedPort) || hasPropertyOverride) + { + builder.Append(" exposedPort: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{ExposedPort.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Transport), out propertyOverride); + if (Optional.IsDefined(Transport) || hasPropertyOverride) + { + builder.Append(" transport: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Transport.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Traffic), out propertyOverride); + if (Optional.IsCollectionDefined(Traffic) || hasPropertyOverride) + { + if (Traffic.Any() || hasPropertyOverride) + { + builder.Append(" traffic: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Traffic) + { + AppendChildObject(builder, item, options, 4, true, " traffic: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CustomDomains), out propertyOverride); + if (Optional.IsCollectionDefined(CustomDomains) || hasPropertyOverride) + { + if (CustomDomains.Any() || hasPropertyOverride) + { + builder.Append(" customDomains: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in CustomDomains) + { + AppendChildObject(builder, item, options, 4, true, " customDomains: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AllowInsecure), out propertyOverride); + if (Optional.IsDefined(AllowInsecure) || hasPropertyOverride) + { + builder.Append(" allowInsecure: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = AllowInsecure.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IPSecurityRestrictions), out propertyOverride); + if (Optional.IsCollectionDefined(IPSecurityRestrictions) || hasPropertyOverride) + { + if (IPSecurityRestrictions.Any() || hasPropertyOverride) + { + builder.Append(" ipSecurityRestrictions: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in IPSecurityRestrictions) + { + AppendChildObject(builder, item, options, 4, true, " ipSecurityRestrictions: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StickySessions), out propertyOverride); + if (Optional.IsDefined(StickySessions) || hasPropertyOverride) + { + builder.Append(" stickySessions: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, StickySessions, options, 2, false, " stickySessions: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ClientCertificateMode), out propertyOverride); + if (Optional.IsDefined(ClientCertificateMode) || hasPropertyOverride) + { + builder.Append(" clientCertificateMode: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ClientCertificateMode.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CorsPolicy), out propertyOverride); + if (Optional.IsDefined(CorsPolicy) || hasPropertyOverride) + { + builder.Append(" corsPolicy: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, CorsPolicy, options, 2, false, " corsPolicy: "); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -305,6 +567,8 @@ BinaryData IPersistableModel.Write(ModelReader { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppIngressConfiguration)} does not support '{options.Format}' format."); } @@ -321,6 +585,8 @@ ContainerAppIngressConfiguration IPersistableModel Hostname. + [WirePath("fqdn")] public string Fqdn { get; } /// Bool indicating if app exposes an external http endpoint. + [WirePath("external")] public bool? External { get; set; } /// Target Port in containers for traffic from ingress. + [WirePath("targetPort")] public int? TargetPort { get; set; } /// Exposed Port in containers for TCP traffic from ingress. + [WirePath("exposedPort")] public int? ExposedPort { get; set; } /// Ingress transport protocol. + [WirePath("transport")] public ContainerAppIngressTransportMethod? Transport { get; set; } /// Traffic weights for app's revisions. + [WirePath("traffic")] public IList Traffic { get; } /// custom domain bindings for Container Apps' hostnames. + [WirePath("customDomains")] public IList CustomDomains { get; } /// Bool indicating if HTTP connections to is allowed. If set to false HTTP connections are automatically redirected to HTTPS connections. + [WirePath("allowInsecure")] public bool? AllowInsecure { get; set; } /// Rules to restrict incoming IP address. + [WirePath("ipSecurityRestrictions")] public IList IPSecurityRestrictions { get; } /// Sticky Sessions for Single Revision Mode. internal IngressStickySessions StickySessions { get; set; } /// Sticky Session Affinity. + [WirePath("stickySessions.affinity")] public Affinity? StickySessionsAffinity { get => StickySessions is null ? default : StickySessions.Affinity; @@ -118,8 +128,10 @@ public Affinity? StickySessionsAffinity } /// Client certificate mode for mTLS authentication. Ignore indicates server drops client certificate on forwarding. Accept indicates server forwards client certificate but does not require a client certificate. Require indicates server requires a client certificate. + [WirePath("clientCertificateMode")] public ContainerAppIngressClientCertificateMode? ClientCertificateMode { get; set; } /// CORS policy for container app. + [WirePath("corsPolicy")] public ContainerAppCorsPolicy CorsPolicy { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppInitContainer.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppInitContainer.Serialization.cs index 11703fce7acf7..87bee20ba9802 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppInitContainer.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppInitContainer.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -223,6 +226,235 @@ internal static ContainerAppInitContainer DeserializeContainerAppInitContainer(J serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Image), out propertyOverride); + if (Optional.IsDefined(Image) || hasPropertyOverride) + { + builder.Append(" image: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Image.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Image}'''"); + } + else + { + builder.AppendLine($"'{Image}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Command), out propertyOverride); + if (Optional.IsCollectionDefined(Command) || hasPropertyOverride) + { + if (Command.Any() || hasPropertyOverride) + { + builder.Append(" command: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Command) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Args), out propertyOverride); + if (Optional.IsCollectionDefined(Args) || hasPropertyOverride) + { + if (Args.Any() || hasPropertyOverride) + { + builder.Append(" args: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Args) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Env), out propertyOverride); + if (Optional.IsCollectionDefined(Env) || hasPropertyOverride) + { + if (Env.Any() || hasPropertyOverride) + { + builder.Append(" env: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Env) + { + AppendChildObject(builder, item, options, 4, true, " env: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Resources), out propertyOverride); + if (Optional.IsDefined(Resources) || hasPropertyOverride) + { + builder.Append(" resources: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Resources, options, 2, false, " resources: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(VolumeMounts), out propertyOverride); + if (Optional.IsCollectionDefined(VolumeMounts) || hasPropertyOverride) + { + if (VolumeMounts.Any() || hasPropertyOverride) + { + builder.Append(" volumeMounts: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in VolumeMounts) + { + AppendChildObject(builder, item, options, 4, true, " volumeMounts: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -231,6 +463,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterO { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppInitContainer)} does not support '{options.Format}' format."); } @@ -247,6 +481,8 @@ ContainerAppInitContainer IPersistableModel.Create(Bi using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppInitContainer(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppInitContainer)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobConfiguration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobConfiguration.Serialization.cs index fc8ab47027ba1..6aa10c6352b9f 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobConfiguration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobConfiguration.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -213,6 +216,185 @@ internal static ContainerAppJobConfiguration DeserializeContainerAppJobConfigura serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Secrets), out propertyOverride); + if (Optional.IsCollectionDefined(Secrets) || hasPropertyOverride) + { + if (Secrets.Any() || hasPropertyOverride) + { + builder.Append(" secrets: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Secrets) + { + AppendChildObject(builder, item, options, 4, true, " secrets: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TriggerType), out propertyOverride); + builder.Append(" triggerType: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{TriggerType.ToString()}'"); + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ReplicaTimeout), out propertyOverride); + builder.Append(" replicaTimeout: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{ReplicaTimeout}"); + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ReplicaRetryLimit), out propertyOverride); + if (Optional.IsDefined(ReplicaRetryLimit) || hasPropertyOverride) + { + builder.Append(" replicaRetryLimit: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{ReplicaRetryLimit.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ManualTriggerConfig), out propertyOverride); + if (Optional.IsDefined(ManualTriggerConfig) || hasPropertyOverride) + { + builder.Append(" manualTriggerConfig: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, ManualTriggerConfig, options, 2, false, " manualTriggerConfig: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ScheduleTriggerConfig), out propertyOverride); + if (Optional.IsDefined(ScheduleTriggerConfig) || hasPropertyOverride) + { + builder.Append(" scheduleTriggerConfig: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, ScheduleTriggerConfig, options, 2, false, " scheduleTriggerConfig: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EventTriggerConfig), out propertyOverride); + if (Optional.IsDefined(EventTriggerConfig) || hasPropertyOverride) + { + builder.Append(" eventTriggerConfig: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, EventTriggerConfig, options, 2, false, " eventTriggerConfig: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Registries), out propertyOverride); + if (Optional.IsCollectionDefined(Registries) || hasPropertyOverride) + { + if (Registries.Any() || hasPropertyOverride) + { + builder.Append(" registries: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Registries) + { + AppendChildObject(builder, item, options, 4, true, " registries: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -221,6 +403,8 @@ BinaryData IPersistableModel.Write(ModelReaderWrit { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppJobConfiguration)} does not support '{options.Format}' format."); } @@ -237,6 +421,8 @@ ContainerAppJobConfiguration IPersistableModel.Cre using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppJobConfiguration(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppJobConfiguration)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobConfiguration.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobConfiguration.cs index d257ba8f177e2..effbd8f0d05bd 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobConfiguration.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobConfiguration.cs @@ -86,20 +86,28 @@ internal ContainerAppJobConfiguration() } /// Collection of secrets used by a Container Apps Job. + [WirePath("secrets")] public IList Secrets { get; } /// Trigger type of the job. + [WirePath("triggerType")] public ContainerAppJobTriggerType TriggerType { get; set; } /// Maximum number of seconds a replica is allowed to run. + [WirePath("replicaTimeout")] public int ReplicaTimeout { get; set; } /// Maximum number of retries before failing the job. + [WirePath("replicaRetryLimit")] public int? ReplicaRetryLimit { get; set; } /// Manual trigger configuration for a single execution job. Properties replicaCompletionCount and parallelism would be set to 1 by default. + [WirePath("manualTriggerConfig")] public JobConfigurationManualTriggerConfig ManualTriggerConfig { get; set; } /// Cron formatted repeating trigger schedule ("* * * * *") for cronjobs. Properties completions and parallelism would be set to 1 by default. + [WirePath("scheduleTriggerConfig")] public JobConfigurationScheduleTriggerConfig ScheduleTriggerConfig { get; set; } /// Trigger configuration of an event driven job. + [WirePath("eventTriggerConfig")] public EventTriggerConfiguration EventTriggerConfig { get; set; } /// Collection of private container registry credentials used by a Container apps job. + [WirePath("registries")] public IList Registries { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobExecutionBase.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobExecutionBase.Serialization.cs index 514d69ba80ebd..1df9d4785bc86 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobExecutionBase.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobExecutionBase.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -100,6 +102,107 @@ internal static ContainerAppJobExecutionBase DeserializeContainerAppJobExecution return new ContainerAppJobExecutionBase(name, id, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Id.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Id}'''"); + } + else + { + builder.AppendLine($"'{Id}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -108,6 +211,8 @@ BinaryData IPersistableModel.Write(ModelReaderWrit { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppJobExecutionBase)} does not support '{options.Format}' format."); } @@ -124,6 +229,8 @@ ContainerAppJobExecutionBase IPersistableModel.Cre using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppJobExecutionBase(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppJobExecutionBase)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobExecutionBase.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobExecutionBase.cs index a7a20aeb0c634..c61324904fe70 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobExecutionBase.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobExecutionBase.cs @@ -62,8 +62,10 @@ internal ContainerAppJobExecutionBase(string name, string id, IDictionary Job execution name. + [WirePath("name")] public string Name { get; } /// Job execution Id. + [WirePath("id")] public string Id { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobExecutionTemplate.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobExecutionTemplate.Serialization.cs index 67c2464251140..7a2cfc27e439c 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobExecutionTemplate.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobExecutionTemplate.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -128,6 +131,107 @@ internal static ContainerAppJobExecutionTemplate DeserializeContainerAppJobExecu return new ContainerAppJobExecutionTemplate(containers ?? new ChangeTrackingList(), initContainers ?? new ChangeTrackingList(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Containers), out propertyOverride); + if (Optional.IsCollectionDefined(Containers) || hasPropertyOverride) + { + if (Containers.Any() || hasPropertyOverride) + { + builder.Append(" containers: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Containers) + { + AppendChildObject(builder, item, options, 4, true, " containers: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(InitContainers), out propertyOverride); + if (Optional.IsCollectionDefined(InitContainers) || hasPropertyOverride) + { + if (InitContainers.Any() || hasPropertyOverride) + { + builder.Append(" initContainers: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in InitContainers) + { + AppendChildObject(builder, item, options, 4, true, " initContainers: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -136,6 +240,8 @@ BinaryData IPersistableModel.Write(ModelReader { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppJobExecutionTemplate)} does not support '{options.Format}' format."); } @@ -152,6 +258,8 @@ ContainerAppJobExecutionTemplate IPersistableModel container } /// List of container definitions for the Container Apps Job. + [WirePath("containers")] public IList Containers { get; } /// List of specialized containers that run before job containers. + [WirePath("initContainers")] public IList InitContainers { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobExecutions.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobExecutions.Serialization.cs index fbe6c0cff6712..f6bec2558ca93 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobExecutions.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobExecutions.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -107,6 +110,107 @@ internal static ContainerAppJobExecutions DeserializeContainerAppJobExecutions(J return new ContainerAppJobExecutions(value, nextLink, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (Optional.IsDefined(NextLink) || hasPropertyOverride) + { + builder.Append(" nextLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -115,6 +219,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterO { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppJobExecutions)} does not support '{options.Format}' format."); } @@ -131,6 +237,8 @@ ContainerAppJobExecutions IPersistableModel.Create(Bi using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppJobExecutions(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppJobExecutions)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobExecutions.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobExecutions.cs index bf5e55bd1cc73..0eb75b2721f08 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobExecutions.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobExecutions.cs @@ -74,8 +74,10 @@ internal ContainerAppJobExecutions() } /// Collection of resources. + [WirePath("value")] public IReadOnlyList Value { get; } /// Link to next page of resources. + [WirePath("nextLink")] public string NextLink { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobPatch.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobPatch.cs index ce4299f9d5cb0..44a83af450828 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobPatch.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobPatch.cs @@ -67,10 +67,13 @@ internal ContainerAppJobPatch(ManagedServiceIdentity identity, IDictionary Managed identities needed by a container app job to interact with other Azure services to not maintain any secrets or credentials in code. + [WirePath("identity")] public ManagedServiceIdentity Identity { get; set; } /// Resource tags. + [WirePath("tags")] public IDictionary Tags { get; } /// Gets or sets the properties. + [WirePath("properties")] public ContainerAppJobPatchProperties Properties { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobPatchProperties.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobPatchProperties.cs index cafede5beb6e3..bc2f989a6ae65 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobPatchProperties.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobPatchProperties.cs @@ -70,14 +70,19 @@ internal ContainerAppJobPatchProperties(string environmentId, ContainerAppJobCon } /// Resource ID of environment. + [WirePath("environmentId")] public string EnvironmentId { get; set; } /// Container Apps Job configuration properties. + [WirePath("configuration")] public ContainerAppJobConfiguration Configuration { get; set; } /// Container Apps job definition. + [WirePath("template")] public ContainerAppJobTemplate Template { get; set; } /// Outbound IP Addresses of a container apps job. + [WirePath("outboundIpAddresses")] public IList OutboundIPAddresses { get; } /// The endpoint of the eventstream of the container apps job. + [WirePath("eventStreamEndpoint")] public string EventStreamEndpoint { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobScale.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobScale.Serialization.cs index 07d811bce92ff..73722019d2cb8 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobScale.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobScale.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -148,6 +151,127 @@ internal static ContainerAppJobScale DeserializeContainerAppJobScale(JsonElement return new ContainerAppJobScale(pollingInterval, minExecutions, maxExecutions, rules ?? new ChangeTrackingList(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PollingIntervalInSeconds), out propertyOverride); + if (Optional.IsDefined(PollingIntervalInSeconds) || hasPropertyOverride) + { + builder.Append(" pollingInterval: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{PollingIntervalInSeconds.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MinExecutions), out propertyOverride); + if (Optional.IsDefined(MinExecutions) || hasPropertyOverride) + { + builder.Append(" minExecutions: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{MinExecutions.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MaxExecutions), out propertyOverride); + if (Optional.IsDefined(MaxExecutions) || hasPropertyOverride) + { + builder.Append(" maxExecutions: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{MaxExecutions.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Rules), out propertyOverride); + if (Optional.IsCollectionDefined(Rules) || hasPropertyOverride) + { + if (Rules.Any() || hasPropertyOverride) + { + builder.Append(" rules: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Rules) + { + AppendChildObject(builder, item, options, 4, true, " rules: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -156,6 +280,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOption { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppJobScale)} does not support '{options.Format}' format."); } @@ -172,6 +298,8 @@ ContainerAppJobScale IPersistableModel.Create(BinaryData d using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppJobScale(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppJobScale)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobScale.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobScale.cs index 17f881493a8a9..0a8444b3f76b6 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobScale.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobScale.cs @@ -68,12 +68,16 @@ internal ContainerAppJobScale(int? pollingIntervalInSeconds, int? minExecutions, } /// Interval to check each event source in seconds. Defaults to 30s. + [WirePath("pollingInterval")] public int? PollingIntervalInSeconds { get; set; } /// Minimum number of job executions that are created for a trigger, default 0. + [WirePath("minExecutions")] public int? MinExecutions { get; set; } /// Maximum number of job executions that are created for a trigger, default 100. + [WirePath("maxExecutions")] public int? MaxExecutions { get; set; } /// Scaling rules. + [WirePath("rules")] public IList Rules { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobScaleRule.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobScaleRule.Serialization.cs index b1616b8f5a6d8..e5d396d06e033 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobScaleRule.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobScaleRule.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -147,6 +150,121 @@ internal static ContainerAppJobScaleRule DeserializeContainerAppJobScaleRule(Jso return new ContainerAppJobScaleRule(name, type, metadata, auth ?? new ChangeTrackingList(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Metadata), out propertyOverride); + if (Optional.IsDefined(Metadata) || hasPropertyOverride) + { + builder.Append(" metadata: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Metadata.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Auth), out propertyOverride); + if (Optional.IsCollectionDefined(Auth) || hasPropertyOverride) + { + if (Auth.Any() || hasPropertyOverride) + { + builder.Append(" auth: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Auth) + { + AppendChildObject(builder, item, options, 4, true, " auth: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -155,6 +273,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOp { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppJobScaleRule)} does not support '{options.Format}' format."); } @@ -171,6 +291,8 @@ ContainerAppJobScaleRule IPersistableModel.Create(Bina using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppJobScaleRule(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppJobScaleRule)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobScaleRule.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobScaleRule.cs index 0adcd15375e97..fcdd6e8e7e0e8 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobScaleRule.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobScaleRule.cs @@ -71,11 +71,13 @@ internal ContainerAppJobScaleRule(string name, string jobScaleRuleType, BinaryDa } /// Scale Rule Name. + [WirePath("name")] public string Name { get; set; } /// /// Type of the scale rule /// eg: azure-servicebus, redis etc. /// + [WirePath("type")] public string JobScaleRuleType { get; set; } /// /// Metadata properties to describe the scale rule. @@ -107,8 +109,10 @@ internal ContainerAppJobScaleRule(string name, string jobScaleRuleType, BinaryDa /// /// /// + [WirePath("metadata")] public BinaryData Metadata { get; set; } /// Authentication secrets for the scale rule. + [WirePath("auth")] public IList Auth { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobTemplate.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobTemplate.Serialization.cs index c8427784a4462..33c857b17ff89 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobTemplate.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobTemplate.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -153,6 +156,129 @@ internal static ContainerAppJobTemplate DeserializeContainerAppJobTemplate(JsonE return new ContainerAppJobTemplate(initContainers ?? new ChangeTrackingList(), containers ?? new ChangeTrackingList(), volumes ?? new ChangeTrackingList(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(InitContainers), out propertyOverride); + if (Optional.IsCollectionDefined(InitContainers) || hasPropertyOverride) + { + if (InitContainers.Any() || hasPropertyOverride) + { + builder.Append(" initContainers: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in InitContainers) + { + AppendChildObject(builder, item, options, 4, true, " initContainers: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Containers), out propertyOverride); + if (Optional.IsCollectionDefined(Containers) || hasPropertyOverride) + { + if (Containers.Any() || hasPropertyOverride) + { + builder.Append(" containers: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Containers) + { + AppendChildObject(builder, item, options, 4, true, " containers: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Volumes), out propertyOverride); + if (Optional.IsCollectionDefined(Volumes) || hasPropertyOverride) + { + if (Volumes.Any() || hasPropertyOverride) + { + builder.Append(" volumes: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Volumes) + { + AppendChildObject(builder, item, options, 4, true, " volumes: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -161,6 +287,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpt { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppJobTemplate)} does not support '{options.Format}' format."); } @@ -177,6 +305,8 @@ ContainerAppJobTemplate IPersistableModel.Create(Binary using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppJobTemplate(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppJobTemplate)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobTemplate.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobTemplate.cs index 08f07a68fa7a5..c99277ca9816f 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobTemplate.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobTemplate.cs @@ -68,10 +68,13 @@ internal ContainerAppJobTemplate(IList initContainers } /// List of specialized containers that run before app containers. + [WirePath("initContainers")] public IList InitContainers { get; } /// List of container definitions for the Container App. + [WirePath("containers")] public IList Containers { get; } /// List of volume definitions for the Container App. + [WirePath("volumes")] public IList Volumes { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobsCollection.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobsCollection.Serialization.cs index 17d709cb8484e..8f094abcd3a91 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobsCollection.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobsCollection.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -107,6 +110,107 @@ internal static ContainerAppJobsCollection DeserializeContainerAppJobsCollection return new ContainerAppJobsCollection(value, nextLink, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (Optional.IsDefined(NextLink) || hasPropertyOverride) + { + builder.Append(" nextLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -115,6 +219,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriter { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppJobsCollection)} does not support '{options.Format}' format."); } @@ -131,6 +237,8 @@ ContainerAppJobsCollection IPersistableModel.Create( using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppJobsCollection(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppJobsCollection)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJwtClaimChecks.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJwtClaimChecks.Serialization.cs index f22fa85c55606..38c7bcad066a4 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJwtClaimChecks.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJwtClaimChecks.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -128,6 +131,133 @@ internal static ContainerAppJwtClaimChecks DeserializeContainerAppJwtClaimChecks return new ContainerAppJwtClaimChecks(allowedGroups ?? new ChangeTrackingList(), allowedClientApplications ?? new ChangeTrackingList(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AllowedGroups), out propertyOverride); + if (Optional.IsCollectionDefined(AllowedGroups) || hasPropertyOverride) + { + if (AllowedGroups.Any() || hasPropertyOverride) + { + builder.Append(" allowedGroups: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in AllowedGroups) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AllowedClientApplications), out propertyOverride); + if (Optional.IsCollectionDefined(AllowedClientApplications) || hasPropertyOverride) + { + if (AllowedClientApplications.Any() || hasPropertyOverride) + { + builder.Append(" allowedClientApplications: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in AllowedClientApplications) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -136,6 +266,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriter { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppJwtClaimChecks)} does not support '{options.Format}' format."); } @@ -152,6 +284,8 @@ ContainerAppJwtClaimChecks IPersistableModel.Create( using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppJwtClaimChecks(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppJwtClaimChecks)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJwtClaimChecks.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJwtClaimChecks.cs index fee953a30de82..af0b2bc283a84 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJwtClaimChecks.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJwtClaimChecks.cs @@ -65,8 +65,10 @@ internal ContainerAppJwtClaimChecks(IList allowedGroups, IList a } /// The list of the allowed groups. + [WirePath("allowedGroups")] public IList AllowedGroups { get; } /// The list of the allowed client applications. + [WirePath("allowedClientApplications")] public IList AllowedClientApplications { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppLogAnalyticsConfiguration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppLogAnalyticsConfiguration.Serialization.cs index 33f841698e7ab..03f9b9de49973 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppLogAnalyticsConfiguration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppLogAnalyticsConfiguration.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -100,6 +102,107 @@ internal static ContainerAppLogAnalyticsConfiguration DeserializeContainerAppLog return new ContainerAppLogAnalyticsConfiguration(customerId, sharedKey, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CustomerId), out propertyOverride); + if (Optional.IsDefined(CustomerId) || hasPropertyOverride) + { + builder.Append(" customerId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (CustomerId.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{CustomerId}'''"); + } + else + { + builder.AppendLine($"'{CustomerId}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SharedKey), out propertyOverride); + if (Optional.IsDefined(SharedKey) || hasPropertyOverride) + { + builder.Append(" sharedKey: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (SharedKey.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{SharedKey}'''"); + } + else + { + builder.AppendLine($"'{SharedKey}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -108,6 +211,8 @@ BinaryData IPersistableModel.Write(ModelR { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppLogAnalyticsConfiguration)} does not support '{options.Format}' format."); } @@ -124,6 +229,8 @@ ContainerAppLogAnalyticsConfiguration IPersistableModel Log analytics customer id. + [WirePath("customerId")] public string CustomerId { get; set; } /// Log analytics customer key. + [WirePath("sharedKey")] public string SharedKey { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppLogin.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppLogin.Serialization.cs index ac6c3f2af07ab..fa714ddebfdf5 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppLogin.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppLogin.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -169,6 +172,155 @@ internal static ContainerAppLogin DeserializeContainerAppLogin(JsonElement eleme serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Routes), out propertyOverride); + if (Optional.IsDefined(Routes) || hasPropertyOverride) + { + builder.Append(" routes: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Routes, options, 2, false, " routes: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PreserveUrlFragmentsForLogins), out propertyOverride); + if (Optional.IsDefined(PreserveUrlFragmentsForLogins) || hasPropertyOverride) + { + builder.Append(" preserveUrlFragmentsForLogins: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = PreserveUrlFragmentsForLogins.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AllowedExternalRedirectUrls), out propertyOverride); + if (Optional.IsCollectionDefined(AllowedExternalRedirectUrls) || hasPropertyOverride) + { + if (AllowedExternalRedirectUrls.Any() || hasPropertyOverride) + { + builder.Append(" allowedExternalRedirectUrls: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in AllowedExternalRedirectUrls) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CookieExpiration), out propertyOverride); + if (Optional.IsDefined(CookieExpiration) || hasPropertyOverride) + { + builder.Append(" cookieExpiration: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, CookieExpiration, options, 2, false, " cookieExpiration: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Nonce), out propertyOverride); + if (Optional.IsDefined(Nonce) || hasPropertyOverride) + { + builder.Append(" nonce: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Nonce, options, 2, false, " nonce: "); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -177,6 +329,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions o { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppLogin)} does not support '{options.Format}' format."); } @@ -193,6 +347,8 @@ ContainerAppLogin IPersistableModel.Create(BinaryData data, M using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppLogin(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppLogin)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppLogin.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppLogin.cs index 75a21422c5fec..13ea88f121df5 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppLogin.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppLogin.cs @@ -76,6 +76,7 @@ internal ContainerAppLogin(LoginRoutes routes, bool? preserveUrlFragmentsForLogi /// The routes that specify the endpoints used for login and logout requests. internal LoginRoutes Routes { get; set; } /// The endpoint at which a logout request should be made. + [WirePath("routes.logoutEndpoint")] public string RoutesLogoutEndpoint { get => Routes is null ? default : Routes.LogoutEndpoint; @@ -88,16 +89,20 @@ public string RoutesLogoutEndpoint } /// <code>true</code> if the fragments from the request are preserved after the login request is made; otherwise, <code>false</code>. + [WirePath("preserveUrlFragmentsForLogins")] public bool? PreserveUrlFragmentsForLogins { get; set; } /// /// External URLs that can be redirected to as part of logging in or logging out of the app. Note that the query string part of the URL is ignored. /// This is an advanced setting typically only needed by Windows Store application backends. /// Note that URLs within the current domain are always implicitly allowed. /// + [WirePath("allowedExternalRedirectUrls")] public IList AllowedExternalRedirectUrls { get; } /// The configuration settings of the session cookie's expiration. + [WirePath("cookieExpiration")] public ContainerAppCookieExpiration CookieExpiration { get; set; } /// The configuration settings of the nonce used in the login flow. + [WirePath("nonce")] public ContainerAppLoginNonce Nonce { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppLoginNonce.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppLoginNonce.Serialization.cs index 9584a59aa28e7..1b703d4f33031 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppLoginNonce.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppLoginNonce.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -104,6 +106,100 @@ internal static ContainerAppLoginNonce DeserializeContainerAppLoginNonce(JsonEle return new ContainerAppLoginNonce(validateNonce, nonceExpirationInterval, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ValidateNonce), out propertyOverride); + if (Optional.IsDefined(ValidateNonce) || hasPropertyOverride) + { + builder.Append(" validateNonce: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = ValidateNonce.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NonceExpirationInterval), out propertyOverride); + if (Optional.IsDefined(NonceExpirationInterval) || hasPropertyOverride) + { + builder.Append(" nonceExpirationInterval: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NonceExpirationInterval.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NonceExpirationInterval}'''"); + } + else + { + builder.AppendLine($"'{NonceExpirationInterval}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -112,6 +208,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpti { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppLoginNonce)} does not support '{options.Format}' format."); } @@ -128,6 +226,8 @@ ContainerAppLoginNonce IPersistableModel.Create(BinaryDa using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppLoginNonce(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppLoginNonce)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppLoginNonce.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppLoginNonce.cs index 53d3551799729..8d19c12d1c9a7 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppLoginNonce.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppLoginNonce.cs @@ -62,8 +62,10 @@ internal ContainerAppLoginNonce(bool? validateNonce, string nonceExpirationInter } /// <code>false</code> if the nonce should not be validated while completing the login flow; otherwise, <code>true</code>. + [WirePath("validateNonce")] public bool? ValidateNonce { get; set; } /// The time after the request is made when the nonce should expire. + [WirePath("nonceExpirationInterval")] public string NonceExpirationInterval { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppLogsConfiguration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppLogsConfiguration.Serialization.cs index 729a339ef6dfa..59b988d749f0a 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppLogsConfiguration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppLogsConfiguration.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -104,6 +106,99 @@ internal static ContainerAppLogsConfiguration DeserializeContainerAppLogsConfigu return new ContainerAppLogsConfiguration(destination, logAnalyticsConfiguration, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Destination), out propertyOverride); + if (Optional.IsDefined(Destination) || hasPropertyOverride) + { + builder.Append(" destination: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Destination.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Destination}'''"); + } + else + { + builder.AppendLine($"'{Destination}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LogAnalyticsConfiguration), out propertyOverride); + if (Optional.IsDefined(LogAnalyticsConfiguration) || hasPropertyOverride) + { + builder.Append(" logAnalyticsConfiguration: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, LogAnalyticsConfiguration, options, 2, false, " logAnalyticsConfiguration: "); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -112,6 +207,8 @@ BinaryData IPersistableModel.Write(ModelReaderWri { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppLogsConfiguration)} does not support '{options.Format}' format."); } @@ -128,6 +225,8 @@ ContainerAppLogsConfiguration IPersistableModel.C using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppLogsConfiguration(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppLogsConfiguration)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppLogsConfiguration.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppLogsConfiguration.cs index b49f9930f4ccb..9eea27a8e4440 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppLogsConfiguration.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppLogsConfiguration.cs @@ -62,8 +62,10 @@ internal ContainerAppLogsConfiguration(string destination, ContainerAppLogAnalyt } /// Logs destination, can be 'log-analytics', 'azure-monitor' or 'none'. + [WirePath("destination")] public string Destination { get; set; } /// Log Analytics configuration, must only be provided when destination is configured as 'log-analytics'. + [WirePath("logAnalyticsConfiguration")] public ContainerAppLogAnalyticsConfiguration LogAnalyticsConfiguration { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppManagedCertificatePatch.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppManagedCertificatePatch.cs index 43be13056dfb9..24cc5bb041467 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppManagedCertificatePatch.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppManagedCertificatePatch.cs @@ -62,6 +62,7 @@ internal ContainerAppManagedCertificatePatch(IDictionary tags, I } /// Application-specific metadata in the form of key-value pairs. + [WirePath("tags")] public IDictionary Tags { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppNameAvailabilityContent.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppNameAvailabilityContent.cs index b9501cfedd386..009d850956808 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppNameAvailabilityContent.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppNameAvailabilityContent.cs @@ -63,8 +63,10 @@ internal ContainerAppNameAvailabilityContent(string name, ResourceType? resource } /// The name of the resource for which availability needs to be checked. + [WirePath("name")] public string Name { get; set; } /// The resource type. + [WirePath("type")] public ResourceType? ResourceType { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppNameAvailabilityResult.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppNameAvailabilityResult.Serialization.cs index 9be20408217e5..078ab98788fd2 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppNameAvailabilityResult.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppNameAvailabilityResult.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -119,6 +121,114 @@ internal static ContainerAppNameAvailabilityResult DeserializeContainerAppNameAv return new ContainerAppNameAvailabilityResult(nameAvailable, reason, message, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsNameAvailable), out propertyOverride); + if (Optional.IsDefined(IsNameAvailable) || hasPropertyOverride) + { + builder.Append(" nameAvailable: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsNameAvailable.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Reason), out propertyOverride); + if (Optional.IsDefined(Reason) || hasPropertyOverride) + { + builder.Append(" reason: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Reason.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Message), out propertyOverride); + if (Optional.IsDefined(Message) || hasPropertyOverride) + { + builder.Append(" message: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Message.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Message}'''"); + } + else + { + builder.AppendLine($"'{Message}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -127,6 +237,8 @@ BinaryData IPersistableModel.Write(ModelRead { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppNameAvailabilityResult)} does not support '{options.Format}' format."); } @@ -143,6 +255,8 @@ ContainerAppNameAvailabilityResult IPersistableModel Indicates if the resource name is available. + [WirePath("nameAvailable")] public bool? IsNameAvailable { get; } /// The reason why the given name is not available. + [WirePath("reason")] public ContainerAppNameUnavailableReason? Reason { get; } /// Detailed reason why the given name is available. + [WirePath("message")] public string Message { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppOpenIdConnectClientCredential.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppOpenIdConnectClientCredential.Serialization.cs index 57a1fd999bccb..f403159800951 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppOpenIdConnectClientCredential.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppOpenIdConnectClientCredential.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -104,6 +106,99 @@ internal static ContainerAppOpenIdConnectClientCredential DeserializeContainerAp return new ContainerAppOpenIdConnectClientCredential(method, clientSecretSettingName, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Method), out propertyOverride); + if (Optional.IsDefined(Method) || hasPropertyOverride) + { + builder.Append(" method: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Method.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ClientSecretSettingName), out propertyOverride); + if (Optional.IsDefined(ClientSecretSettingName) || hasPropertyOverride) + { + builder.Append(" clientSecretSettingName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ClientSecretSettingName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ClientSecretSettingName}'''"); + } + else + { + builder.AppendLine($"'{ClientSecretSettingName}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -112,6 +207,8 @@ BinaryData IPersistableModel.Write(Mo { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppOpenIdConnectClientCredential)} does not support '{options.Format}' format."); } @@ -128,6 +225,8 @@ ContainerAppOpenIdConnectClientCredential IPersistableModel The method that should be used to authenticate the user. + [WirePath("method")] public ContainerAppOpenIdConnectClientCredentialMethod? Method { get; set; } /// The app setting that contains the client secret for the custom Open ID Connect provider. + [WirePath("clientSecretSettingName")] public string ClientSecretSettingName { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppOpenIdConnectConfig.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppOpenIdConnectConfig.Serialization.cs index 32174ffb89c2f..43ee4af272004 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppOpenIdConnectConfig.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppOpenIdConnectConfig.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -143,6 +145,165 @@ internal static ContainerAppOpenIdConnectConfig DeserializeContainerAppOpenIdCon serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AuthorizationEndpoint), out propertyOverride); + if (Optional.IsDefined(AuthorizationEndpoint) || hasPropertyOverride) + { + builder.Append(" authorizationEndpoint: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (AuthorizationEndpoint.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{AuthorizationEndpoint}'''"); + } + else + { + builder.AppendLine($"'{AuthorizationEndpoint}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TokenEndpoint), out propertyOverride); + if (Optional.IsDefined(TokenEndpoint) || hasPropertyOverride) + { + builder.Append(" tokenEndpoint: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (TokenEndpoint.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{TokenEndpoint}'''"); + } + else + { + builder.AppendLine($"'{TokenEndpoint}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Issuer), out propertyOverride); + if (Optional.IsDefined(Issuer) || hasPropertyOverride) + { + builder.Append(" issuer: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Issuer.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Issuer}'''"); + } + else + { + builder.AppendLine($"'{Issuer}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CertificationUri), out propertyOverride); + if (Optional.IsDefined(CertificationUri) || hasPropertyOverride) + { + builder.Append(" certificationUri: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{CertificationUri.AbsoluteUri}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(WellKnownOpenIdConfiguration), out propertyOverride); + if (Optional.IsDefined(WellKnownOpenIdConfiguration) || hasPropertyOverride) + { + builder.Append(" wellKnownOpenIdConfiguration: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (WellKnownOpenIdConfiguration.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{WellKnownOpenIdConfiguration}'''"); + } + else + { + builder.AppendLine($"'{WellKnownOpenIdConfiguration}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -151,6 +312,8 @@ BinaryData IPersistableModel.Write(ModelReaderW { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppOpenIdConnectConfig)} does not support '{options.Format}' format."); } @@ -167,6 +330,8 @@ ContainerAppOpenIdConnectConfig IPersistableModel The endpoint to be used to make an authorization request. + [WirePath("authorizationEndpoint")] public string AuthorizationEndpoint { get; set; } /// The endpoint to be used to request a token. + [WirePath("tokenEndpoint")] public string TokenEndpoint { get; set; } /// The endpoint that issues the token. + [WirePath("issuer")] public string Issuer { get; set; } /// The endpoint that provides the keys necessary to validate the token. + [WirePath("certificationUri")] public Uri CertificationUri { get; set; } /// The endpoint that contains all the configuration endpoints for the provider. + [WirePath("wellKnownOpenIdConfiguration")] public string WellKnownOpenIdConfiguration { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppOpenIdConnectLogin.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppOpenIdConnectLogin.Serialization.cs index 021aa95991ac6..4d0897cdcabbb 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppOpenIdConnectLogin.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppOpenIdConnectLogin.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -114,6 +117,120 @@ internal static ContainerAppOpenIdConnectLogin DeserializeContainerAppOpenIdConn return new ContainerAppOpenIdConnectLogin(nameClaimType, scopes ?? new ChangeTrackingList(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NameClaimType), out propertyOverride); + if (Optional.IsDefined(NameClaimType) || hasPropertyOverride) + { + builder.Append(" nameClaimType: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NameClaimType.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NameClaimType}'''"); + } + else + { + builder.AppendLine($"'{NameClaimType}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Scopes), out propertyOverride); + if (Optional.IsCollectionDefined(Scopes) || hasPropertyOverride) + { + if (Scopes.Any() || hasPropertyOverride) + { + builder.Append(" scopes: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Scopes) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -122,6 +239,8 @@ BinaryData IPersistableModel.Write(ModelReaderWr { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppOpenIdConnectLogin)} does not support '{options.Format}' format."); } @@ -138,6 +257,8 @@ ContainerAppOpenIdConnectLogin IPersistableModel using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppOpenIdConnectLogin(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppOpenIdConnectLogin)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppOpenIdConnectLogin.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppOpenIdConnectLogin.cs index e6c24a2dab5d3..8427c4e796b7f 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppOpenIdConnectLogin.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppOpenIdConnectLogin.cs @@ -64,8 +64,10 @@ internal ContainerAppOpenIdConnectLogin(string nameClaimType, IList scop } /// The name of the claim that contains the users name. + [WirePath("nameClaimType")] public string NameClaimType { get; set; } /// A list of the scopes that should be requested while authenticating. + [WirePath("scopes")] public IList Scopes { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppOpenIdConnectRegistration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppOpenIdConnectRegistration.Serialization.cs index 6ae022847faed..ec63d9bd30994 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppOpenIdConnectRegistration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppOpenIdConnectRegistration.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -119,6 +121,113 @@ internal static ContainerAppOpenIdConnectRegistration DeserializeContainerAppOpe return new ContainerAppOpenIdConnectRegistration(clientId, clientCredential, openIdConnectConfiguration, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ClientId), out propertyOverride); + if (Optional.IsDefined(ClientId) || hasPropertyOverride) + { + builder.Append(" clientId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ClientId.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ClientId}'''"); + } + else + { + builder.AppendLine($"'{ClientId}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ClientCredential), out propertyOverride); + if (Optional.IsDefined(ClientCredential) || hasPropertyOverride) + { + builder.Append(" clientCredential: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, ClientCredential, options, 2, false, " clientCredential: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(OpenIdConnectConfiguration), out propertyOverride); + if (Optional.IsDefined(OpenIdConnectConfiguration) || hasPropertyOverride) + { + builder.Append(" openIdConnectConfiguration: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, OpenIdConnectConfiguration, options, 2, false, " openIdConnectConfiguration: "); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -127,6 +236,8 @@ BinaryData IPersistableModel.Write(ModelR { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppOpenIdConnectRegistration)} does not support '{options.Format}' format."); } @@ -143,6 +254,8 @@ ContainerAppOpenIdConnectRegistration IPersistableModel The client id of the custom Open ID Connect provider. + [WirePath("clientId")] public string ClientId { get; set; } /// The authentication credentials of the custom Open ID Connect provider. + [WirePath("clientCredential")] public ContainerAppOpenIdConnectClientCredential ClientCredential { get; set; } /// The configuration settings of the endpoints used for the custom Open ID Connect provider. + [WirePath("openIdConnectConfiguration")] public ContainerAppOpenIdConnectConfig OpenIdConnectConfiguration { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppProbe.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppProbe.Serialization.cs index ac8fda5d97c09..22a60c45f6c03 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppProbe.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppProbe.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -223,6 +225,175 @@ internal static ContainerAppProbe DeserializeContainerAppProbe(JsonElement eleme serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FailureThreshold), out propertyOverride); + if (Optional.IsDefined(FailureThreshold) || hasPropertyOverride) + { + builder.Append(" failureThreshold: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{FailureThreshold.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HttpGet), out propertyOverride); + if (Optional.IsDefined(HttpGet) || hasPropertyOverride) + { + builder.Append(" httpGet: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, HttpGet, options, 2, false, " httpGet: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(InitialDelaySeconds), out propertyOverride); + if (Optional.IsDefined(InitialDelaySeconds) || hasPropertyOverride) + { + builder.Append(" initialDelaySeconds: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{InitialDelaySeconds.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PeriodSeconds), out propertyOverride); + if (Optional.IsDefined(PeriodSeconds) || hasPropertyOverride) + { + builder.Append(" periodSeconds: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{PeriodSeconds.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SuccessThreshold), out propertyOverride); + if (Optional.IsDefined(SuccessThreshold) || hasPropertyOverride) + { + builder.Append(" successThreshold: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{SuccessThreshold.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TcpSocket), out propertyOverride); + if (Optional.IsDefined(TcpSocket) || hasPropertyOverride) + { + builder.Append(" tcpSocket: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, TcpSocket, options, 2, false, " tcpSocket: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TerminationGracePeriodSeconds), out propertyOverride); + if (Optional.IsDefined(TerminationGracePeriodSeconds) || hasPropertyOverride) + { + builder.Append(" terminationGracePeriodSeconds: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{TerminationGracePeriodSeconds.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TimeoutSeconds), out propertyOverride); + if (Optional.IsDefined(TimeoutSeconds) || hasPropertyOverride) + { + builder.Append(" timeoutSeconds: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{TimeoutSeconds.Value}"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -231,6 +402,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions o { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppProbe)} does not support '{options.Format}' format."); } @@ -247,6 +420,8 @@ ContainerAppProbe IPersistableModel.Create(BinaryData data, M using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppProbe(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppProbe)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppProbe.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppProbe.cs index 7859c17c70e81..3d21ad3c2996f 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppProbe.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppProbe.cs @@ -76,22 +76,31 @@ internal ContainerAppProbe(int? failureThreshold, ContainerAppHttpRequestInfo ht } /// Minimum consecutive failures for the probe to be considered failed after having succeeded. Defaults to 3. Minimum value is 1. Maximum value is 10. + [WirePath("failureThreshold")] public int? FailureThreshold { get; set; } /// HTTPGet specifies the http request to perform. + [WirePath("httpGet")] public ContainerAppHttpRequestInfo HttpGet { get; set; } /// Number of seconds after the container has started before liveness probes are initiated. Minimum value is 1. Maximum value is 60. + [WirePath("initialDelaySeconds")] public int? InitialDelaySeconds { get; set; } /// How often (in seconds) to perform the probe. Default to 10 seconds. Minimum value is 1. Maximum value is 240. + [WirePath("periodSeconds")] public int? PeriodSeconds { get; set; } /// Minimum consecutive successes for the probe to be considered successful after having failed. Defaults to 1. Must be 1 for liveness and startup. Minimum value is 1. Maximum value is 10. + [WirePath("successThreshold")] public int? SuccessThreshold { get; set; } /// TCPSocket specifies an action involving a TCP port. TCP hooks not yet supported. + [WirePath("tcpSocket")] public ContainerAppTcpSocketRequestInfo TcpSocket { get; set; } /// Optional duration in seconds the pod needs to terminate gracefully upon probe failure. The grace period is the duration in seconds after the processes running in the pod are sent a termination signal and the time when the processes are forcibly halted with a kill signal. Set this value longer than the expected cleanup time for your process. If this value is nil, the pod's terminationGracePeriodSeconds will be used. Otherwise, this value overrides the value provided by the pod spec. Value must be non-negative integer. The value zero indicates stop immediately via the kill signal (no opportunity to shut down). This is an alpha field and requires enabling ProbeTerminationGracePeriod feature gate. Maximum value is 3600 seconds (1 hour). + [WirePath("terminationGracePeriodSeconds")] public long? TerminationGracePeriodSeconds { get; set; } /// Number of seconds after which the probe times out. Defaults to 1 second. Minimum value is 1. Maximum value is 240. + [WirePath("timeoutSeconds")] public int? TimeoutSeconds { get; set; } /// The type of probe. + [WirePath("type")] public ContainerAppProbeType? ProbeType { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppQueueScaleRule.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppQueueScaleRule.Serialization.cs index 64ef77b1ac80c..8b81bb8532e7e 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppQueueScaleRule.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppQueueScaleRule.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -129,6 +132,121 @@ internal static ContainerAppQueueScaleRule DeserializeContainerAppQueueScaleRule return new ContainerAppQueueScaleRule(queueName, queueLength, auth ?? new ChangeTrackingList(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(QueueName), out propertyOverride); + if (Optional.IsDefined(QueueName) || hasPropertyOverride) + { + builder.Append(" queueName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (QueueName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{QueueName}'''"); + } + else + { + builder.AppendLine($"'{QueueName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(QueueLength), out propertyOverride); + if (Optional.IsDefined(QueueLength) || hasPropertyOverride) + { + builder.Append(" queueLength: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{QueueLength.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Auth), out propertyOverride); + if (Optional.IsCollectionDefined(Auth) || hasPropertyOverride) + { + if (Auth.Any() || hasPropertyOverride) + { + builder.Append(" auth: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Auth) + { + AppendChildObject(builder, item, options, 4, true, " auth: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -137,6 +255,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriter { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppQueueScaleRule)} does not support '{options.Format}' format."); } @@ -153,6 +273,8 @@ ContainerAppQueueScaleRule IPersistableModel.Create( using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppQueueScaleRule(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppQueueScaleRule)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppQueueScaleRule.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppQueueScaleRule.cs index 4ebca132abd0e..beacb32c14079 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppQueueScaleRule.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppQueueScaleRule.cs @@ -66,10 +66,13 @@ internal ContainerAppQueueScaleRule(string queueName, int? queueLength, IList Queue name. + [WirePath("queueName")] public string QueueName { get; set; } /// Queue length. + [WirePath("queueLength")] public int? QueueLength { get; set; } /// Authentication secrets for the queue scale rule. + [WirePath("auth")] public IList Auth { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppRegistration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppRegistration.Serialization.cs index 13ac5c5aa93e1..eb967c043c98a 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppRegistration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppRegistration.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -100,6 +102,107 @@ internal static ContainerAppRegistration DeserializeContainerAppRegistration(Jso return new ContainerAppRegistration(appId, appSecretSettingName, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AppId), out propertyOverride); + if (Optional.IsDefined(AppId) || hasPropertyOverride) + { + builder.Append(" appId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (AppId.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{AppId}'''"); + } + else + { + builder.AppendLine($"'{AppId}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AppSecretSettingName), out propertyOverride); + if (Optional.IsDefined(AppSecretSettingName) || hasPropertyOverride) + { + builder.Append(" appSecretSettingName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (AppSecretSettingName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{AppSecretSettingName}'''"); + } + else + { + builder.AppendLine($"'{AppSecretSettingName}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -108,6 +211,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOp { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppRegistration)} does not support '{options.Format}' format."); } @@ -124,6 +229,8 @@ ContainerAppRegistration IPersistableModel.Create(Bina using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppRegistration(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppRegistration)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppRegistration.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppRegistration.cs index 24e26f526722e..4554eb75430ac 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppRegistration.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppRegistration.cs @@ -62,8 +62,10 @@ internal ContainerAppRegistration(string appId, string appSecretSettingName, IDi } /// The App ID of the app used for login. + [WirePath("appId")] public string AppId { get; set; } /// The app setting name that contains the app secret. + [WirePath("appSecretSettingName")] public string AppSecretSettingName { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppRegistryCredentials.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppRegistryCredentials.Serialization.cs index 1e6a0af9ad28f..843d0d6230e00 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppRegistryCredentials.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppRegistryCredentials.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -122,6 +124,151 @@ internal static ContainerAppRegistryCredentials DeserializeContainerAppRegistryC return new ContainerAppRegistryCredentials(server, username, passwordSecretRef, identity, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Server), out propertyOverride); + if (Optional.IsDefined(Server) || hasPropertyOverride) + { + builder.Append(" server: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Server.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Server}'''"); + } + else + { + builder.AppendLine($"'{Server}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Username), out propertyOverride); + if (Optional.IsDefined(Username) || hasPropertyOverride) + { + builder.Append(" username: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Username.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Username}'''"); + } + else + { + builder.AppendLine($"'{Username}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PasswordSecretRef), out propertyOverride); + if (Optional.IsDefined(PasswordSecretRef) || hasPropertyOverride) + { + builder.Append(" passwordSecretRef: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (PasswordSecretRef.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{PasswordSecretRef}'''"); + } + else + { + builder.AppendLine($"'{PasswordSecretRef}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Identity), out propertyOverride); + if (Optional.IsDefined(Identity) || hasPropertyOverride) + { + builder.Append(" identity: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Identity.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Identity}'''"); + } + else + { + builder.AppendLine($"'{Identity}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -130,6 +277,8 @@ BinaryData IPersistableModel.Write(ModelReaderW { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppRegistryCredentials)} does not support '{options.Format}' format."); } @@ -146,6 +295,8 @@ ContainerAppRegistryCredentials IPersistableModel Container Registry Server. + [WirePath("server")] public string Server { get; set; } /// Container Registry Username. + [WirePath("username")] public string Username { get; set; } /// The name of the Secret that contains the registry login password. + [WirePath("passwordSecretRef")] public string PasswordSecretRef { get; set; } /// A Managed Identity to use to authenticate with Azure Container Registry. For user-assigned identities, use the full user-assigned identity Resource ID. For system-assigned identities, use 'system'. + [WirePath("identity")] public string Identity { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppRegistryInfo.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppRegistryInfo.Serialization.cs index 306602d9eddc6..48d34bdf63d40 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppRegistryInfo.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppRegistryInfo.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -111,6 +113,129 @@ internal static ContainerAppRegistryInfo DeserializeContainerAppRegistryInfo(Jso return new ContainerAppRegistryInfo(registryUrl, registryUserName, registryPassword, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RegistryServer), out propertyOverride); + if (Optional.IsDefined(RegistryServer) || hasPropertyOverride) + { + builder.Append(" registryUrl: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (RegistryServer.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{RegistryServer}'''"); + } + else + { + builder.AppendLine($"'{RegistryServer}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RegistryUserName), out propertyOverride); + if (Optional.IsDefined(RegistryUserName) || hasPropertyOverride) + { + builder.Append(" registryUserName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (RegistryUserName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{RegistryUserName}'''"); + } + else + { + builder.AppendLine($"'{RegistryUserName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RegistryPassword), out propertyOverride); + if (Optional.IsDefined(RegistryPassword) || hasPropertyOverride) + { + builder.Append(" registryPassword: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (RegistryPassword.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{RegistryPassword}'''"); + } + else + { + builder.AppendLine($"'{RegistryPassword}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -119,6 +244,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOp { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppRegistryInfo)} does not support '{options.Format}' format."); } @@ -135,6 +262,8 @@ ContainerAppRegistryInfo IPersistableModel.Create(Bina using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppRegistryInfo(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppRegistryInfo)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppRegistryInfo.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppRegistryInfo.cs index cf8846ace63a3..5d40582ab38b4 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppRegistryInfo.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppRegistryInfo.cs @@ -64,10 +64,13 @@ internal ContainerAppRegistryInfo(string registryServer, string registryUserName } /// registry server Url. + [WirePath("registryUrl")] public string RegistryServer { get; set; } /// registry username. + [WirePath("registryUserName")] public string RegistryUserName { get; set; } /// registry secret. + [WirePath("registryPassword")] public string RegistryPassword { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppReplicaContainer.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppReplicaContainer.Serialization.cs index 2703be8e5151a..df28661317c41 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppReplicaContainer.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppReplicaContainer.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -203,6 +205,231 @@ internal static ContainerAppReplicaContainer DeserializeContainerAppReplicaConta serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ContainerId), out propertyOverride); + if (Optional.IsDefined(ContainerId) || hasPropertyOverride) + { + builder.Append(" containerId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ContainerId.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ContainerId}'''"); + } + else + { + builder.AppendLine($"'{ContainerId}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsReady), out propertyOverride); + if (Optional.IsDefined(IsReady) || hasPropertyOverride) + { + builder.Append(" ready: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsReady.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsStarted), out propertyOverride); + if (Optional.IsDefined(IsStarted) || hasPropertyOverride) + { + builder.Append(" started: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsStarted.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RestartCount), out propertyOverride); + if (Optional.IsDefined(RestartCount) || hasPropertyOverride) + { + builder.Append(" restartCount: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{RestartCount.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RunningState), out propertyOverride); + if (Optional.IsDefined(RunningState) || hasPropertyOverride) + { + builder.Append(" runningState: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{RunningState.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RunningStateDetails), out propertyOverride); + if (Optional.IsDefined(RunningStateDetails) || hasPropertyOverride) + { + builder.Append(" runningStateDetails: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (RunningStateDetails.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{RunningStateDetails}'''"); + } + else + { + builder.AppendLine($"'{RunningStateDetails}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LogStreamEndpoint), out propertyOverride); + if (Optional.IsDefined(LogStreamEndpoint) || hasPropertyOverride) + { + builder.Append(" logStreamEndpoint: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (LogStreamEndpoint.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{LogStreamEndpoint}'''"); + } + else + { + builder.AppendLine($"'{LogStreamEndpoint}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExecEndpoint), out propertyOverride); + if (Optional.IsDefined(ExecEndpoint) || hasPropertyOverride) + { + builder.Append(" execEndpoint: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ExecEndpoint.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ExecEndpoint}'''"); + } + else + { + builder.AppendLine($"'{ExecEndpoint}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -211,6 +438,8 @@ BinaryData IPersistableModel.Write(ModelReaderWrit { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppReplicaContainer)} does not support '{options.Format}' format."); } @@ -227,6 +456,8 @@ ContainerAppReplicaContainer IPersistableModel.Cre using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppReplicaContainer(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppReplicaContainer)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppReplicaContainer.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppReplicaContainer.cs index f0c3fb8b7127e..2aa59e0405bc5 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppReplicaContainer.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppReplicaContainer.cs @@ -76,22 +76,31 @@ internal ContainerAppReplicaContainer(string name, string containerId, bool? isR } /// The Name of the Container. + [WirePath("name")] public string Name { get; set; } /// The Id of the Container. + [WirePath("containerId")] public string ContainerId { get; set; } /// The container ready status. + [WirePath("ready")] public bool? IsReady { get; set; } /// The container start status. + [WirePath("started")] public bool? IsStarted { get; set; } /// The container restart count. + [WirePath("restartCount")] public int? RestartCount { get; set; } /// Current running state of the container. + [WirePath("runningState")] public ContainerAppContainerRunningState? RunningState { get; } /// The details of container current running state. + [WirePath("runningStateDetails")] public string RunningStateDetails { get; } /// Log Stream endpoint. + [WirePath("logStreamEndpoint")] public string LogStreamEndpoint { get; } /// Container exec endpoint. + [WirePath("execEndpoint")] public string ExecEndpoint { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppRevisionTrafficWeight.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppRevisionTrafficWeight.Serialization.cs index ea0dd5f6c46a9..9eff5ddca6170 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppRevisionTrafficWeight.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppRevisionTrafficWeight.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -130,6 +132,136 @@ internal static ContainerAppRevisionTrafficWeight DeserializeContainerAppRevisio return new ContainerAppRevisionTrafficWeight(revisionName, weight, latestRevision, label, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RevisionName), out propertyOverride); + if (Optional.IsDefined(RevisionName) || hasPropertyOverride) + { + builder.Append(" revisionName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (RevisionName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{RevisionName}'''"); + } + else + { + builder.AppendLine($"'{RevisionName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Weight), out propertyOverride); + if (Optional.IsDefined(Weight) || hasPropertyOverride) + { + builder.Append(" weight: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{Weight.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsLatestRevision), out propertyOverride); + if (Optional.IsDefined(IsLatestRevision) || hasPropertyOverride) + { + builder.Append(" latestRevision: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsLatestRevision.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Label), out propertyOverride); + if (Optional.IsDefined(Label) || hasPropertyOverride) + { + builder.Append(" label: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Label.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Label}'''"); + } + else + { + builder.AppendLine($"'{Label}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -138,6 +270,8 @@ BinaryData IPersistableModel.Write(ModelReade { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppRevisionTrafficWeight)} does not support '{options.Format}' format."); } @@ -154,6 +288,8 @@ ContainerAppRevisionTrafficWeight IPersistableModel Name of a revision. + [WirePath("revisionName")] public string RevisionName { get; set; } /// Traffic weight assigned to a revision. + [WirePath("weight")] public int? Weight { get; set; } /// Indicates that the traffic weight belongs to a latest stable revision. + [WirePath("latestRevision")] public bool? IsLatestRevision { get; set; } /// Associates a traffic label with a revision. + [WirePath("label")] public string Label { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppScale.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppScale.Serialization.cs index 6bf531f45cbc8..c1ef0eb600791 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppScale.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppScale.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -133,6 +136,113 @@ internal static ContainerAppScale DeserializeContainerAppScale(JsonElement eleme return new ContainerAppScale(minReplicas, maxReplicas, rules ?? new ChangeTrackingList(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MinReplicas), out propertyOverride); + if (Optional.IsDefined(MinReplicas) || hasPropertyOverride) + { + builder.Append(" minReplicas: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{MinReplicas.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MaxReplicas), out propertyOverride); + if (Optional.IsDefined(MaxReplicas) || hasPropertyOverride) + { + builder.Append(" maxReplicas: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{MaxReplicas.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Rules), out propertyOverride); + if (Optional.IsCollectionDefined(Rules) || hasPropertyOverride) + { + if (Rules.Any() || hasPropertyOverride) + { + builder.Append(" rules: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Rules) + { + AppendChildObject(builder, item, options, 4, true, " rules: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -141,6 +251,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions o { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppScale)} does not support '{options.Format}' format."); } @@ -157,6 +269,8 @@ ContainerAppScale IPersistableModel.Create(BinaryData data, M using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppScale(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppScale)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppScale.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppScale.cs index 0bba5e493da00..02827666322e6 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppScale.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppScale.cs @@ -66,10 +66,13 @@ internal ContainerAppScale(int? minReplicas, int? maxReplicas, IList Optional. Minimum number of container replicas. + [WirePath("minReplicas")] public int? MinReplicas { get; set; } /// Optional. Maximum number of container replicas. Defaults to 10 if not set. + [WirePath("maxReplicas")] public int? MaxReplicas { get; set; } /// Scaling rules. + [WirePath("rules")] public IList Rules { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppScaleRule.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppScaleRule.Serialization.cs index da72a9a30818c..6c5e61916e42e 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppScaleRule.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppScaleRule.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -155,6 +157,141 @@ internal static ContainerAppScaleRule DeserializeContainerAppScaleRule(JsonEleme serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AzureQueue), out propertyOverride); + if (Optional.IsDefined(AzureQueue) || hasPropertyOverride) + { + builder.Append(" azureQueue: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, AzureQueue, options, 2, false, " azureQueue: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Custom), out propertyOverride); + if (Optional.IsDefined(Custom) || hasPropertyOverride) + { + builder.Append(" custom: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Custom, options, 2, false, " custom: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Http), out propertyOverride); + if (Optional.IsDefined(Http) || hasPropertyOverride) + { + builder.Append(" http: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Http, options, 2, false, " http: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tcp), out propertyOverride); + if (Optional.IsDefined(Tcp) || hasPropertyOverride) + { + builder.Append(" tcp: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Tcp, options, 2, false, " tcp: "); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -163,6 +300,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptio { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppScaleRule)} does not support '{options.Format}' format."); } @@ -179,6 +318,8 @@ ContainerAppScaleRule IPersistableModel.Create(BinaryData using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppScaleRule(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppScaleRule)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppScaleRule.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppScaleRule.cs index cb29eafa992cc..255f42044edf3 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppScaleRule.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppScaleRule.cs @@ -68,14 +68,19 @@ internal ContainerAppScaleRule(string name, ContainerAppQueueScaleRule azureQueu } /// Scale Rule Name. + [WirePath("name")] public string Name { get; set; } /// Azure Queue based scaling. + [WirePath("azureQueue")] public ContainerAppQueueScaleRule AzureQueue { get; set; } /// Custom scale rule. + [WirePath("custom")] public ContainerAppCustomScaleRule Custom { get; set; } /// HTTP requests based scaling. + [WirePath("http")] public ContainerAppHttpScaleRule Http { get; set; } /// Tcp requests based scaling. + [WirePath("tcp")] public ContainerAppTcpScaleRule Tcp { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppScaleRuleAuth.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppScaleRuleAuth.Serialization.cs index e78b0917d4025..d7b777cdb6db8 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppScaleRuleAuth.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppScaleRuleAuth.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -100,6 +102,107 @@ internal static ContainerAppScaleRuleAuth DeserializeContainerAppScaleRuleAuth(J return new ContainerAppScaleRuleAuth(secretRef, triggerParameter, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SecretRef), out propertyOverride); + if (Optional.IsDefined(SecretRef) || hasPropertyOverride) + { + builder.Append(" secretRef: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (SecretRef.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{SecretRef}'''"); + } + else + { + builder.AppendLine($"'{SecretRef}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TriggerParameter), out propertyOverride); + if (Optional.IsDefined(TriggerParameter) || hasPropertyOverride) + { + builder.Append(" triggerParameter: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (TriggerParameter.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{TriggerParameter}'''"); + } + else + { + builder.AppendLine($"'{TriggerParameter}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -108,6 +211,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterO { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppScaleRuleAuth)} does not support '{options.Format}' format."); } @@ -124,6 +229,8 @@ ContainerAppScaleRuleAuth IPersistableModel.Create(Bi using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppScaleRuleAuth(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppScaleRuleAuth)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppScaleRuleAuth.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppScaleRuleAuth.cs index b13dc2123b420..402b806bc4881 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppScaleRuleAuth.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppScaleRuleAuth.cs @@ -62,8 +62,10 @@ internal ContainerAppScaleRuleAuth(string secretRef, string triggerParameter, ID } /// Name of the secret from which to pull the auth params. + [WirePath("secretRef")] public string SecretRef { get; set; } /// Trigger Parameter that uses the secret. + [WirePath("triggerParameter")] public string TriggerParameter { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppSecret.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppSecret.Serialization.cs index e23eb9d8f92ae..0b1e2ae1190e6 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppSecret.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppSecret.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -126,6 +128,143 @@ internal static ContainerAppSecret DeserializeContainerAppSecret(JsonElement ele return new ContainerAppSecret(name, value, identity, keyVaultUrl, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsDefined(Value) || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Value}'''"); + } + else + { + builder.AppendLine($"'{Value}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Identity), out propertyOverride); + if (Optional.IsDefined(Identity) || hasPropertyOverride) + { + builder.Append(" identity: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Identity.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Identity}'''"); + } + else + { + builder.AppendLine($"'{Identity}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyVaultUri), out propertyOverride); + if (Optional.IsDefined(KeyVaultUri) || hasPropertyOverride) + { + builder.Append(" keyVaultUrl: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{KeyVaultUri.AbsoluteUri}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -134,6 +273,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppSecret)} does not support '{options.Format}' format."); } @@ -150,6 +291,8 @@ ContainerAppSecret IPersistableModel.Create(BinaryData data, using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppSecret(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppSecret)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppSecret.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppSecret.cs index 8f717e470bf8e..3473d211cf205 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppSecret.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppSecret.cs @@ -66,12 +66,16 @@ internal ContainerAppSecret(string name, string value, string identity, Uri keyV } /// Secret Name. + [WirePath("name")] public string Name { get; } /// Secret Value. + [WirePath("value")] public string Value { get; } /// Resource ID of a managed identity to authenticate with Azure Key Vault, or System to use a system-assigned identity. + [WirePath("identity")] public string Identity { get; } /// Azure Key Vault URL pointing to the secret referenced by the container app. + [WirePath("keyVaultUrl")] public Uri KeyVaultUri { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppServiceBind.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppServiceBind.Serialization.cs index 0b1c739060eac..34b14d65ecaec 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppServiceBind.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppServiceBind.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -104,6 +106,99 @@ internal static ContainerAppServiceBind DeserializeContainerAppServiceBind(JsonE return new ContainerAppServiceBind(serviceId, name, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ServiceId), out propertyOverride); + if (Optional.IsDefined(ServiceId) || hasPropertyOverride) + { + builder.Append(" serviceId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ServiceId.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -112,6 +207,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpt { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppServiceBind)} does not support '{options.Format}' format."); } @@ -128,6 +225,8 @@ ContainerAppServiceBind IPersistableModel.Create(Binary using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppServiceBind(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppServiceBind)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppServiceBind.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppServiceBind.cs index c47203c9fd921..330156fee9ec0 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppServiceBind.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppServiceBind.cs @@ -63,8 +63,10 @@ internal ContainerAppServiceBind(ResourceIdentifier serviceId, string name, IDic } /// Resource id of the target service. + [WirePath("serviceId")] public ResourceIdentifier ServiceId { get; set; } /// Name of the service bind. + [WirePath("name")] public string Name { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTcpScaleRule.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTcpScaleRule.Serialization.cs index c1243bdf6893e..6aab73a919a1f 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTcpScaleRule.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTcpScaleRule.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -129,6 +132,121 @@ internal static ContainerAppTcpScaleRule DeserializeContainerAppTcpScaleRule(Jso return new ContainerAppTcpScaleRule(metadata ?? new ChangeTrackingDictionary(), auth ?? new ChangeTrackingList(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Metadata), out propertyOverride); + if (Optional.IsCollectionDefined(Metadata) || hasPropertyOverride) + { + if (Metadata.Any() || hasPropertyOverride) + { + builder.Append(" metadata: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("{"); + foreach (var item in Metadata) + { + builder.Append($" '{item.Key}': "); + if (item.Value == null) + { + builder.Append("null"); + continue; + } + if (item.Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{item.Value}'''"); + } + else + { + builder.AppendLine($"'{item.Value}'"); + } + } + builder.AppendLine(" }"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Auth), out propertyOverride); + if (Optional.IsCollectionDefined(Auth) || hasPropertyOverride) + { + if (Auth.Any() || hasPropertyOverride) + { + builder.Append(" auth: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Auth) + { + AppendChildObject(builder, item, options, 4, true, " auth: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -137,6 +255,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOp { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppTcpScaleRule)} does not support '{options.Format}' format."); } @@ -153,6 +273,8 @@ ContainerAppTcpScaleRule IPersistableModel.Create(Bina using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppTcpScaleRule(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppTcpScaleRule)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTcpScaleRule.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTcpScaleRule.cs index ed4f063a5c6e4..82ab2e037e5c3 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTcpScaleRule.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTcpScaleRule.cs @@ -66,8 +66,10 @@ internal ContainerAppTcpScaleRule(IDictionary metadata, IList Metadata properties to describe tcp scale rule. + [WirePath("metadata")] public IDictionary Metadata { get; } /// Authentication secrets for the tcp scale rule. + [WirePath("auth")] public IList Auth { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTcpSocketRequestInfo.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTcpSocketRequestInfo.Serialization.cs index b1c834354d8bc..c77fb52343740 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTcpSocketRequestInfo.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTcpSocketRequestInfo.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -97,6 +99,96 @@ internal static ContainerAppTcpSocketRequestInfo DeserializeContainerAppTcpSocke return new ContainerAppTcpSocketRequestInfo(host, port, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Host), out propertyOverride); + if (Optional.IsDefined(Host) || hasPropertyOverride) + { + builder.Append(" host: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Host.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Host}'''"); + } + else + { + builder.AppendLine($"'{Host}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Port), out propertyOverride); + builder.Append(" port: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{Port}"); + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -105,6 +197,8 @@ BinaryData IPersistableModel.Write(ModelReader { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppTcpSocketRequestInfo)} does not support '{options.Format}' format."); } @@ -121,6 +215,8 @@ ContainerAppTcpSocketRequestInfo IPersistableModel Optional: Host name to connect to, defaults to the pod IP. + [WirePath("host")] public string Host { get; set; } /// Number or name of the port to access on the container. Number must be in the range 1 to 65535. Name must be an IANA_SVC_NAME. + [WirePath("port")] public int Port { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTemplate.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTemplate.Serialization.cs index ec756657bd06d..98b10ea10fba8 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTemplate.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTemplate.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -227,6 +230,201 @@ internal static ContainerAppTemplate DeserializeContainerAppTemplate(JsonElement serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RevisionSuffix), out propertyOverride); + if (Optional.IsDefined(RevisionSuffix) || hasPropertyOverride) + { + builder.Append(" revisionSuffix: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (RevisionSuffix.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{RevisionSuffix}'''"); + } + else + { + builder.AppendLine($"'{RevisionSuffix}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TerminationGracePeriodSeconds), out propertyOverride); + if (Optional.IsDefined(TerminationGracePeriodSeconds) || hasPropertyOverride) + { + builder.Append(" terminationGracePeriodSeconds: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{TerminationGracePeriodSeconds.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(InitContainers), out propertyOverride); + if (Optional.IsCollectionDefined(InitContainers) || hasPropertyOverride) + { + if (InitContainers.Any() || hasPropertyOverride) + { + builder.Append(" initContainers: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in InitContainers) + { + AppendChildObject(builder, item, options, 4, true, " initContainers: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Containers), out propertyOverride); + if (Optional.IsCollectionDefined(Containers) || hasPropertyOverride) + { + if (Containers.Any() || hasPropertyOverride) + { + builder.Append(" containers: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Containers) + { + AppendChildObject(builder, item, options, 4, true, " containers: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Scale), out propertyOverride); + if (Optional.IsDefined(Scale) || hasPropertyOverride) + { + builder.Append(" scale: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Scale, options, 2, false, " scale: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Volumes), out propertyOverride); + if (Optional.IsCollectionDefined(Volumes) || hasPropertyOverride) + { + if (Volumes.Any() || hasPropertyOverride) + { + builder.Append(" volumes: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Volumes) + { + AppendChildObject(builder, item, options, 4, true, " volumes: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ServiceBinds), out propertyOverride); + if (Optional.IsCollectionDefined(ServiceBinds) || hasPropertyOverride) + { + if (ServiceBinds.Any() || hasPropertyOverride) + { + builder.Append(" serviceBinds: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in ServiceBinds) + { + AppendChildObject(builder, item, options, 4, true, " serviceBinds: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -235,6 +433,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOption { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppTemplate)} does not support '{options.Format}' format."); } @@ -251,6 +451,8 @@ ContainerAppTemplate IPersistableModel.Create(BinaryData d using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppTemplate(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppTemplate)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTemplate.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTemplate.cs index 250f777fc17d4..5b1348803082f 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTemplate.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTemplate.cs @@ -81,18 +81,25 @@ internal ContainerAppTemplate(string revisionSuffix, long? terminationGracePerio } /// User friendly suffix that is appended to the revision name. + [WirePath("revisionSuffix")] public string RevisionSuffix { get; set; } /// Optional duration in seconds the Container App Instance needs to terminate gracefully. Value must be non-negative integer. The value zero indicates stop immediately via the kill signal (no opportunity to shut down). If this value is nil, the default grace period will be used instead. Set this value longer than the expected cleanup time for your process. Defaults to 30 seconds. + [WirePath("terminationGracePeriodSeconds")] public long? TerminationGracePeriodSeconds { get; set; } /// List of specialized containers that run before app containers. + [WirePath("initContainers")] public IList InitContainers { get; } /// List of container definitions for the Container App. + [WirePath("containers")] public IList Containers { get; } /// Scaling properties for the Container App. + [WirePath("scale")] public ContainerAppScale Scale { get; set; } /// List of volume definitions for the Container App. + [WirePath("volumes")] public IList Volumes { get; } /// List of container app services bound to the app. + [WirePath("serviceBinds")] public IList ServiceBinds { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTwitterConfiguration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTwitterConfiguration.Serialization.cs index e48521b591406..fca519bf7c12f 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTwitterConfiguration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTwitterConfiguration.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -108,6 +110,92 @@ internal static ContainerAppTwitterConfiguration DeserializeContainerAppTwitterC return new ContainerAppTwitterConfiguration(enabled, registration, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); + if (Optional.IsDefined(IsEnabled) || hasPropertyOverride) + { + builder.Append(" enabled: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsEnabled.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Registration), out propertyOverride); + if (Optional.IsDefined(Registration) || hasPropertyOverride) + { + builder.Append(" registration: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Registration, options, 2, false, " registration: "); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -116,6 +204,8 @@ BinaryData IPersistableModel.Write(ModelReader { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppTwitterConfiguration)} does not support '{options.Format}' format."); } @@ -132,6 +222,8 @@ ContainerAppTwitterConfiguration IPersistableModel <code>false</code> if the Twitter provider should not be enabled despite the set registration; otherwise, <code>true</code>. + [WirePath("enabled")] public bool? IsEnabled { get; set; } /// The configuration settings of the app registration for the Twitter provider. + [WirePath("registration")] public ContainerAppTwitterRegistration Registration { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTwitterRegistration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTwitterRegistration.Serialization.cs index ea55272fe5365..1ec78f062466c 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTwitterRegistration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTwitterRegistration.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -100,6 +102,107 @@ internal static ContainerAppTwitterRegistration DeserializeContainerAppTwitterRe return new ContainerAppTwitterRegistration(consumerKey, consumerSecretSettingName, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ConsumerKey), out propertyOverride); + if (Optional.IsDefined(ConsumerKey) || hasPropertyOverride) + { + builder.Append(" consumerKey: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ConsumerKey.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ConsumerKey}'''"); + } + else + { + builder.AppendLine($"'{ConsumerKey}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ConsumerSecretSettingName), out propertyOverride); + if (Optional.IsDefined(ConsumerSecretSettingName) || hasPropertyOverride) + { + builder.Append(" consumerSecretSettingName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ConsumerSecretSettingName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ConsumerSecretSettingName}'''"); + } + else + { + builder.AppendLine($"'{ConsumerSecretSettingName}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -108,6 +211,8 @@ BinaryData IPersistableModel.Write(ModelReaderW { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppTwitterRegistration)} does not support '{options.Format}' format."); } @@ -124,6 +229,8 @@ ContainerAppTwitterRegistration IPersistableModel + [WirePath("consumerKey")] public string ConsumerKey { get; set; } /// /// The app setting name that contains the OAuth 1.0a consumer secret of the Twitter /// application used for sign-in. /// + [WirePath("consumerSecretSettingName")] public string ConsumerSecretSettingName { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppVnetConfiguration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppVnetConfiguration.Serialization.cs index 403a072cc6727..6692a0160dd55 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppVnetConfiguration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppVnetConfiguration.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -147,6 +149,158 @@ internal static ContainerAppVnetConfiguration DeserializeContainerAppVnetConfigu serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsInternal), out propertyOverride); + if (Optional.IsDefined(IsInternal) || hasPropertyOverride) + { + builder.Append(" internal: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsInternal.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(InfrastructureSubnetId), out propertyOverride); + if (Optional.IsDefined(InfrastructureSubnetId) || hasPropertyOverride) + { + builder.Append(" infrastructureSubnetId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{InfrastructureSubnetId.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DockerBridgeCidr), out propertyOverride); + if (Optional.IsDefined(DockerBridgeCidr) || hasPropertyOverride) + { + builder.Append(" dockerBridgeCidr: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (DockerBridgeCidr.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{DockerBridgeCidr}'''"); + } + else + { + builder.AppendLine($"'{DockerBridgeCidr}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PlatformReservedCidr), out propertyOverride); + if (Optional.IsDefined(PlatformReservedCidr) || hasPropertyOverride) + { + builder.Append(" platformReservedCidr: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (PlatformReservedCidr.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{PlatformReservedCidr}'''"); + } + else + { + builder.AppendLine($"'{PlatformReservedCidr}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PlatformReservedDnsIP), out propertyOverride); + if (Optional.IsDefined(PlatformReservedDnsIP) || hasPropertyOverride) + { + builder.Append(" platformReservedDnsIP: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (PlatformReservedDnsIP.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{PlatformReservedDnsIP}'''"); + } + else + { + builder.AppendLine($"'{PlatformReservedDnsIP}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -155,6 +309,8 @@ BinaryData IPersistableModel.Write(ModelReaderWri { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppVnetConfiguration)} does not support '{options.Format}' format."); } @@ -171,6 +327,8 @@ ContainerAppVnetConfiguration IPersistableModel.C using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppVnetConfiguration(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppVnetConfiguration)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppVnetConfiguration.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppVnetConfiguration.cs index 82a25900225ff..3d4622b33af5c 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppVnetConfiguration.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppVnetConfiguration.cs @@ -69,14 +69,19 @@ internal ContainerAppVnetConfiguration(bool? isInternal, ResourceIdentifier infr } /// Boolean indicating the environment only has an internal load balancer. These environments do not have a public static IP resource. They must provide infrastructureSubnetId if enabling this property. + [WirePath("internal")] public bool? IsInternal { get; set; } /// Resource ID of a subnet for infrastructure components. Must not overlap with any other provided IP ranges. + [WirePath("infrastructureSubnetId")] public ResourceIdentifier InfrastructureSubnetId { get; set; } /// CIDR notation IP range assigned to the Docker bridge, network. Must not overlap with any other provided IP ranges. + [WirePath("dockerBridgeCidr")] public string DockerBridgeCidr { get; set; } /// IP range in CIDR notation that can be reserved for environment infrastructure IP addresses. Must not overlap with any other provided IP ranges. + [WirePath("platformReservedCidr")] public string PlatformReservedCidr { get; set; } /// An IP address from the IP range defined by platformReservedCidr that will be reserved for the internal DNS server. + [WirePath("platformReservedDnsIP")] public string PlatformReservedDnsIP { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppVolume.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppVolume.Serialization.cs index 5ab23b3a649fe..ef89ad74054a6 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppVolume.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppVolume.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -157,6 +160,165 @@ internal static ContainerAppVolume DeserializeContainerAppVolume(JsonElement ele serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageType), out propertyOverride); + if (Optional.IsDefined(StorageType) || hasPropertyOverride) + { + builder.Append(" storageType: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{StorageType.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageName), out propertyOverride); + if (Optional.IsDefined(StorageName) || hasPropertyOverride) + { + builder.Append(" storageName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (StorageName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{StorageName}'''"); + } + else + { + builder.AppendLine($"'{StorageName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Secrets), out propertyOverride); + if (Optional.IsCollectionDefined(Secrets) || hasPropertyOverride) + { + if (Secrets.Any() || hasPropertyOverride) + { + builder.Append(" secrets: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Secrets) + { + AppendChildObject(builder, item, options, 4, true, " secrets: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MountOptions), out propertyOverride); + if (Optional.IsDefined(MountOptions) || hasPropertyOverride) + { + builder.Append(" mountOptions: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (MountOptions.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{MountOptions}'''"); + } + else + { + builder.AppendLine($"'{MountOptions}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -165,6 +327,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppVolume)} does not support '{options.Format}' format."); } @@ -181,6 +345,8 @@ ContainerAppVolume IPersistableModel.Create(BinaryData data, using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppVolume(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppVolume)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppVolume.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppVolume.cs index 3f9d675acd233..fe871f7563f3e 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppVolume.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppVolume.cs @@ -70,14 +70,19 @@ internal ContainerAppVolume(string name, ContainerAppStorageType? storageType, s } /// Volume name. + [WirePath("name")] public string Name { get; set; } /// Storage type for the volume. If not provided, use EmptyDir. + [WirePath("storageType")] public ContainerAppStorageType? StorageType { get; set; } /// Name of storage resource. No need to provide for EmptyDir and Secret. + [WirePath("storageName")] public string StorageName { get; set; } /// List of secrets to be added in volume. If no secrets are provided, all secrets in collection will be added to volume. + [WirePath("secrets")] public IList Secrets { get; } /// Mount options used while mounting the AzureFile. Must be a comma-separated string. + [WirePath("mountOptions")] public string MountOptions { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppVolumeMount.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppVolumeMount.Serialization.cs index 1ff06ffb04956..8c5c925e252fb 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppVolumeMount.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppVolumeMount.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -111,6 +113,129 @@ internal static ContainerAppVolumeMount DeserializeContainerAppVolumeMount(JsonE return new ContainerAppVolumeMount(volumeName, mountPath, subPath, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(VolumeName), out propertyOverride); + if (Optional.IsDefined(VolumeName) || hasPropertyOverride) + { + builder.Append(" volumeName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (VolumeName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{VolumeName}'''"); + } + else + { + builder.AppendLine($"'{VolumeName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MountPath), out propertyOverride); + if (Optional.IsDefined(MountPath) || hasPropertyOverride) + { + builder.Append(" mountPath: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (MountPath.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{MountPath}'''"); + } + else + { + builder.AppendLine($"'{MountPath}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SubPath), out propertyOverride); + if (Optional.IsDefined(SubPath) || hasPropertyOverride) + { + builder.Append(" subPath: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (SubPath.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{SubPath}'''"); + } + else + { + builder.AppendLine($"'{SubPath}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -119,6 +244,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpt { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppVolumeMount)} does not support '{options.Format}' format."); } @@ -135,6 +262,8 @@ ContainerAppVolumeMount IPersistableModel.Create(Binary using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppVolumeMount(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppVolumeMount)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppVolumeMount.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppVolumeMount.cs index b16b584e1165d..56b0abcecb726 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppVolumeMount.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppVolumeMount.cs @@ -64,10 +64,13 @@ internal ContainerAppVolumeMount(string volumeName, string mountPath, string sub } /// This must match the Name of a Volume. + [WirePath("volumeName")] public string VolumeName { get; set; } /// Path within the container at which the volume should be mounted.Must not contain ':'. + [WirePath("mountPath")] public string MountPath { get; set; } /// Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root). + [WirePath("subPath")] public string SubPath { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppWorkloadProfile.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppWorkloadProfile.Serialization.cs index 6ca8ea0b85c5b..8b1221e45ecd8 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppWorkloadProfile.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppWorkloadProfile.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -124,6 +126,135 @@ internal static ContainerAppWorkloadProfile DeserializeContainerAppWorkloadProfi return new ContainerAppWorkloadProfile(name, workloadProfileType, minimumCount, maximumCount, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(WorkloadProfileType), out propertyOverride); + if (Optional.IsDefined(WorkloadProfileType) || hasPropertyOverride) + { + builder.Append(" workloadProfileType: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (WorkloadProfileType.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{WorkloadProfileType}'''"); + } + else + { + builder.AppendLine($"'{WorkloadProfileType}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MinimumNodeCount), out propertyOverride); + if (Optional.IsDefined(MinimumNodeCount) || hasPropertyOverride) + { + builder.Append(" minimumCount: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{MinimumNodeCount.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MaximumNodeCount), out propertyOverride); + if (Optional.IsDefined(MaximumNodeCount) || hasPropertyOverride) + { + builder.Append(" maximumCount: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{MaximumNodeCount.Value}"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -132,6 +263,8 @@ BinaryData IPersistableModel.Write(ModelReaderWrite { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppWorkloadProfile)} does not support '{options.Format}' format."); } @@ -148,6 +281,8 @@ ContainerAppWorkloadProfile IPersistableModel.Creat using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppWorkloadProfile(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppWorkloadProfile)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppWorkloadProfile.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppWorkloadProfile.cs index 5e99d1922099f..02bcb81308abf 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppWorkloadProfile.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppWorkloadProfile.cs @@ -80,12 +80,16 @@ internal ContainerAppWorkloadProfile() } /// Workload profile type for the workloads to run on. + [WirePath("name")] public string Name { get; set; } /// Workload profile type for the workloads to run on. + [WirePath("workloadProfileType")] public string WorkloadProfileType { get; set; } /// The minimum capacity. + [WirePath("minimumCount")] public int? MinimumNodeCount { get; set; } /// The maximum capacity. + [WirePath("maximumCount")] public int? MaximumNodeCount { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppWorkloadProfileState.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppWorkloadProfileState.Serialization.cs index fa4de7ea06aa8..8b705cb7fb25f 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppWorkloadProfileState.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppWorkloadProfileState.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; using Azure.ResourceManager.Models; @@ -148,6 +150,127 @@ internal static ContainerAppWorkloadProfileState DeserializeContainerAppWorkload serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Properties), out propertyOverride); + if (Optional.IsDefined(Properties) || hasPropertyOverride) + { + builder.Append(" properties: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Properties, options, 2, false, " properties: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -156,6 +279,8 @@ BinaryData IPersistableModel.Write(ModelReader { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppWorkloadProfileState)} does not support '{options.Format}' format."); } @@ -172,6 +297,8 @@ ContainerAppWorkloadProfileState IPersistableModel Workload Profile resource specific properties. + [WirePath("properties")] public ContainerAppWorkloadProfileStateProperties Properties { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppWorkloadProfileStateProperties.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppWorkloadProfileStateProperties.Serialization.cs index 9cc3e53eb7b53..7720a071b2793 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppWorkloadProfileStateProperties.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppWorkloadProfileStateProperties.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -123,6 +125,105 @@ internal static ContainerAppWorkloadProfileStateProperties DeserializeContainerA return new ContainerAppWorkloadProfileStateProperties(minimumCount, maximumCount, currentCount, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MinimumCount), out propertyOverride); + if (Optional.IsDefined(MinimumCount) || hasPropertyOverride) + { + builder.Append(" minimumCount: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{MinimumCount.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MaximumCount), out propertyOverride); + if (Optional.IsDefined(MaximumCount) || hasPropertyOverride) + { + builder.Append(" maximumCount: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{MaximumCount.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CurrentCount), out propertyOverride); + if (Optional.IsDefined(CurrentCount) || hasPropertyOverride) + { + builder.Append(" currentCount: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{CurrentCount.Value}"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -131,6 +232,8 @@ BinaryData IPersistableModel.Write(M { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppWorkloadProfileStateProperties)} does not support '{options.Format}' format."); } @@ -147,6 +250,8 @@ ContainerAppWorkloadProfileStateProperties IPersistableModel Minimum count of instances. + [WirePath("minimumCount")] public int? MinimumCount { get; set; } /// Maximum count of nodes. + [WirePath("maximumCount")] public int? MaximumCount { get; set; } /// Current count of nodes. + [WirePath("currentCount")] public int? CurrentCount { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppWritableSecret.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppWritableSecret.Serialization.cs index 2a44cf0c46ebf..642505be91041 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppWritableSecret.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppWritableSecret.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -126,6 +128,143 @@ internal static ContainerAppWritableSecret DeserializeContainerAppWritableSecret return new ContainerAppWritableSecret(name, value, identity, keyVaultUrl, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsDefined(Value) || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Value}'''"); + } + else + { + builder.AppendLine($"'{Value}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Identity), out propertyOverride); + if (Optional.IsDefined(Identity) || hasPropertyOverride) + { + builder.Append(" identity: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Identity.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Identity}'''"); + } + else + { + builder.AppendLine($"'{Identity}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyVaultUri), out propertyOverride); + if (Optional.IsDefined(KeyVaultUri) || hasPropertyOverride) + { + builder.Append(" keyVaultUrl: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{KeyVaultUri.AbsoluteUri}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -134,6 +273,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriter { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerAppWritableSecret)} does not support '{options.Format}' format."); } @@ -150,6 +291,8 @@ ContainerAppWritableSecret IPersistableModel.Create( using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerAppWritableSecret(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerAppWritableSecret)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppWritableSecret.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppWritableSecret.cs index 5a2d6a69b01dc..ff1dc4ecc82b1 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppWritableSecret.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppWritableSecret.cs @@ -66,12 +66,16 @@ internal ContainerAppWritableSecret(string name, string value, string identity, } /// Secret Name. + [WirePath("name")] public string Name { get; set; } /// Secret Value. + [WirePath("value")] public string Value { get; set; } /// Resource ID of a managed identity to authenticate with Azure Key Vault, or System to use a system-assigned identity. + [WirePath("identity")] public string Identity { get; set; } /// Azure Key Vault URL pointing to the secret referenced by the container app. + [WirePath("keyVaultUrl")] public Uri KeyVaultUri { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/DaprComponentsCollection.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/DaprComponentsCollection.Serialization.cs index 5f65e715a111e..6bd58c504dc25 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/DaprComponentsCollection.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/DaprComponentsCollection.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -107,6 +110,107 @@ internal static DaprComponentsCollection DeserializeDaprComponentsCollection(Jso return new DaprComponentsCollection(value, nextLink, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (Optional.IsDefined(NextLink) || hasPropertyOverride) + { + builder.Append(" nextLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -115,6 +219,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOp { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(DaprComponentsCollection)} does not support '{options.Format}' format."); } @@ -131,6 +237,8 @@ DaprComponentsCollection IPersistableModel.Create(Bina using JsonDocument document = JsonDocument.Parse(data); return DeserializeDaprComponentsCollection(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(DaprComponentsCollection)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/DaprConfiguration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/DaprConfiguration.Serialization.cs index f71524c5dee77..c462faa73e7b2 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/DaprConfiguration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/DaprConfiguration.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -89,6 +91,85 @@ internal static DaprConfiguration DeserializeDaprConfiguration(JsonElement eleme return new DaprConfiguration(version, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Version), out propertyOverride); + if (Optional.IsDefined(Version) || hasPropertyOverride) + { + builder.Append(" version: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Version.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Version}'''"); + } + else + { + builder.AppendLine($"'{Version}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -97,6 +178,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions o { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(DaprConfiguration)} does not support '{options.Format}' format."); } @@ -113,6 +196,8 @@ DaprConfiguration IPersistableModel.Create(BinaryData data, M using JsonDocument document = JsonDocument.Parse(data); return DeserializeDaprConfiguration(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(DaprConfiguration)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/DaprConfiguration.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/DaprConfiguration.cs index caf3242660219..9fddf839ab062 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/DaprConfiguration.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/DaprConfiguration.cs @@ -60,6 +60,7 @@ internal DaprConfiguration(string version, IDictionary seria } /// The version of Dapr. + [WirePath("version")] public string Version { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/DaprSecretsCollection.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/DaprSecretsCollection.Serialization.cs index f2fb46197ac9c..04836daa39ed6 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/DaprSecretsCollection.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/DaprSecretsCollection.Serialization.cs @@ -8,8 +8,12 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; +using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models { @@ -95,6 +99,85 @@ internal static DaprSecretsCollection DeserializeDaprSecretsCollection(JsonEleme return new DaprSecretsCollection(value, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -103,6 +186,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptio { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(DaprSecretsCollection)} does not support '{options.Format}' format."); } @@ -119,6 +204,8 @@ DaprSecretsCollection IPersistableModel.Create(BinaryData using JsonDocument document = JsonDocument.Parse(data); return DeserializeDaprSecretsCollection(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(DaprSecretsCollection)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/DaprSecretsCollection.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/DaprSecretsCollection.cs index 35a6fc8282369..5352006555e98 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/DaprSecretsCollection.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/DaprSecretsCollection.cs @@ -72,6 +72,7 @@ internal DaprSecretsCollection() } /// Collection of secrets used by a Dapr component. + [WirePath("value")] public IReadOnlyList Value { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/DiagnosticsCollection.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/DiagnosticsCollection.Serialization.cs index e77585bc91715..24de1704277db 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/DiagnosticsCollection.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/DiagnosticsCollection.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -107,6 +110,107 @@ internal static DiagnosticsCollection DeserializeDiagnosticsCollection(JsonEleme return new DiagnosticsCollection(value, nextLink, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (Optional.IsDefined(NextLink) || hasPropertyOverride) + { + builder.Append(" nextLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -115,6 +219,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptio { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(DiagnosticsCollection)} does not support '{options.Format}' format."); } @@ -131,6 +237,8 @@ DiagnosticsCollection IPersistableModel.Create(BinaryData using JsonDocument document = JsonDocument.Parse(data); return DeserializeDiagnosticsCollection(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(DiagnosticsCollection)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/DiagnosticsCollection.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/DiagnosticsCollection.cs index d738928a4ae77..9697c7f5d5c1c 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/DiagnosticsCollection.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/DiagnosticsCollection.cs @@ -74,8 +74,10 @@ internal DiagnosticsCollection() } /// Collection of diagnostic data. + [WirePath("value")] public IReadOnlyList Value { get; } /// Link to next page of resources. + [WirePath("nextLink")] public string NextLink { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/EventTriggerConfiguration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/EventTriggerConfiguration.Serialization.cs index 28b7833d23ddb..dc43e21376abe 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/EventTriggerConfiguration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/EventTriggerConfiguration.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -123,6 +125,105 @@ internal static EventTriggerConfiguration DeserializeEventTriggerConfiguration(J return new EventTriggerConfiguration(replicaCompletionCount, parallelism, scale, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ReplicaCompletionCount), out propertyOverride); + if (Optional.IsDefined(ReplicaCompletionCount) || hasPropertyOverride) + { + builder.Append(" replicaCompletionCount: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{ReplicaCompletionCount.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Parallelism), out propertyOverride); + if (Optional.IsDefined(Parallelism) || hasPropertyOverride) + { + builder.Append(" parallelism: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{Parallelism.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Scale), out propertyOverride); + if (Optional.IsDefined(Scale) || hasPropertyOverride) + { + builder.Append(" scale: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Scale, options, 2, false, " scale: "); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -131,6 +232,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterO { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(EventTriggerConfiguration)} does not support '{options.Format}' format."); } @@ -147,6 +250,8 @@ EventTriggerConfiguration IPersistableModel.Create(Bi using JsonDocument document = JsonDocument.Parse(data); return DeserializeEventTriggerConfiguration(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(EventTriggerConfiguration)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/EventTriggerConfiguration.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/EventTriggerConfiguration.cs index 6ae408d85bc02..78e715afc6a2b 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/EventTriggerConfiguration.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/EventTriggerConfiguration.cs @@ -64,10 +64,13 @@ internal EventTriggerConfiguration(int? replicaCompletionCount, int? parallelism } /// Minimum number of successful replica completions before overall job completion. + [WirePath("replicaCompletionCount")] public int? ReplicaCompletionCount { get; set; } /// Number of parallel replicas of a job that can run at a given time. + [WirePath("parallelism")] public int? Parallelism { get; set; } /// Scaling configurations for event driven jobs. + [WirePath("scale")] public ContainerAppJobScale Scale { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/HttpSettingsRoutes.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/HttpSettingsRoutes.Serialization.cs index 3e4c26247568b..94495b0f5958a 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/HttpSettingsRoutes.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/HttpSettingsRoutes.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -89,6 +91,85 @@ internal static HttpSettingsRoutes DeserializeHttpSettingsRoutes(JsonElement ele return new HttpSettingsRoutes(apiPrefix, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ApiPrefix), out propertyOverride); + if (Optional.IsDefined(ApiPrefix) || hasPropertyOverride) + { + builder.Append(" apiPrefix: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ApiPrefix.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ApiPrefix}'''"); + } + else + { + builder.AppendLine($"'{ApiPrefix}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -97,6 +178,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(HttpSettingsRoutes)} does not support '{options.Format}' format."); } @@ -113,6 +196,8 @@ HttpSettingsRoutes IPersistableModel.Create(BinaryData data, using JsonDocument document = JsonDocument.Parse(data); return DeserializeHttpSettingsRoutes(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(HttpSettingsRoutes)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/HttpSettingsRoutes.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/HttpSettingsRoutes.cs index 5f61ff2b8e23c..e3a5b7c674703 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/HttpSettingsRoutes.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/HttpSettingsRoutes.cs @@ -60,6 +60,7 @@ internal HttpSettingsRoutes(string apiPrefix, IDictionary se } /// The prefix that should precede all the authentication/authorization paths. + [WirePath("apiPrefix")] public string ApiPrefix { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/IngressStickySessions.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/IngressStickySessions.Serialization.cs index eb6c643d6bab4..af297efeebb0f 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/IngressStickySessions.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/IngressStickySessions.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -93,6 +95,77 @@ internal static IngressStickySessions DeserializeIngressStickySessions(JsonEleme return new IngressStickySessions(affinity, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Affinity), out propertyOverride); + if (Optional.IsDefined(Affinity) || hasPropertyOverride) + { + builder.Append(" affinity: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Affinity.Value.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -101,6 +174,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptio { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(IngressStickySessions)} does not support '{options.Format}' format."); } @@ -117,6 +192,8 @@ IngressStickySessions IPersistableModel.Create(BinaryData using JsonDocument document = JsonDocument.Parse(data); return DeserializeIngressStickySessions(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(IngressStickySessions)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/IngressStickySessions.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/IngressStickySessions.cs index cdd42eb2ec3cf..ac04b171c8f24 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/IngressStickySessions.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/IngressStickySessions.cs @@ -60,6 +60,7 @@ internal IngressStickySessions(Affinity? affinity, IDictionary Sticky Session Affinity. + [WirePath("affinity")] public Affinity? Affinity { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/JobConfigurationManualTriggerConfig.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/JobConfigurationManualTriggerConfig.Serialization.cs index ef2787d0c0184..ff4ac72e5fcd1 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/JobConfigurationManualTriggerConfig.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/JobConfigurationManualTriggerConfig.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -108,6 +110,91 @@ internal static JobConfigurationManualTriggerConfig DeserializeJobConfigurationM return new JobConfigurationManualTriggerConfig(replicaCompletionCount, parallelism, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ReplicaCompletionCount), out propertyOverride); + if (Optional.IsDefined(ReplicaCompletionCount) || hasPropertyOverride) + { + builder.Append(" replicaCompletionCount: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{ReplicaCompletionCount.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Parallelism), out propertyOverride); + if (Optional.IsDefined(Parallelism) || hasPropertyOverride) + { + builder.Append(" parallelism: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{Parallelism.Value}"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -116,6 +203,8 @@ BinaryData IPersistableModel.Write(ModelRea { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(JobConfigurationManualTriggerConfig)} does not support '{options.Format}' format."); } @@ -132,6 +221,8 @@ JobConfigurationManualTriggerConfig IPersistableModel Minimum number of successful replica completions before overall job completion. + [WirePath("replicaCompletionCount")] public int? ReplicaCompletionCount { get; set; } /// Number of parallel replicas of a job that can run at a given time. + [WirePath("parallelism")] public int? Parallelism { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/JobConfigurationScheduleTriggerConfig.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/JobConfigurationScheduleTriggerConfig.Serialization.cs index 7cdeef5b9120c..6b541b5954437 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/JobConfigurationScheduleTriggerConfig.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/JobConfigurationScheduleTriggerConfig.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -116,6 +118,113 @@ internal static JobConfigurationScheduleTriggerConfig DeserializeJobConfiguratio return new JobConfigurationScheduleTriggerConfig(replicaCompletionCount, cronExpression, parallelism, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ReplicaCompletionCount), out propertyOverride); + if (Optional.IsDefined(ReplicaCompletionCount) || hasPropertyOverride) + { + builder.Append(" replicaCompletionCount: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{ReplicaCompletionCount.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CronExpression), out propertyOverride); + if (Optional.IsDefined(CronExpression) || hasPropertyOverride) + { + builder.Append(" cronExpression: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (CronExpression.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{CronExpression}'''"); + } + else + { + builder.AppendLine($"'{CronExpression}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Parallelism), out propertyOverride); + if (Optional.IsDefined(Parallelism) || hasPropertyOverride) + { + builder.Append(" parallelism: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{Parallelism.Value}"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -124,6 +233,8 @@ BinaryData IPersistableModel.Write(ModelR { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(JobConfigurationScheduleTriggerConfig)} does not support '{options.Format}' format."); } @@ -140,6 +251,8 @@ JobConfigurationScheduleTriggerConfig IPersistableModel Minimum number of successful replica completions before overall job completion. + [WirePath("replicaCompletionCount")] public int? ReplicaCompletionCount { get; set; } /// Cron formatted repeating schedule ("* * * * *") of a Cron Job. + [WirePath("cronExpression")] public string CronExpression { get; set; } /// Number of parallel replicas of a job that can run at a given time. + [WirePath("parallelism")] public int? Parallelism { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/JobExecutionContainer.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/JobExecutionContainer.Serialization.cs index 0ef234edd78e9..e989d5afef66a 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/JobExecutionContainer.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/JobExecutionContainer.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -197,6 +200,213 @@ internal static JobExecutionContainer DeserializeJobExecutionContainer(JsonEleme serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Image), out propertyOverride); + if (Optional.IsDefined(Image) || hasPropertyOverride) + { + builder.Append(" image: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Image.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Image}'''"); + } + else + { + builder.AppendLine($"'{Image}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Command), out propertyOverride); + if (Optional.IsCollectionDefined(Command) || hasPropertyOverride) + { + if (Command.Any() || hasPropertyOverride) + { + builder.Append(" command: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Command) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Args), out propertyOverride); + if (Optional.IsCollectionDefined(Args) || hasPropertyOverride) + { + if (Args.Any() || hasPropertyOverride) + { + builder.Append(" args: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Args) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Env), out propertyOverride); + if (Optional.IsCollectionDefined(Env) || hasPropertyOverride) + { + if (Env.Any() || hasPropertyOverride) + { + builder.Append(" env: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Env) + { + AppendChildObject(builder, item, options, 4, true, " env: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Resources), out propertyOverride); + if (Optional.IsDefined(Resources) || hasPropertyOverride) + { + builder.Append(" resources: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Resources, options, 2, false, " resources: "); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -205,6 +415,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptio { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(JobExecutionContainer)} does not support '{options.Format}' format."); } @@ -221,6 +433,8 @@ JobExecutionContainer IPersistableModel.Create(BinaryData using JsonDocument document = JsonDocument.Parse(data); return DeserializeJobExecutionContainer(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(JobExecutionContainer)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/JobExecutionContainer.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/JobExecutionContainer.cs index 1e55f553351bf..f3b8661cffaa0 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/JobExecutionContainer.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/JobExecutionContainer.cs @@ -74,16 +74,22 @@ internal JobExecutionContainer(string image, string name, IList command, } /// Container image tag. + [WirePath("image")] public string Image { get; set; } /// Custom container name. + [WirePath("name")] public string Name { get; set; } /// Container start command. + [WirePath("command")] public IList Command { get; } /// Container start command arguments. + [WirePath("args")] public IList Args { get; } /// Container environment variables. + [WirePath("env")] public IList Env { get; } /// Container resource requirements. + [WirePath("resources")] public AppContainerResources Resources { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/JobSecretsCollection.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/JobSecretsCollection.Serialization.cs index 879c00125ae1f..4eabb6adfce75 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/JobSecretsCollection.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/JobSecretsCollection.Serialization.cs @@ -8,8 +8,12 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; +using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models { @@ -95,6 +99,85 @@ internal static JobSecretsCollection DeserializeJobSecretsCollection(JsonElement return new JobSecretsCollection(value, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -103,6 +186,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOption { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(JobSecretsCollection)} does not support '{options.Format}' format."); } @@ -119,6 +204,8 @@ JobSecretsCollection IPersistableModel.Create(BinaryData d using JsonDocument document = JsonDocument.Parse(data); return DeserializeJobSecretsCollection(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(JobSecretsCollection)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/JobSecretsCollection.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/JobSecretsCollection.cs index 8014f11bd1299..6c01ba05c772b 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/JobSecretsCollection.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/JobSecretsCollection.cs @@ -72,6 +72,7 @@ internal JobSecretsCollection() } /// Collection of resources. + [WirePath("value")] public IReadOnlyList Value { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/KedaConfiguration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/KedaConfiguration.Serialization.cs index 4490d044dee4b..177655f25efe5 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/KedaConfiguration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/KedaConfiguration.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -89,6 +91,85 @@ internal static KedaConfiguration DeserializeKedaConfiguration(JsonElement eleme return new KedaConfiguration(version, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Version), out propertyOverride); + if (Optional.IsDefined(Version) || hasPropertyOverride) + { + builder.Append(" version: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Version.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Version}'''"); + } + else + { + builder.AppendLine($"'{Version}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -97,6 +178,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions o { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(KedaConfiguration)} does not support '{options.Format}' format."); } @@ -113,6 +196,8 @@ KedaConfiguration IPersistableModel.Create(BinaryData data, M using JsonDocument document = JsonDocument.Parse(data); return DeserializeKedaConfiguration(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(KedaConfiguration)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/KedaConfiguration.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/KedaConfiguration.cs index 168c9a51f6fc3..347dd760b04e9 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/KedaConfiguration.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/KedaConfiguration.cs @@ -60,6 +60,7 @@ internal KedaConfiguration(string version, IDictionary seria } /// The version of Keda. + [WirePath("version")] public string Version { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/LoginRoutes.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/LoginRoutes.Serialization.cs index ba9f19adddab5..0b7e93bd26250 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/LoginRoutes.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/LoginRoutes.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -89,6 +91,85 @@ internal static LoginRoutes DeserializeLoginRoutes(JsonElement element, ModelRea return new LoginRoutes(logoutEndpoint, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LogoutEndpoint), out propertyOverride); + if (Optional.IsDefined(LogoutEndpoint) || hasPropertyOverride) + { + builder.Append(" logoutEndpoint: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (LogoutEndpoint.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{LogoutEndpoint}'''"); + } + else + { + builder.AppendLine($"'{LogoutEndpoint}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -97,6 +178,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions options { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(LoginRoutes)} does not support '{options.Format}' format."); } @@ -113,6 +196,8 @@ LoginRoutes IPersistableModel.Create(BinaryData data, ModelReaderWr using JsonDocument document = JsonDocument.Parse(data); return DeserializeLoginRoutes(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(LoginRoutes)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/LoginRoutes.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/LoginRoutes.cs index 7cc1e8a9ba320..df60c7af1b716 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/LoginRoutes.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/LoginRoutes.cs @@ -60,6 +60,7 @@ internal LoginRoutes(string logoutEndpoint, IDictionary seri } /// The endpoint at which a logout request should be made. + [WirePath("logoutEndpoint")] public string LogoutEndpoint { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/LoginScopes.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/LoginScopes.Serialization.cs index d9cce94df4521..d338903001167 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/LoginScopes.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/LoginScopes.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -103,6 +106,98 @@ internal static LoginScopes DeserializeLoginScopes(JsonElement element, ModelRea return new LoginScopes(scopes ?? new ChangeTrackingList(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Scopes), out propertyOverride); + if (Optional.IsCollectionDefined(Scopes) || hasPropertyOverride) + { + if (Scopes.Any() || hasPropertyOverride) + { + builder.Append(" scopes: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Scopes) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -111,6 +206,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions options { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(LoginScopes)} does not support '{options.Format}' format."); } @@ -127,6 +224,8 @@ LoginScopes IPersistableModel.Create(BinaryData data, ModelReaderWr using JsonDocument document = JsonDocument.Parse(data); return DeserializeLoginScopes(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(LoginScopes)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/LoginScopes.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/LoginScopes.cs index 8dd03eee88968..65f4c1dc390a0 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/LoginScopes.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/LoginScopes.cs @@ -62,6 +62,7 @@ internal LoginScopes(IList scopes, IDictionary seria } /// A list of the scopes that should be requested while authenticating. + [WirePath("scopes")] public IList Scopes { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedCertificateCollection.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedCertificateCollection.Serialization.cs index 77acd96d13e67..abb0c9c0972aa 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedCertificateCollection.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedCertificateCollection.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -107,6 +110,107 @@ internal static ManagedCertificateCollection DeserializeManagedCertificateCollec return new ManagedCertificateCollection(value, nextLink, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (Optional.IsDefined(NextLink) || hasPropertyOverride) + { + builder.Append(" nextLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -115,6 +219,8 @@ BinaryData IPersistableModel.Write(ModelReaderWrit { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ManagedCertificateCollection)} does not support '{options.Format}' format."); } @@ -131,6 +237,8 @@ ManagedCertificateCollection IPersistableModel.Cre using JsonDocument document = JsonDocument.Parse(data); return DeserializeManagedCertificateCollection(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ManagedCertificateCollection)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedCertificateProperties.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedCertificateProperties.Serialization.cs index 57dc311894479..49bb2f579f059 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedCertificateProperties.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedCertificateProperties.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -147,6 +149,157 @@ internal static ManagedCertificateProperties DeserializeManagedCertificateProper serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); + if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) + { + builder.Append(" provisioningState: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ProvisioningState.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SubjectName), out propertyOverride); + if (Optional.IsDefined(SubjectName) || hasPropertyOverride) + { + builder.Append(" subjectName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (SubjectName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{SubjectName}'''"); + } + else + { + builder.AppendLine($"'{SubjectName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Error), out propertyOverride); + if (Optional.IsDefined(Error) || hasPropertyOverride) + { + builder.Append(" error: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Error.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Error}'''"); + } + else + { + builder.AppendLine($"'{Error}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DomainControlValidation), out propertyOverride); + if (Optional.IsDefined(DomainControlValidation) || hasPropertyOverride) + { + builder.Append(" domainControlValidation: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{DomainControlValidation.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ValidationToken), out propertyOverride); + if (Optional.IsDefined(ValidationToken) || hasPropertyOverride) + { + builder.Append(" validationToken: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ValidationToken.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ValidationToken}'''"); + } + else + { + builder.AppendLine($"'{ValidationToken}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -155,6 +308,8 @@ BinaryData IPersistableModel.Write(ModelReaderWrit { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ManagedCertificateProperties)} does not support '{options.Format}' format."); } @@ -171,6 +326,8 @@ ManagedCertificateProperties IPersistableModel.Cre using JsonDocument document = JsonDocument.Parse(data); return DeserializeManagedCertificateProperties(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ManagedCertificateProperties)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedCertificateProperties.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedCertificateProperties.cs index 1855a35652899..97bb68f029415 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedCertificateProperties.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedCertificateProperties.cs @@ -68,14 +68,19 @@ internal ManagedCertificateProperties(ContainerAppCertificateProvisioningState? } /// Provisioning state of the certificate. + [WirePath("provisioningState")] public ContainerAppCertificateProvisioningState? ProvisioningState { get; } /// Subject name of the certificate. + [WirePath("subjectName")] public string SubjectName { get; set; } /// Any error occurred during the certificate provision. + [WirePath("error")] public string Error { get; } /// Selected type of domain control validation for managed certificates. + [WirePath("domainControlValidation")] public ManagedCertificateDomainControlValidation? DomainControlValidation { get; set; } /// A TXT token used for DNS TXT domain control validation when issuing this type of managed certificates. + [WirePath("validationToken")] public string ValidationToken { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedEnvironmentPropertiesPeerAuthentication.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedEnvironmentPropertiesPeerAuthentication.Serialization.cs index d45185883e98b..7dd7e89f1d6d9 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedEnvironmentPropertiesPeerAuthentication.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedEnvironmentPropertiesPeerAuthentication.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -93,6 +95,77 @@ internal static ManagedEnvironmentPropertiesPeerAuthentication DeserializeManage return new ManagedEnvironmentPropertiesPeerAuthentication(mtls, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Mtls), out propertyOverride); + if (Optional.IsDefined(Mtls) || hasPropertyOverride) + { + builder.Append(" mtls: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Mtls, options, 2, false, " mtls: "); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -101,6 +174,8 @@ BinaryData IPersistableModel.Wri { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ManagedEnvironmentPropertiesPeerAuthentication)} does not support '{options.Format}' format."); } @@ -117,6 +192,8 @@ ManagedEnvironmentPropertiesPeerAuthentication IPersistableModel Mutual TLS authentication settings for the Managed Environment. internal Mtls Mtls { get; set; } /// Boolean indicating whether the mutual TLS authentication is enabled. + [WirePath("mtls.enabled")] public bool? IsMtlsEnabled { get => Mtls is null ? default : Mtls.IsMtlsEnabled; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedEnvironmentStorageProperties.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedEnvironmentStorageProperties.Serialization.cs index 2af2ab2661fc9..d34eefbaa48f2 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedEnvironmentStorageProperties.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedEnvironmentStorageProperties.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -93,6 +95,77 @@ internal static ManagedEnvironmentStorageProperties DeserializeManagedEnvironmen return new ManagedEnvironmentStorageProperties(azureFile, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AzureFile), out propertyOverride); + if (Optional.IsDefined(AzureFile) || hasPropertyOverride) + { + builder.Append(" azureFile: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, AzureFile, options, 2, false, " azureFile: "); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -101,6 +174,8 @@ BinaryData IPersistableModel.Write(ModelRea { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ManagedEnvironmentStorageProperties)} does not support '{options.Format}' format."); } @@ -117,6 +192,8 @@ ManagedEnvironmentStorageProperties IPersistableModel Azure file properties. + [WirePath("azureFile")] public ContainerAppAzureFileProperties AzureFile { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedEnvironmentStoragesCollection.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedEnvironmentStoragesCollection.Serialization.cs index 4d24a0b56ce7d..648e280355d3d 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedEnvironmentStoragesCollection.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedEnvironmentStoragesCollection.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -96,6 +99,85 @@ internal static ManagedEnvironmentStoragesCollection DeserializeManagedEnvironme return new ManagedEnvironmentStoragesCollection(value, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -104,6 +186,8 @@ BinaryData IPersistableModel.Write(ModelRe { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ManagedEnvironmentStoragesCollection)} does not support '{options.Format}' format."); } @@ -120,6 +204,8 @@ ManagedEnvironmentStoragesCollection IPersistableModel Collection of storage resources. + [WirePath("value")] public IReadOnlyList Value { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedEnvironmentsCollection.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedEnvironmentsCollection.Serialization.cs index 288066f1301d2..c93525c14be26 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedEnvironmentsCollection.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedEnvironmentsCollection.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -107,6 +110,107 @@ internal static ManagedEnvironmentsCollection DeserializeManagedEnvironmentsColl return new ManagedEnvironmentsCollection(value, nextLink, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (Optional.IsDefined(NextLink) || hasPropertyOverride) + { + builder.Append(" nextLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -115,6 +219,8 @@ BinaryData IPersistableModel.Write(ModelReaderWri { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ManagedEnvironmentsCollection)} does not support '{options.Format}' format."); } @@ -131,6 +237,8 @@ ManagedEnvironmentsCollection IPersistableModel.C using JsonDocument document = JsonDocument.Parse(data); return DeserializeManagedEnvironmentsCollection(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ManagedEnvironmentsCollection)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/Mtls.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/Mtls.Serialization.cs index 267ef3e2558ab..b0bffc07d1499 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/Mtls.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/Mtls.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -93,6 +95,78 @@ internal static Mtls DeserializeMtls(JsonElement element, ModelReaderWriterOptio return new Mtls(enabled, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsMtlsEnabled), out propertyOverride); + if (Optional.IsDefined(IsMtlsEnabled) || hasPropertyOverride) + { + builder.Append(" enabled: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsMtlsEnabled.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -101,6 +175,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(Mtls)} does not support '{options.Format}' format."); } @@ -117,6 +193,8 @@ Mtls IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions op using JsonDocument document = JsonDocument.Parse(data); return DeserializeMtls(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(Mtls)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/Mtls.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/Mtls.cs index 52dc1afafdc80..0fab51ea0c3c7 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/Mtls.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/Mtls.cs @@ -60,6 +60,7 @@ internal Mtls(bool? isMtlsEnabled, IDictionary serializedAdd } /// Boolean indicating whether the mutual TLS authentication is enabled. + [WirePath("enabled")] public bool? IsMtlsEnabled { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ReplicaCollection.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ReplicaCollection.Serialization.cs index 08e81d073f530..3015ede29655b 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ReplicaCollection.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ReplicaCollection.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -96,6 +99,85 @@ internal static ReplicaCollection DeserializeReplicaCollection(JsonElement eleme return new ReplicaCollection(value, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -104,6 +186,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions o { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ReplicaCollection)} does not support '{options.Format}' format."); } @@ -120,6 +204,8 @@ ReplicaCollection IPersistableModel.Create(BinaryData data, M using JsonDocument document = JsonDocument.Parse(data); return DeserializeReplicaCollection(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ReplicaCollection)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ReplicaCollection.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ReplicaCollection.cs index 8d4a99955b406..3ee6b1b0a1928 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ReplicaCollection.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ReplicaCollection.cs @@ -72,6 +72,7 @@ internal ReplicaCollection() } /// Collection of resources. + [WirePath("value")] public IReadOnlyList Value { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/RevisionCollection.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/RevisionCollection.Serialization.cs index 4c7ad292db9c1..47d568f0d9484 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/RevisionCollection.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/RevisionCollection.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -107,6 +110,107 @@ internal static RevisionCollection DeserializeRevisionCollection(JsonElement ele return new RevisionCollection(value, nextLink, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (Optional.IsDefined(NextLink) || hasPropertyOverride) + { + builder.Append(" nextLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -115,6 +219,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(RevisionCollection)} does not support '{options.Format}' format."); } @@ -131,6 +237,8 @@ RevisionCollection IPersistableModel.Create(BinaryData data, using JsonDocument document = JsonDocument.Parse(data); return DeserializeRevisionCollection(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(RevisionCollection)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/SecretVolumeItem.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/SecretVolumeItem.Serialization.cs index a2d94607f89ab..7a768d09037d6 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/SecretVolumeItem.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/SecretVolumeItem.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -100,6 +102,107 @@ internal static SecretVolumeItem DeserializeSecretVolumeItem(JsonElement element return new SecretVolumeItem(secretRef, path, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SecretRef), out propertyOverride); + if (Optional.IsDefined(SecretRef) || hasPropertyOverride) + { + builder.Append(" secretRef: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (SecretRef.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{SecretRef}'''"); + } + else + { + builder.AppendLine($"'{SecretRef}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Path), out propertyOverride); + if (Optional.IsDefined(Path) || hasPropertyOverride) + { + builder.Append(" path: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Path.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Path}'''"); + } + else + { + builder.AppendLine($"'{Path}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -108,6 +211,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions op { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(SecretVolumeItem)} does not support '{options.Format}' format."); } @@ -124,6 +229,8 @@ SecretVolumeItem IPersistableModel.Create(BinaryData data, Mod using JsonDocument document = JsonDocument.Parse(data); return DeserializeSecretVolumeItem(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(SecretVolumeItem)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/SecretVolumeItem.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/SecretVolumeItem.cs index a6d41475b7d1b..aab06e2f56b5e 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/SecretVolumeItem.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/SecretVolumeItem.cs @@ -62,8 +62,10 @@ internal SecretVolumeItem(string secretRef, string path, IDictionary Name of the Container App secret from which to pull the secret value. + [WirePath("secretRef")] public string SecretRef { get; set; } /// Path to project secret to. If no path is provided, path defaults to name of secret listed in secretRef. + [WirePath("path")] public string Path { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/SecretsCollection.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/SecretsCollection.Serialization.cs index 50886d5203e8f..b7f703f4d94ea 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/SecretsCollection.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/SecretsCollection.Serialization.cs @@ -8,8 +8,12 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; +using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models { @@ -95,6 +99,85 @@ internal static SecretsCollection DeserializeSecretsCollection(JsonElement eleme return new SecretsCollection(value, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -103,6 +186,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions o { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(SecretsCollection)} does not support '{options.Format}' format."); } @@ -119,6 +204,8 @@ SecretsCollection IPersistableModel.Create(BinaryData data, M using JsonDocument document = JsonDocument.Parse(data); return DeserializeSecretsCollection(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(SecretsCollection)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/SecretsCollection.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/SecretsCollection.cs index abf97806eb260..cd5b1d44654e9 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/SecretsCollection.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/SecretsCollection.cs @@ -72,6 +72,7 @@ internal SecretsCollection() } /// Collection of resources. + [WirePath("value")] public IReadOnlyList Value { get; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/Service.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/Service.Serialization.cs index f4a328dcff51d..8195dc5e494b3 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/Service.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/Service.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; namespace Azure.ResourceManager.AppContainers.Models { @@ -85,6 +87,63 @@ internal static Service DeserializeService(JsonElement element, ModelReaderWrite return new Service(type, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -93,6 +152,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(Service)} does not support '{options.Format}' format."); } @@ -109,6 +170,8 @@ Service IPersistableModel.Create(BinaryData data, ModelReaderWriterOpti using JsonDocument document = JsonDocument.Parse(data); return DeserializeService(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(Service)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/Service.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/Service.cs index c3623dd2811dc..522dc7c30b1f4 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/Service.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/Service.cs @@ -71,6 +71,7 @@ internal Service() } /// Dev ContainerApp service type. + [WirePath("type")] public string ServiceType { get; set; } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/SourceControlCollection.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/SourceControlCollection.Serialization.cs index b06db7e7175fc..8bfd0f45a0962 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/SourceControlCollection.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/SourceControlCollection.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -107,6 +110,107 @@ internal static SourceControlCollection DeserializeSourceControlCollection(JsonE return new SourceControlCollection(value, nextLink, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (Optional.IsDefined(NextLink) || hasPropertyOverride) + { + builder.Append(" nextLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -115,6 +219,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpt { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(SourceControlCollection)} does not support '{options.Format}' format."); } @@ -131,6 +237,8 @@ SourceControlCollection IPersistableModel.Create(Binary using JsonDocument document = JsonDocument.Parse(data); return DeserializeSourceControlCollection(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(SourceControlCollection)} does not support '{options.Format}' format."); } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/WorkloadProfileStatesCollection.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/WorkloadProfileStatesCollection.Serialization.cs index ad6bae05f0070..c2436953b23b6 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/WorkloadProfileStatesCollection.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/WorkloadProfileStatesCollection.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models @@ -107,6 +110,107 @@ internal static WorkloadProfileStatesCollection DeserializeWorkloadProfileStates return new WorkloadProfileStatesCollection(value, nextLink, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (Optional.IsDefined(NextLink) || hasPropertyOverride) + { + builder.Append(" nextLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -115,6 +219,8 @@ BinaryData IPersistableModel.Write(ModelReaderW { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(WorkloadProfileStatesCollection)} does not support '{options.Format}' format."); } @@ -131,6 +237,8 @@ WorkloadProfileStatesCollection IPersistableModel + +#nullable disable + +using System; + +namespace Azure.ResourceManager.OperationalInsights +{ + [AttributeUsage(AttributeTargets.Property)] + internal class WirePathAttribute : Attribute + { + private string _wirePath; + + public WirePathAttribute(string wirePath) + { + _wirePath = wirePath; + } + + public override string ToString() + { + return _wirePath; + } + } +} diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/LogAnalyticsQueryData.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/LogAnalyticsQueryData.Serialization.cs index 0d774448ea9fd..680f2ad914d16 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/LogAnalyticsQueryData.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/LogAnalyticsQueryData.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.Models; using Azure.ResourceManager.OperationalInsights.Models; @@ -331,6 +334,322 @@ internal static LogAnalyticsQueryData DeserializeLogAnalyticsQueryData(JsonEleme serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ApplicationId), out propertyOverride); + if (Optional.IsDefined(ApplicationId) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ApplicationId.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayName), out propertyOverride); + if (Optional.IsDefined(DisplayName) || hasPropertyOverride) + { + builder.Append(" displayName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (DisplayName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{DisplayName}'''"); + } + else + { + builder.AppendLine($"'{DisplayName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); + if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) + { + builder.Append(" timeCreated: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ModifiedOn), out propertyOverride); + if (Optional.IsDefined(ModifiedOn) || hasPropertyOverride) + { + builder.Append(" timeModified: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(ModifiedOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Author), out propertyOverride); + if (Optional.IsDefined(Author) || hasPropertyOverride) + { + builder.Append(" author: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Author.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Author}'''"); + } + else + { + builder.AppendLine($"'{Author}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); + if (Optional.IsDefined(Description) || hasPropertyOverride) + { + builder.Append(" description: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Description.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Description}'''"); + } + else + { + builder.AppendLine($"'{Description}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Body), out propertyOverride); + if (Optional.IsDefined(Body) || hasPropertyOverride) + { + builder.Append(" body: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Body.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Body}'''"); + } + else + { + builder.AppendLine($"'{Body}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Related), out propertyOverride); + if (Optional.IsDefined(Related) || hasPropertyOverride) + { + builder.Append(" related: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Related, options, 4, false, " related: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tags), out propertyOverride); + if (Optional.IsCollectionDefined(Tags) || hasPropertyOverride) + { + if (Tags.Any() || hasPropertyOverride) + { + builder.Append(" tags: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("{"); + foreach (var item in Tags) + { + builder.Append($" '{item.Key}': "); + if (item.Value == null) + { + builder.Append("null"); + continue; + } + builder.AppendLine("["); + foreach (var item0 in item.Value) + { + if (item0 == null) + { + builder.Append("null"); + continue; + } + if (item0.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item0}'''"); + } + else + { + builder.AppendLine($" '{item0}'"); + } + } + builder.AppendLine(" ]"); + } + builder.AppendLine(" }"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Properties), out propertyOverride); + if (Optional.IsDefined(Properties) || hasPropertyOverride) + { + builder.Append(" properties: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Properties.ToString()}'"); + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -339,6 +658,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptio { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(LogAnalyticsQueryData)} does not support '{options.Format}' format."); } @@ -355,6 +676,8 @@ LogAnalyticsQueryData IPersistableModel.Create(BinaryData using JsonDocument document = JsonDocument.Parse(data); return DeserializeLogAnalyticsQueryData(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(LogAnalyticsQueryData)} does not support '{options.Format}' format."); } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/LogAnalyticsQueryData.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/LogAnalyticsQueryData.cs index eeea17982eefc..713a17b9afa23 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/LogAnalyticsQueryData.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/LogAnalyticsQueryData.cs @@ -89,22 +89,31 @@ internal LogAnalyticsQueryData(ResourceIdentifier id, string name, ResourceType } /// The unique ID of your application. This field cannot be changed. + [WirePath("properties.id")] public Guid? ApplicationId { get; } /// Unique display name for your query within the Query Pack. + [WirePath("properties.displayName")] public string DisplayName { get; set; } /// Creation Date for the Log Analytics Query, in ISO 8601 format. + [WirePath("properties.timeCreated")] public DateTimeOffset? CreatedOn { get; } /// Last modified date of the Log Analytics Query, in ISO 8601 format. + [WirePath("properties.timeModified")] public DateTimeOffset? ModifiedOn { get; } /// Object Id of user creating the query. + [WirePath("properties.author")] public string Author { get; } /// Description of the query. + [WirePath("properties.description")] public string Description { get; set; } /// Body of the query. + [WirePath("properties.body")] public string Body { get; set; } /// The related metadata items for the function. + [WirePath("properties.related")] public LogAnalyticsQueryRelatedMetadata Related { get; set; } /// Tags associated with the query. + [WirePath("properties.tags")] public IDictionary> Tags { get; } /// /// Additional properties that can be set for the query. @@ -136,6 +145,7 @@ internal LogAnalyticsQueryData(ResourceIdentifier id, string name, ResourceType /// /// /// + [WirePath("properties.properties")] public BinaryData Properties { get; set; } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/LogAnalyticsQueryPackData.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/LogAnalyticsQueryPackData.Serialization.cs index 6fa8109bf972e..f6b49bfebee1c 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/LogAnalyticsQueryPackData.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/LogAnalyticsQueryPackData.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.Models; namespace Azure.ResourceManager.OperationalInsights @@ -242,6 +245,229 @@ internal static LogAnalyticsQueryPackData DeserializeLogAnalyticsQueryPackData(J serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); + builder.Append(" location: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Location.ToString()}'"); + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tags), out propertyOverride); + if (Optional.IsCollectionDefined(Tags) || hasPropertyOverride) + { + if (Tags.Any() || hasPropertyOverride) + { + builder.Append(" tags: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("{"); + foreach (var item in Tags) + { + builder.Append($" '{item.Key}': "); + if (item.Value == null) + { + builder.Append("null"); + continue; + } + if (item.Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{item.Value}'''"); + } + else + { + builder.AppendLine($"'{item.Value}'"); + } + } + builder.AppendLine(" }"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(QueryPackId), out propertyOverride); + if (Optional.IsDefined(QueryPackId) || hasPropertyOverride) + { + builder.Append(" queryPackId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{QueryPackId.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); + if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) + { + builder.Append(" timeCreated: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ModifiedOn), out propertyOverride); + if (Optional.IsDefined(ModifiedOn) || hasPropertyOverride) + { + builder.Append(" timeModified: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(ModifiedOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); + if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) + { + builder.Append(" provisioningState: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ProvisioningState.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ProvisioningState}'''"); + } + else + { + builder.AppendLine($"'{ProvisioningState}'"); + } + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -250,6 +476,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterO { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(LogAnalyticsQueryPackData)} does not support '{options.Format}' format."); } @@ -266,6 +494,8 @@ LogAnalyticsQueryPackData IPersistableModel.Create(Bi using JsonDocument document = JsonDocument.Parse(data); return DeserializeLogAnalyticsQueryPackData(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(LogAnalyticsQueryPackData)} does not support '{options.Format}' format."); } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/LogAnalyticsQueryPackData.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/LogAnalyticsQueryPackData.cs index b96c3f78209b0..41a37894bc55c 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/LogAnalyticsQueryPackData.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/LogAnalyticsQueryPackData.cs @@ -83,12 +83,16 @@ internal LogAnalyticsQueryPackData() } /// The unique ID of your application. This field cannot be changed. + [WirePath("properties.queryPackId")] public Guid? QueryPackId { get; } /// Creation Date for the Log Analytics QueryPack, in ISO 8601 format. + [WirePath("properties.timeCreated")] public DateTimeOffset? CreatedOn { get; } /// Last modified date of the Log Analytics QueryPack, in ISO 8601 format. + [WirePath("properties.timeModified")] public DateTimeOffset? ModifiedOn { get; } /// Current state of this QueryPack: whether or not is has been provisioned within the resource group it is defined. Users cannot change this value but are able to read from it. Values will include Succeeded, Deploying, Canceled, and Failed. + [WirePath("properties.provisioningState")] public string ProvisioningState { get; } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/ClusterListResult.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/ClusterListResult.Serialization.cs index d12a12be7cf3f..56e484728fb9f 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/ClusterListResult.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/ClusterListResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.OperationalInsights; namespace Azure.ResourceManager.OperationalInsights.Models @@ -114,6 +117,107 @@ internal static ClusterListResult DeserializeClusterListResult(JsonElement eleme return new ClusterListResult(nextLink, value ?? new ChangeTrackingList(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (Optional.IsDefined(NextLink) || hasPropertyOverride) + { + builder.Append(" nextLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -122,6 +226,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions o { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ClusterListResult)} does not support '{options.Format}' format."); } @@ -138,6 +244,8 @@ ClusterListResult IPersistableModel.Create(BinaryData data, M using JsonDocument document = JsonDocument.Parse(data); return DeserializeClusterListResult(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ClusterListResult)} does not support '{options.Format}' format."); } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/DataExportListResult.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/DataExportListResult.Serialization.cs index 1ecc98160a040..2ea6fad0bd3d3 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/DataExportListResult.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/DataExportListResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.OperationalInsights; namespace Azure.ResourceManager.OperationalInsights.Models @@ -103,6 +106,85 @@ internal static DataExportListResult DeserializeDataExportListResult(JsonElement return new DataExportListResult(value ?? new ChangeTrackingList(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -111,6 +193,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOption { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(DataExportListResult)} does not support '{options.Format}' format."); } @@ -127,6 +211,8 @@ DataExportListResult IPersistableModel.Create(BinaryData d using JsonDocument document = JsonDocument.Parse(data); return DeserializeDataExportListResult(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(DataExportListResult)} does not support '{options.Format}' format."); } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/DataSourceListResult.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/DataSourceListResult.Serialization.cs index 690336473d0ba..fdb696a94d336 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/DataSourceListResult.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/DataSourceListResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.OperationalInsights; namespace Azure.ResourceManager.OperationalInsights.Models @@ -114,6 +117,107 @@ internal static DataSourceListResult DeserializeDataSourceListResult(JsonElement return new DataSourceListResult(value ?? new ChangeTrackingList(), nextLink, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (Optional.IsDefined(NextLink) || hasPropertyOverride) + { + builder.Append(" nextLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -122,6 +226,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOption { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(DataSourceListResult)} does not support '{options.Format}' format."); } @@ -138,6 +244,8 @@ DataSourceListResult IPersistableModel.Create(BinaryData d using JsonDocument document = JsonDocument.Parse(data); return DeserializeDataSourceListResult(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(DataSourceListResult)} does not support '{options.Format}' format."); } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/LinkedServiceListResult.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/LinkedServiceListResult.Serialization.cs index fd17529b77fc0..e9bfcddb50639 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/LinkedServiceListResult.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/LinkedServiceListResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.OperationalInsights; namespace Azure.ResourceManager.OperationalInsights.Models @@ -103,6 +106,85 @@ internal static LinkedServiceListResult DeserializeLinkedServiceListResult(JsonE return new LinkedServiceListResult(value ?? new ChangeTrackingList(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -111,6 +193,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpt { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(LinkedServiceListResult)} does not support '{options.Format}' format."); } @@ -127,6 +211,8 @@ LinkedServiceListResult IPersistableModel.Create(Binary using JsonDocument document = JsonDocument.Parse(data); return DeserializeLinkedServiceListResult(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(LinkedServiceListResult)} does not support '{options.Format}' format."); } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/LinkedStorageAccountsListResult.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/LinkedStorageAccountsListResult.Serialization.cs index 38951d3b6f3fd..f6284aabe1119 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/LinkedStorageAccountsListResult.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/LinkedStorageAccountsListResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.OperationalInsights; namespace Azure.ResourceManager.OperationalInsights.Models @@ -103,6 +106,85 @@ internal static LinkedStorageAccountsListResult DeserializeLinkedStorageAccounts return new LinkedStorageAccountsListResult(value ?? new ChangeTrackingList(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -111,6 +193,8 @@ BinaryData IPersistableModel.Write(ModelReaderW { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(LinkedStorageAccountsListResult)} does not support '{options.Format}' format."); } @@ -127,6 +211,8 @@ LinkedStorageAccountsListResult IPersistableModel propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (Optional.IsDefined(NextLink) || hasPropertyOverride) + { + builder.Append(" nextLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -115,6 +219,8 @@ BinaryData IPersistableModel.Write(ModelReaderW { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(LogAnalyticsQueryPackListResult)} does not support '{options.Format}' format."); } @@ -131,6 +237,8 @@ LogAnalyticsQueryPackListResult IPersistableModel tags, IDictionar } /// Resource tags. + [WirePath("tags")] public IDictionary Tags { get; } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/LogAnalyticsQueryPackQueryListResult.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/LogAnalyticsQueryPackQueryListResult.Serialization.cs index 8bdf09be942d6..2789e1e0ea770 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/LogAnalyticsQueryPackQueryListResult.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/LogAnalyticsQueryPackQueryListResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.OperationalInsights; namespace Azure.ResourceManager.OperationalInsights.Models @@ -107,6 +110,107 @@ internal static LogAnalyticsQueryPackQueryListResult DeserializeLogAnalyticsQuer return new LogAnalyticsQueryPackQueryListResult(value, nextLink, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (Optional.IsDefined(NextLink) || hasPropertyOverride) + { + builder.Append(" nextLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -115,6 +219,8 @@ BinaryData IPersistableModel.Write(ModelRe { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(LogAnalyticsQueryPackQueryListResult)} does not support '{options.Format}' format."); } @@ -131,6 +237,8 @@ LogAnalyticsQueryPackQueryListResult IPersistableModel(), resourceTypes ?? new ChangeTrackingList(), solutions ?? new ChangeTrackingList(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Categories), out propertyOverride); + if (Optional.IsCollectionDefined(Categories) || hasPropertyOverride) + { + if (Categories.Any() || hasPropertyOverride) + { + builder.Append(" categories: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Categories) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ResourceTypes), out propertyOverride); + if (Optional.IsCollectionDefined(ResourceTypes) || hasPropertyOverride) + { + if (ResourceTypes.Any() || hasPropertyOverride) + { + builder.Append(" resourceTypes: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in ResourceTypes) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Solutions), out propertyOverride); + if (Optional.IsCollectionDefined(Solutions) || hasPropertyOverride) + { + if (Solutions.Any() || hasPropertyOverride) + { + builder.Append(" solutions: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Solutions) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -161,6 +326,8 @@ BinaryData IPersistableModel.Write(ModelReader { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(LogAnalyticsQueryRelatedMetadata)} does not support '{options.Format}' format."); } @@ -177,6 +344,8 @@ LogAnalyticsQueryRelatedMetadata IPersistableModel categories, IList The related categories for the function. + [WirePath("categories")] public IList Categories { get; } /// The related resource types for the function. + [WirePath("resourceTypes")] public IList ResourceTypes { get; } /// The related Log Analytics solutions for the function. + [WirePath("solutions")] public IList Solutions { get; } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/LogAnalyticsQuerySearchProperties.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/LogAnalyticsQuerySearchProperties.cs index e4b59574c7661..955ae0cdb43cd 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/LogAnalyticsQuerySearchProperties.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/LogAnalyticsQuerySearchProperties.cs @@ -64,8 +64,10 @@ internal LogAnalyticsQuerySearchProperties(LogAnalyticsQuerySearchRelatedMetadat } /// The related metadata items for the function. + [WirePath("related")] public LogAnalyticsQuerySearchRelatedMetadata Related { get; set; } /// Tags associated with the query. + [WirePath("tags")] public IDictionary> Tags { get; } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/LogAnalyticsQuerySearchRelatedMetadata.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/LogAnalyticsQuerySearchRelatedMetadata.cs index 4ad54c2477f54..e8528e2d72fa8 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/LogAnalyticsQuerySearchRelatedMetadata.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/LogAnalyticsQuerySearchRelatedMetadata.cs @@ -68,10 +68,13 @@ internal LogAnalyticsQuerySearchRelatedMetadata(IList categories, IList< } /// The related categories for the function. + [WirePath("categories")] public IList Categories { get; } /// The related resource types for the function. + [WirePath("resourceTypes")] public IList ResourceTypes { get; } /// The related Log Analytics solutions for the function. + [WirePath("solutions")] public IList Solutions { get; } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsAvailableServiceTier.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsAvailableServiceTier.Serialization.cs index a6b6b67b6941e..d568d363ca9ec 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsAvailableServiceTier.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsAvailableServiceTier.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.OperationalInsights; namespace Azure.ResourceManager.OperationalInsights.Models @@ -191,6 +193,163 @@ internal static OperationalInsightsAvailableServiceTier DeserializeOperationalIn serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ServiceTier), out propertyOverride); + if (Optional.IsDefined(ServiceTier) || hasPropertyOverride) + { + builder.Append(" serviceTier: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ServiceTier.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); + if (Optional.IsDefined(IsEnabled) || hasPropertyOverride) + { + builder.Append(" enabled: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsEnabled.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MinimumRetention), out propertyOverride); + if (Optional.IsDefined(MinimumRetention) || hasPropertyOverride) + { + builder.Append(" minimumRetention: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{MinimumRetention.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MaximumRetention), out propertyOverride); + if (Optional.IsDefined(MaximumRetention) || hasPropertyOverride) + { + builder.Append(" maximumRetention: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{MaximumRetention.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DefaultRetention), out propertyOverride); + if (Optional.IsDefined(DefaultRetention) || hasPropertyOverride) + { + builder.Append(" defaultRetention: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{DefaultRetention.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CapacityReservationLevel), out propertyOverride); + if (Optional.IsDefined(CapacityReservationLevel) || hasPropertyOverride) + { + builder.Append(" capacityReservationLevel: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{CapacityReservationLevel.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastSkuUpdatedOn), out propertyOverride); + if (Optional.IsDefined(LastSkuUpdatedOn) || hasPropertyOverride) + { + builder.Append(" lastSkuUpdate: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(LastSkuUpdatedOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -199,6 +358,8 @@ BinaryData IPersistableModel.Write(Mode { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(OperationalInsightsAvailableServiceTier)} does not support '{options.Format}' format."); } @@ -215,6 +376,8 @@ OperationalInsightsAvailableServiceTier IPersistableModel The name of the Service Tier. + [WirePath("serviceTier")] public OperationalInsightsSkuName? ServiceTier { get; } /// True if the Service Tier is enabled for the workspace. + [WirePath("enabled")] public bool? IsEnabled { get; } /// The minimum retention for the Service Tier, in days. + [WirePath("minimumRetention")] public long? MinimumRetention { get; } /// The maximum retention for the Service Tier, in days. + [WirePath("maximumRetention")] public long? MaximumRetention { get; } /// The default retention for the Service Tier, in days. + [WirePath("defaultRetention")] public long? DefaultRetention { get; } /// The capacity reservation level in GB per day. Returned for the Capacity Reservation Service Tier. + [WirePath("capacityReservationLevel")] public long? CapacityReservationLevel { get; } /// Time when the sku was last updated for the workspace. Returned for the Capacity Reservation Service Tier. + [WirePath("lastSkuUpdate")] public DateTimeOffset? LastSkuUpdatedOn { get; } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsCapacityReservationProperties.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsCapacityReservationProperties.Serialization.cs index b22350e451ea3..6074abfd5e8eb 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsCapacityReservationProperties.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsCapacityReservationProperties.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.OperationalInsights; namespace Azure.ResourceManager.OperationalInsights.Models @@ -108,6 +110,92 @@ internal static OperationalInsightsCapacityReservationProperties DeserializeOper return new OperationalInsightsCapacityReservationProperties(lastSkuUpdate, minCapacity, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastSkuUpdatedOn), out propertyOverride); + if (Optional.IsDefined(LastSkuUpdatedOn) || hasPropertyOverride) + { + builder.Append(" lastSkuUpdate: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(LastSkuUpdatedOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MinCapacity), out propertyOverride); + if (Optional.IsDefined(MinCapacity) || hasPropertyOverride) + { + builder.Append(" minCapacity: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{MinCapacity.Value.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -116,6 +204,8 @@ BinaryData IPersistableModel.W { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(OperationalInsightsCapacityReservationProperties)} does not support '{options.Format}' format."); } @@ -132,6 +222,8 @@ OperationalInsightsCapacityReservationProperties IPersistableModel The last time Sku was updated. + [WirePath("lastSkuUpdate")] public DateTimeOffset? LastSkuUpdatedOn { get; } /// Minimum CapacityReservation value in GB. + [WirePath("minCapacity")] public long? MinCapacity { get; } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsClusterAssociatedWorkspace.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsClusterAssociatedWorkspace.Serialization.cs index f37c04942fd3c..ccf81af5c9b93 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsClusterAssociatedWorkspace.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsClusterAssociatedWorkspace.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.OperationalInsights; namespace Azure.ResourceManager.OperationalInsights.Models @@ -134,6 +136,128 @@ internal static OperationalInsightsClusterAssociatedWorkspace DeserializeOperati return new OperationalInsightsClusterAssociatedWorkspace(workspaceId, workspaceName, resourceId, associateDate, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(WorkspaceId), out propertyOverride); + if (Optional.IsDefined(WorkspaceId) || hasPropertyOverride) + { + builder.Append(" workspaceId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{WorkspaceId.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(WorkspaceName), out propertyOverride); + if (Optional.IsDefined(WorkspaceName) || hasPropertyOverride) + { + builder.Append(" workspaceName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (WorkspaceName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{WorkspaceName}'''"); + } + else + { + builder.AppendLine($"'{WorkspaceName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ResourceId), out propertyOverride); + if (Optional.IsDefined(ResourceId) || hasPropertyOverride) + { + builder.Append(" resourceId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ResourceId.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AssociatedOn), out propertyOverride); + if (Optional.IsDefined(AssociatedOn) || hasPropertyOverride) + { + builder.Append(" associateDate: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(AssociatedOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -142,6 +266,8 @@ BinaryData IPersistableModel.Writ { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(OperationalInsightsClusterAssociatedWorkspace)} does not support '{options.Format}' format."); } @@ -158,6 +284,8 @@ OperationalInsightsClusterAssociatedWorkspace IPersistableModel The id of the assigned workspace. + [WirePath("workspaceId")] public Guid? WorkspaceId { get; } /// The name id the assigned workspace. + [WirePath("workspaceName")] public string WorkspaceName { get; } /// The ResourceId id the assigned workspace. + [WirePath("resourceId")] public ResourceIdentifier ResourceId { get; } /// The time of workspace association. + [WirePath("associateDate")] public DateTimeOffset? AssociatedOn { get; } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsClusterPatch.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsClusterPatch.cs index f8524c3aff716..de632dc8b446f 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsClusterPatch.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsClusterPatch.cs @@ -71,14 +71,19 @@ internal OperationalInsightsClusterPatch(ManagedServiceIdentity identity, Operat } /// The identity of the resource. Current supported identity types: None, SystemAssigned, UserAssigned. + [WirePath("identity")] public ManagedServiceIdentity Identity { get; set; } /// The sku properties. + [WirePath("sku")] public OperationalInsightsClusterSku Sku { get; set; } /// Resource tags. + [WirePath("tags")] public IDictionary Tags { get; } /// The associated key properties. + [WirePath("properties.keyVaultProperties")] public OperationalInsightsKeyVaultProperties KeyVaultProperties { get; set; } /// The cluster's billing type. + [WirePath("properties.billingType")] public OperationalInsightsBillingType? BillingType { get; set; } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsColumn.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsColumn.Serialization.cs index 8ac18f4e11c70..e43ff3f95904b 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsColumn.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsColumn.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.OperationalInsights; namespace Azure.ResourceManager.OperationalInsights.Models @@ -179,6 +181,173 @@ internal static OperationalInsightsColumn DeserializeOperationalInsightsColumn(J serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DataTypeHint), out propertyOverride); + if (Optional.IsDefined(DataTypeHint) || hasPropertyOverride) + { + builder.Append(" dataTypeHint: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{DataTypeHint.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayName), out propertyOverride); + if (Optional.IsDefined(DisplayName) || hasPropertyOverride) + { + builder.Append(" displayName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (DisplayName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{DisplayName}'''"); + } + else + { + builder.AppendLine($"'{DisplayName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); + if (Optional.IsDefined(Description) || hasPropertyOverride) + { + builder.Append(" description: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Description.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Description}'''"); + } + else + { + builder.AppendLine($"'{Description}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsDefaultDisplay), out propertyOverride); + if (Optional.IsDefined(IsDefaultDisplay) || hasPropertyOverride) + { + builder.Append(" isDefaultDisplay: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsDefaultDisplay.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsHidden), out propertyOverride); + if (Optional.IsDefined(IsHidden) || hasPropertyOverride) + { + builder.Append(" isHidden: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsHidden.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -187,6 +356,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterO { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(OperationalInsightsColumn)} does not support '{options.Format}' format."); } @@ -203,6 +374,8 @@ OperationalInsightsColumn IPersistableModel.Create(Bi using JsonDocument document = JsonDocument.Parse(data); return DeserializeOperationalInsightsColumn(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(OperationalInsightsColumn)} does not support '{options.Format}' format."); } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsColumn.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsColumn.cs index 8debbe7a958b1..bd74ed9576ca5 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsColumn.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsColumn.cs @@ -72,18 +72,25 @@ internal OperationalInsightsColumn(string name, OperationalInsightsColumnType? c } /// Column name. + [WirePath("name")] public string Name { get; set; } /// Column data type. + [WirePath("type")] public OperationalInsightsColumnType? ColumnType { get; set; } /// Column data type logical hint. + [WirePath("dataTypeHint")] public OperationalInsightsColumnDataTypeHint? DataTypeHint { get; set; } /// Column display name. + [WirePath("displayName")] public string DisplayName { get; set; } /// Column description. + [WirePath("description")] public string Description { get; set; } /// Is displayed by default. + [WirePath("isDefaultDisplay")] public bool? IsDefaultDisplay { get; } /// Is column hidden. + [WirePath("isHidden")] public bool? IsHidden { get; } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsIntelligencePack.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsIntelligencePack.Serialization.cs index 46c026aa67b75..d7d4dcf43ffae 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsIntelligencePack.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsIntelligencePack.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.OperationalInsights; namespace Azure.ResourceManager.OperationalInsights.Models @@ -115,6 +117,122 @@ internal static OperationalInsightsIntelligencePack DeserializeOperationalInsigh return new OperationalInsightsIntelligencePack(name, enabled, displayName, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); + if (Optional.IsDefined(IsEnabled) || hasPropertyOverride) + { + builder.Append(" enabled: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsEnabled.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayName), out propertyOverride); + if (Optional.IsDefined(DisplayName) || hasPropertyOverride) + { + builder.Append(" displayName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (DisplayName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{DisplayName}'''"); + } + else + { + builder.AppendLine($"'{DisplayName}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -123,6 +241,8 @@ BinaryData IPersistableModel.Write(ModelRea { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(OperationalInsightsIntelligencePack)} does not support '{options.Format}' format."); } @@ -139,6 +259,8 @@ OperationalInsightsIntelligencePack IPersistableModel The name of the intelligence pack. + [WirePath("name")] public string Name { get; } /// The enabled boolean for the intelligence pack. + [WirePath("enabled")] public bool? IsEnabled { get; } /// The display name of the intelligence pack. + [WirePath("displayName")] public string DisplayName { get; } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsKeyVaultProperties.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsKeyVaultProperties.Serialization.cs index e4d2d5b81d4e6..4611f0c26748b 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsKeyVaultProperties.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsKeyVaultProperties.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.OperationalInsights; namespace Azure.ResourceManager.OperationalInsights.Models @@ -130,6 +132,135 @@ internal static OperationalInsightsKeyVaultProperties DeserializeOperationalInsi return new OperationalInsightsKeyVaultProperties(keyVaultUri, keyName, keyVersion, keyRsaSize, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyVaultUri), out propertyOverride); + if (Optional.IsDefined(KeyVaultUri) || hasPropertyOverride) + { + builder.Append(" keyVaultUri: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{KeyVaultUri.AbsoluteUri}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyName), out propertyOverride); + if (Optional.IsDefined(KeyName) || hasPropertyOverride) + { + builder.Append(" keyName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (KeyName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{KeyName}'''"); + } + else + { + builder.AppendLine($"'{KeyName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyVersion), out propertyOverride); + if (Optional.IsDefined(KeyVersion) || hasPropertyOverride) + { + builder.Append(" keyVersion: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (KeyVersion.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{KeyVersion}'''"); + } + else + { + builder.AppendLine($"'{KeyVersion}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyRsaSize), out propertyOverride); + if (Optional.IsDefined(KeyRsaSize) || hasPropertyOverride) + { + builder.Append(" keyRsaSize: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{KeyRsaSize.Value}"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -138,6 +269,8 @@ BinaryData IPersistableModel.Write(ModelR { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(OperationalInsightsKeyVaultProperties)} does not support '{options.Format}' format."); } @@ -154,6 +287,8 @@ OperationalInsightsKeyVaultProperties IPersistableModel The Key Vault uri which holds they key associated with the Log Analytics cluster. + [WirePath("keyVaultUri")] public Uri KeyVaultUri { get; set; } /// The name of the key associated with the Log Analytics cluster. + [WirePath("keyName")] public string KeyName { get; set; } /// The version of the key associated with the Log Analytics cluster. + [WirePath("keyVersion")] public string KeyVersion { get; set; } /// Selected key minimum required size. + [WirePath("keyRsaSize")] public int? KeyRsaSize { get; set; } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsManagementGroup.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsManagementGroup.Serialization.cs index 84c3bd86edc84..d66288d7d7306 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsManagementGroup.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsManagementGroup.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.OperationalInsights; namespace Azure.ResourceManager.OperationalInsights.Models @@ -206,6 +208,213 @@ internal static OperationalInsightsManagementGroup DeserializeOperationalInsight serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ServerCount), out propertyOverride); + if (Optional.IsDefined(ServerCount) || hasPropertyOverride) + { + builder.Append(" serverCount: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{ServerCount.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsGateway), out propertyOverride); + if (Optional.IsDefined(IsGateway) || hasPropertyOverride) + { + builder.Append(" isGateway: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsGateway.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Id.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Id}'''"); + } + else + { + builder.AppendLine($"'{Id}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); + if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) + { + builder.Append(" created: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DataReceivedOn), out propertyOverride); + if (Optional.IsDefined(DataReceivedOn) || hasPropertyOverride) + { + builder.Append(" dataReceived: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(DataReceivedOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Version), out propertyOverride); + if (Optional.IsDefined(Version) || hasPropertyOverride) + { + builder.Append(" version: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Version.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Version}'''"); + } + else + { + builder.AppendLine($"'{Version}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Sku), out propertyOverride); + if (Optional.IsDefined(Sku) || hasPropertyOverride) + { + builder.Append(" sku: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Sku.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Sku}'''"); + } + else + { + builder.AppendLine($"'{Sku}'"); + } + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -214,6 +423,8 @@ BinaryData IPersistableModel.Write(ModelRead { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(OperationalInsightsManagementGroup)} does not support '{options.Format}' format."); } @@ -230,6 +441,8 @@ OperationalInsightsManagementGroup IPersistableModel The number of servers connected to the management group. + [WirePath("properties.serverCount")] public int? ServerCount { get; } /// Gets or sets a value indicating whether the management group is a gateway. + [WirePath("properties.isGateway")] public bool? IsGateway { get; } /// The name of the management group. + [WirePath("properties.name")] public string Name { get; } /// The unique ID of the management group. + [WirePath("properties.id")] public string Id { get; } /// The datetime that the management group was created. + [WirePath("properties.created")] public DateTimeOffset? CreatedOn { get; } /// The last datetime that the management group received data. + [WirePath("properties.dataReceived")] public DateTimeOffset? DataReceivedOn { get; } /// The version of System Center that is managing the management group. + [WirePath("properties.version")] public string Version { get; } /// The SKU of System Center that is managing the management group. + [WirePath("properties.sku")] public string Sku { get; } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsMetricName.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsMetricName.Serialization.cs index 99edf3e1269ef..ff96286b911a2 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsMetricName.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsMetricName.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.OperationalInsights; namespace Azure.ResourceManager.OperationalInsights.Models @@ -100,6 +102,107 @@ internal static OperationalInsightsMetricName DeserializeOperationalInsightsMetr return new OperationalInsightsMetricName(value, localizedValue, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsDefined(Value) || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Value}'''"); + } + else + { + builder.AppendLine($"'{Value}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LocalizedValue), out propertyOverride); + if (Optional.IsDefined(LocalizedValue) || hasPropertyOverride) + { + builder.Append(" localizedValue: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (LocalizedValue.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{LocalizedValue}'''"); + } + else + { + builder.AppendLine($"'{LocalizedValue}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -108,6 +211,8 @@ BinaryData IPersistableModel.Write(ModelReaderWri { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(OperationalInsightsMetricName)} does not support '{options.Format}' format."); } @@ -124,6 +229,8 @@ OperationalInsightsMetricName IPersistableModel.C using JsonDocument document = JsonDocument.Parse(data); return DeserializeOperationalInsightsMetricName(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(OperationalInsightsMetricName)} does not support '{options.Format}' format."); } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsMetricName.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsMetricName.cs index 46de8fe8de14f..261656ab949f4 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsMetricName.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsMetricName.cs @@ -62,8 +62,10 @@ internal OperationalInsightsMetricName(string value, string localizedValue, IDic } /// The system name of the metric. + [WirePath("value")] public string Value { get; } /// The localized name of the metric. + [WirePath("localizedValue")] public string LocalizedValue { get; } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsPrivateLinkScopedResourceInfo.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsPrivateLinkScopedResourceInfo.Serialization.cs index 7deb4bc64280d..ba3961619261e 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsPrivateLinkScopedResourceInfo.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsPrivateLinkScopedResourceInfo.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.OperationalInsights; namespace Azure.ResourceManager.OperationalInsights.Models @@ -104,6 +106,99 @@ internal static OperationalInsightsPrivateLinkScopedResourceInfo DeserializeOper return new OperationalInsightsPrivateLinkScopedResourceInfo(resourceId, scopeId, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ResourceId), out propertyOverride); + if (Optional.IsDefined(ResourceId) || hasPropertyOverride) + { + builder.Append(" resourceId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ResourceId.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ScopeId), out propertyOverride); + if (Optional.IsDefined(ScopeId) || hasPropertyOverride) + { + builder.Append(" scopeId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ScopeId.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ScopeId}'''"); + } + else + { + builder.AppendLine($"'{ScopeId}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -112,6 +207,8 @@ BinaryData IPersistableModel.W { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(OperationalInsightsPrivateLinkScopedResourceInfo)} does not support '{options.Format}' format."); } @@ -128,6 +225,8 @@ OperationalInsightsPrivateLinkScopedResourceInfo IPersistableModel The full resource Id of the private link scope resource. + [WirePath("resourceId")] public ResourceIdentifier ResourceId { get; } /// The private link scope unique Identifier. + [WirePath("scopeId")] public string ScopeId { get; } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsSchema.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsSchema.Serialization.cs index 3a917fab62b92..4fda36c230937 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsSchema.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsSchema.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.OperationalInsights; namespace Azure.ResourceManager.OperationalInsights.Models @@ -293,6 +296,320 @@ internal static OperationalInsightsSchema DeserializeOperationalInsightsSchema(J serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayName), out propertyOverride); + if (Optional.IsDefined(DisplayName) || hasPropertyOverride) + { + builder.Append(" displayName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (DisplayName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{DisplayName}'''"); + } + else + { + builder.AppendLine($"'{DisplayName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); + if (Optional.IsDefined(Description) || hasPropertyOverride) + { + builder.Append(" description: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Description.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Description}'''"); + } + else + { + builder.AppendLine($"'{Description}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Columns), out propertyOverride); + if (Optional.IsCollectionDefined(Columns) || hasPropertyOverride) + { + if (Columns.Any() || hasPropertyOverride) + { + builder.Append(" columns: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Columns) + { + AppendChildObject(builder, item, options, 4, true, " columns: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StandardColumns), out propertyOverride); + if (Optional.IsCollectionDefined(StandardColumns) || hasPropertyOverride) + { + if (StandardColumns.Any() || hasPropertyOverride) + { + builder.Append(" standardColumns: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in StandardColumns) + { + AppendChildObject(builder, item, options, 4, true, " standardColumns: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Categories), out propertyOverride); + if (Optional.IsCollectionDefined(Categories) || hasPropertyOverride) + { + if (Categories.Any() || hasPropertyOverride) + { + builder.Append(" categories: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Categories) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Labels), out propertyOverride); + if (Optional.IsCollectionDefined(Labels) || hasPropertyOverride) + { + if (Labels.Any() || hasPropertyOverride) + { + builder.Append(" labels: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Labels) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Source), out propertyOverride); + if (Optional.IsDefined(Source) || hasPropertyOverride) + { + builder.Append(" source: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Source.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TableType), out propertyOverride); + if (Optional.IsDefined(TableType) || hasPropertyOverride) + { + builder.Append(" tableType: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{TableType.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TableSubType), out propertyOverride); + if (Optional.IsDefined(TableSubType) || hasPropertyOverride) + { + builder.Append(" tableSubType: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{TableSubType.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Solutions), out propertyOverride); + if (Optional.IsCollectionDefined(Solutions) || hasPropertyOverride) + { + if (Solutions.Any() || hasPropertyOverride) + { + builder.Append(" solutions: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Solutions) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -301,6 +618,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterO { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(OperationalInsightsSchema)} does not support '{options.Format}' format."); } @@ -317,6 +636,8 @@ OperationalInsightsSchema IPersistableModel.Create(Bi using JsonDocument document = JsonDocument.Parse(data); return DeserializeOperationalInsightsSchema(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(OperationalInsightsSchema)} does not support '{options.Format}' format."); } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsSchema.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsSchema.cs index 8ebd321858e30..42521c891b910 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsSchema.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsSchema.cs @@ -86,26 +86,37 @@ internal OperationalInsightsSchema(string name, string displayName, string descr } /// Table name. + [WirePath("name")] public string Name { get; set; } /// Table display name. + [WirePath("displayName")] public string DisplayName { get; set; } /// Table description. + [WirePath("description")] public string Description { get; set; } /// A list of table custom columns. + [WirePath("columns")] public IList Columns { get; } /// A list of table standard columns. + [WirePath("standardColumns")] public IReadOnlyList StandardColumns { get; } /// Table category. + [WirePath("categories")] public IReadOnlyList Categories { get; } /// Table labels. + [WirePath("labels")] public IReadOnlyList Labels { get; } /// Table's creator. + [WirePath("source")] public OperationalInsightsTableCreator? Source { get; } /// Table's creator. + [WirePath("tableType")] public OperationalInsightsTableType? TableType { get; } /// The subtype describes what APIs can be used to interact with the table, and what features are available against it. + [WirePath("tableSubType")] public OperationalInsightsTableSubType? TableSubType { get; } /// List of solutions the table is affiliated with. + [WirePath("solutions")] public IReadOnlyList Solutions { get; } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsSearchCoreSummary.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsSearchCoreSummary.Serialization.cs index 1a2df64298420..0519ebc48f53f 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsSearchCoreSummary.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsSearchCoreSummary.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.OperationalInsights; namespace Azure.ResourceManager.OperationalInsights.Models @@ -97,6 +99,96 @@ internal static OperationalInsightsSearchCoreSummary DeserializeOperationalInsig return new OperationalInsightsSearchCoreSummary(status, numberOfDocuments, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); + if (Optional.IsDefined(Status) || hasPropertyOverride) + { + builder.Append(" status: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Status.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Status}'''"); + } + else + { + builder.AppendLine($"'{Status}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NumberOfDocuments), out propertyOverride); + builder.Append(" numberOfDocuments: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{NumberOfDocuments.ToString()}'"); + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -105,6 +197,8 @@ BinaryData IPersistableModel.Write(ModelRe { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(OperationalInsightsSearchCoreSummary)} does not support '{options.Format}' format."); } @@ -121,6 +215,8 @@ OperationalInsightsSearchCoreSummary IPersistableModel The status of a core summary. + [WirePath("status")] public string Status { get; } /// The number of documents of a core summary. + [WirePath("numberOfDocuments")] public long NumberOfDocuments { get; } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsSearchSchemaValue.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsSearchSchemaValue.Serialization.cs index a45de7d4a086a..c5ce036bd025e 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsSearchSchemaValue.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsSearchSchemaValue.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.OperationalInsights; namespace Azure.ResourceManager.OperationalInsights.Models @@ -168,6 +171,178 @@ internal static OperationalInsightsSearchSchemaValue DeserializeOperationalInsig serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayName), out propertyOverride); + if (Optional.IsDefined(DisplayName) || hasPropertyOverride) + { + builder.Append(" displayName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (DisplayName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{DisplayName}'''"); + } + else + { + builder.AppendLine($"'{DisplayName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Indexed), out propertyOverride); + builder.Append(" indexed: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = Indexed == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Stored), out propertyOverride); + builder.Append(" stored: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = Stored == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Facet), out propertyOverride); + builder.Append(" facet: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = Facet == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(OwnerType), out propertyOverride); + if (Optional.IsCollectionDefined(OwnerType) || hasPropertyOverride) + { + if (OwnerType.Any() || hasPropertyOverride) + { + builder.Append(" ownerType: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in OwnerType) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -176,6 +351,8 @@ BinaryData IPersistableModel.Write(ModelRe { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(OperationalInsightsSearchSchemaValue)} does not support '{options.Format}' format."); } @@ -192,6 +369,8 @@ OperationalInsightsSearchSchemaValue IPersistableModel The name of the schema. + [WirePath("name")] public string Name { get; } /// The display name of the schema. + [WirePath("displayName")] public string DisplayName { get; } /// The type. + [WirePath("type")] public string SearchSchemaValueType { get; } /// The boolean that indicates the field is searchable as free text. + [WirePath("indexed")] public bool Indexed { get; } /// The boolean that indicates whether or not the field is stored. + [WirePath("stored")] public bool Stored { get; } /// The boolean that indicates whether or not the field is a facet. + [WirePath("facet")] public bool Facet { get; } /// The array of workflows containing the field. + [WirePath("ownerType")] public IReadOnlyList OwnerType { get; } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsStorageAccount.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsStorageAccount.Serialization.cs index d09048eff4445..8645d2cb7935d 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsStorageAccount.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsStorageAccount.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; +using Azure.ResourceManager.OperationalInsights; namespace Azure.ResourceManager.OperationalInsights.Models { @@ -93,6 +96,99 @@ internal static OperationalInsightsStorageAccount DeserializeOperationalInsights return new OperationalInsightsStorageAccount(id, key, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Key), out propertyOverride); + if (Optional.IsDefined(Key) || hasPropertyOverride) + { + builder.Append(" key: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Key.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Key}'''"); + } + else + { + builder.AppendLine($"'{Key}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -101,6 +197,8 @@ BinaryData IPersistableModel.Write(ModelReade { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(OperationalInsightsStorageAccount)} does not support '{options.Format}' format."); } @@ -117,6 +215,8 @@ OperationalInsightsStorageAccount IPersistableModel The Azure Resource Manager ID of the storage account resource. + [WirePath("id")] public ResourceIdentifier Id { get; set; } /// The storage account key. + [WirePath("key")] public string Key { get; set; } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsTableRestoredLogs.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsTableRestoredLogs.Serialization.cs index f033044d4841d..0b3045a6aeec1 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsTableRestoredLogs.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsTableRestoredLogs.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.OperationalInsights; namespace Azure.ResourceManager.OperationalInsights.Models @@ -134,6 +136,129 @@ internal static OperationalInsightsTableRestoredLogs DeserializeOperationalInsig return new OperationalInsightsTableRestoredLogs(startRestoreTime, endRestoreTime, sourceTable, azureAsyncOperationId, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartRestoreOn), out propertyOverride); + if (Optional.IsDefined(StartRestoreOn) || hasPropertyOverride) + { + builder.Append(" startRestoreTime: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(StartRestoreOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EndRestoreOn), out propertyOverride); + if (Optional.IsDefined(EndRestoreOn) || hasPropertyOverride) + { + builder.Append(" endRestoreTime: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(EndRestoreOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SourceTable), out propertyOverride); + if (Optional.IsDefined(SourceTable) || hasPropertyOverride) + { + builder.Append(" sourceTable: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (SourceTable.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{SourceTable}'''"); + } + else + { + builder.AppendLine($"'{SourceTable}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AzureAsyncOperationId), out propertyOverride); + if (Optional.IsDefined(AzureAsyncOperationId) || hasPropertyOverride) + { + builder.Append(" azureAsyncOperationId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{AzureAsyncOperationId.Value.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -142,6 +267,8 @@ BinaryData IPersistableModel.Write(ModelRe { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(OperationalInsightsTableRestoredLogs)} does not support '{options.Format}' format."); } @@ -158,6 +285,8 @@ OperationalInsightsTableRestoredLogs IPersistableModel The timestamp to start the restore from (UTC). + [WirePath("startRestoreTime")] public DateTimeOffset? StartRestoreOn { get; set; } /// The timestamp to end the restore by (UTC). + [WirePath("endRestoreTime")] public DateTimeOffset? EndRestoreOn { get; set; } /// The table to restore data from. + [WirePath("sourceTable")] public string SourceTable { get; set; } /// Search results table async operation id. + [WirePath("azureAsyncOperationId")] public Guid? AzureAsyncOperationId { get; } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsTableResultStatistics.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsTableResultStatistics.Serialization.cs index 317ccf6d77956..f35c9b0a6d388 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsTableResultStatistics.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsTableResultStatistics.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.OperationalInsights; namespace Azure.ResourceManager.OperationalInsights.Models @@ -123,6 +125,105 @@ internal static OperationalInsightsTableResultStatistics DeserializeOperationalI return new OperationalInsightsTableResultStatistics(progress, ingestedRecords, scannedGb, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Progress), out propertyOverride); + if (Optional.IsDefined(Progress) || hasPropertyOverride) + { + builder.Append(" progress: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Progress.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IngestedRecords), out propertyOverride); + if (Optional.IsDefined(IngestedRecords) || hasPropertyOverride) + { + builder.Append(" ingestedRecords: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{IngestedRecords.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ScannedGB), out propertyOverride); + if (Optional.IsDefined(ScannedGB) || hasPropertyOverride) + { + builder.Append(" scannedGb: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ScannedGB.Value.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -131,6 +232,8 @@ BinaryData IPersistableModel.Write(Mod { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(OperationalInsightsTableResultStatistics)} does not support '{options.Format}' format."); } @@ -147,6 +250,8 @@ OperationalInsightsTableResultStatistics IPersistableModel Search job completion percentage. + [WirePath("progress")] public float? Progress { get; } /// The number of rows that were returned by the search job. + [WirePath("ingestedRecords")] public int? IngestedRecords { get; } /// Search job: Amount of scanned data. + [WirePath("scannedGb")] public float? ScannedGB { get; } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsTableSearchResults.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsTableSearchResults.Serialization.cs index 5e44f7e63556b..6861bf6d26ff7 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsTableSearchResults.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsTableSearchResults.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.OperationalInsights; namespace Azure.ResourceManager.OperationalInsights.Models @@ -179,6 +181,187 @@ internal static OperationalInsightsTableSearchResults DeserializeOperationalInsi serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Query), out propertyOverride); + if (Optional.IsDefined(Query) || hasPropertyOverride) + { + builder.Append(" query: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Query.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Query}'''"); + } + else + { + builder.AppendLine($"'{Query}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); + if (Optional.IsDefined(Description) || hasPropertyOverride) + { + builder.Append(" description: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Description.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Description}'''"); + } + else + { + builder.AppendLine($"'{Description}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Limit), out propertyOverride); + if (Optional.IsDefined(Limit) || hasPropertyOverride) + { + builder.Append(" limit: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{Limit.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartSearchOn), out propertyOverride); + if (Optional.IsDefined(StartSearchOn) || hasPropertyOverride) + { + builder.Append(" startSearchTime: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(StartSearchOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EndSearchOn), out propertyOverride); + if (Optional.IsDefined(EndSearchOn) || hasPropertyOverride) + { + builder.Append(" endSearchTime: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(EndSearchOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SourceTable), out propertyOverride); + if (Optional.IsDefined(SourceTable) || hasPropertyOverride) + { + builder.Append(" sourceTable: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (SourceTable.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{SourceTable}'''"); + } + else + { + builder.AppendLine($"'{SourceTable}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AzureAsyncOperationId), out propertyOverride); + if (Optional.IsDefined(AzureAsyncOperationId) || hasPropertyOverride) + { + builder.Append(" azureAsyncOperationId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{AzureAsyncOperationId.Value.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -187,6 +370,8 @@ BinaryData IPersistableModel.Write(ModelR { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(OperationalInsightsTableSearchResults)} does not support '{options.Format}' format."); } @@ -203,6 +388,8 @@ OperationalInsightsTableSearchResults IPersistableModel Search job query. + [WirePath("query")] public string Query { get; set; } /// Search job Description. + [WirePath("description")] public string Description { get; set; } /// Limit the search job to return up to specified number of rows. + [WirePath("limit")] public int? Limit { get; set; } /// The timestamp to start the search from (UTC). + [WirePath("startSearchTime")] public DateTimeOffset? StartSearchOn { get; set; } /// The timestamp to end the search by (UTC). + [WirePath("endSearchTime")] public DateTimeOffset? EndSearchOn { get; set; } /// The table used in the search job. + [WirePath("sourceTable")] public string SourceTable { get; } /// Search results table async operation id. + [WirePath("azureAsyncOperationId")] public Guid? AzureAsyncOperationId { get; } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsTag.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsTag.Serialization.cs index e327d7415e19f..fb5e1d83a28f3 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsTag.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsTag.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; +using Azure.ResourceManager.OperationalInsights; namespace Azure.ResourceManager.OperationalInsights.Models { @@ -93,6 +96,107 @@ internal static OperationalInsightsTag DeserializeOperationalInsightsTag(JsonEle return new OperationalInsightsTag(name, value, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsDefined(Value) || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Value}'''"); + } + else + { + builder.AppendLine($"'{Value}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -101,6 +205,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpti { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(OperationalInsightsTag)} does not support '{options.Format}' format."); } @@ -117,6 +223,8 @@ OperationalInsightsTag IPersistableModel.Create(BinaryDa using JsonDocument document = JsonDocument.Parse(data); return DeserializeOperationalInsightsTag(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(OperationalInsightsTag)} does not support '{options.Format}' format."); } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsTag.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsTag.cs index ce122806ff1db..93cc9af06466c 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsTag.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsTag.cs @@ -76,8 +76,10 @@ internal OperationalInsightsTag() } /// The tag name. + [WirePath("name")] public string Name { get; set; } /// The tag value. + [WirePath("value")] public string Value { get; set; } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsUsageMetric.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsUsageMetric.Serialization.cs index c0ccd8d23fbc6..6c63f84c88789 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsUsageMetric.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsUsageMetric.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.OperationalInsights; namespace Azure.ResourceManager.OperationalInsights.Models @@ -167,6 +169,164 @@ internal static OperationalInsightsUsageMetric DeserializeOperationalInsightsUsa serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Name, options, 2, false, " name: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Unit), out propertyOverride); + if (Optional.IsDefined(Unit) || hasPropertyOverride) + { + builder.Append(" unit: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Unit.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Unit}'''"); + } + else + { + builder.AppendLine($"'{Unit}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CurrentValue), out propertyOverride); + if (Optional.IsDefined(CurrentValue) || hasPropertyOverride) + { + builder.Append(" currentValue: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{CurrentValue.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Limit), out propertyOverride); + if (Optional.IsDefined(Limit) || hasPropertyOverride) + { + builder.Append(" limit: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Limit.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextResetOn), out propertyOverride); + if (Optional.IsDefined(NextResetOn) || hasPropertyOverride) + { + builder.Append(" nextResetTime: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(NextResetOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(QuotaPeriod), out propertyOverride); + if (Optional.IsDefined(QuotaPeriod) || hasPropertyOverride) + { + builder.Append(" quotaPeriod: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (QuotaPeriod.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{QuotaPeriod}'''"); + } + else + { + builder.AppendLine($"'{QuotaPeriod}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -175,6 +335,8 @@ BinaryData IPersistableModel.Write(ModelReaderWr { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(OperationalInsightsUsageMetric)} does not support '{options.Format}' format."); } @@ -191,6 +353,8 @@ OperationalInsightsUsageMetric IPersistableModel using JsonDocument document = JsonDocument.Parse(data); return DeserializeOperationalInsightsUsageMetric(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(OperationalInsightsUsageMetric)} does not support '{options.Format}' format."); } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsUsageMetric.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsUsageMetric.cs index 7c56ef4cc30f1..b4b23b41cacf0 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsUsageMetric.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsUsageMetric.cs @@ -70,16 +70,22 @@ internal OperationalInsightsUsageMetric(OperationalInsightsMetricName name, stri } /// The name of the metric. + [WirePath("name")] public OperationalInsightsMetricName Name { get; } /// The units used for the metric. + [WirePath("unit")] public string Unit { get; } /// The current value of the metric. + [WirePath("currentValue")] public double? CurrentValue { get; } /// The quota limit for the metric. + [WirePath("limit")] public double? Limit { get; } /// The time that the metric's value will reset. + [WirePath("nextResetTime")] public DateTimeOffset? NextResetOn { get; } /// The quota period that determines the length of time between value resets. + [WirePath("quotaPeriod")] public string QuotaPeriod { get; } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspaceCapping.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspaceCapping.Serialization.cs index f950669335fb6..18bc295171fa9 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspaceCapping.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspaceCapping.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.OperationalInsights; namespace Azure.ResourceManager.OperationalInsights.Models @@ -119,6 +121,113 @@ internal static OperationalInsightsWorkspaceCapping DeserializeOperationalInsigh return new OperationalInsightsWorkspaceCapping(dailyQuotaGb, quotaNextResetTime, dataIngestionStatus, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DailyQuotaInGB), out propertyOverride); + if (Optional.IsDefined(DailyQuotaInGB) || hasPropertyOverride) + { + builder.Append(" dailyQuotaGb: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{DailyQuotaInGB.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(QuotaNextResetTime), out propertyOverride); + if (Optional.IsDefined(QuotaNextResetTime) || hasPropertyOverride) + { + builder.Append(" quotaNextResetTime: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (QuotaNextResetTime.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{QuotaNextResetTime}'''"); + } + else + { + builder.AppendLine($"'{QuotaNextResetTime}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DataIngestionStatus), out propertyOverride); + if (Optional.IsDefined(DataIngestionStatus) || hasPropertyOverride) + { + builder.Append(" dataIngestionStatus: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{DataIngestionStatus.Value.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -127,6 +236,8 @@ BinaryData IPersistableModel.Write(ModelRea { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(OperationalInsightsWorkspaceCapping)} does not support '{options.Format}' format."); } @@ -143,6 +254,8 @@ OperationalInsightsWorkspaceCapping IPersistableModel The workspace daily quota for ingestion. + [WirePath("dailyQuotaGb")] public double? DailyQuotaInGB { get; set; } /// The time when the quota will be rest. + [WirePath("quotaNextResetTime")] public string QuotaNextResetTime { get; } /// The status of data ingestion for this workspace. + [WirePath("dataIngestionStatus")] public OperationalInsightsDataIngestionStatus? DataIngestionStatus { get; } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspaceFeatures.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspaceFeatures.Serialization.cs index b6040f2f8f74a..039a5372f5264 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspaceFeatures.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspaceFeatures.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.OperationalInsights; namespace Azure.ResourceManager.OperationalInsights.Models @@ -193,6 +195,137 @@ internal static OperationalInsightsWorkspaceFeatures DeserializeOperationalInsig additionalProperties); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsDataExportEnabled), out propertyOverride); + if (Optional.IsDefined(IsDataExportEnabled) || hasPropertyOverride) + { + builder.Append(" enableDataExport: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsDataExportEnabled.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ImmediatePurgeDataOn30Days), out propertyOverride); + if (Optional.IsDefined(ImmediatePurgeDataOn30Days) || hasPropertyOverride) + { + builder.Append(" immediatePurgeDataOn30Days: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = ImmediatePurgeDataOn30Days.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsLogAccessUsingOnlyResourcePermissionsEnabled), out propertyOverride); + if (Optional.IsDefined(IsLogAccessUsingOnlyResourcePermissionsEnabled) || hasPropertyOverride) + { + builder.Append(" enableLogAccessUsingOnlyResourcePermissions: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsLogAccessUsingOnlyResourcePermissionsEnabled.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ClusterResourceId), out propertyOverride); + if (Optional.IsDefined(ClusterResourceId) || hasPropertyOverride) + { + builder.Append(" clusterResourceId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ClusterResourceId.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsLocalAuthDisabled), out propertyOverride); + if (Optional.IsDefined(IsLocalAuthDisabled) || hasPropertyOverride) + { + builder.Append(" disableLocalAuth: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsLocalAuthDisabled.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -201,6 +334,8 @@ BinaryData IPersistableModel.Write(ModelRe { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(OperationalInsightsWorkspaceFeatures)} does not support '{options.Format}' format."); } @@ -217,6 +352,8 @@ OperationalInsightsWorkspaceFeatures IPersistableModel Flag that indicate if data should be exported. + [WirePath("enableDataExport")] public bool? IsDataExportEnabled { get; set; } /// Flag that describes if we want to remove the data after 30 days. + [WirePath("immediatePurgeDataOn30Days")] public bool? ImmediatePurgeDataOn30Days { get; set; } /// Flag that indicate which permission to use - resource or workspace or both. + [WirePath("enableLogAccessUsingOnlyResourcePermissions")] public bool? IsLogAccessUsingOnlyResourcePermissionsEnabled { get; set; } /// Dedicated LA cluster resourceId that is linked to the workspaces. + [WirePath("clusterResourceId")] public ResourceIdentifier ClusterResourceId { get; set; } /// Disable Non-AAD based Auth. + [WirePath("disableLocalAuth")] public bool? IsLocalAuthDisabled { get; set; } /// /// Additional Properties @@ -77,6 +82,7 @@ internal OperationalInsightsWorkspaceFeatures(bool? isDataExportEnabled, bool? i /// /// /// + [WirePath("AdditionalProperties")] public IDictionary AdditionalProperties { get; } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspacePatch.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspacePatch.Serialization.cs index a309e7be772a5..ad2c8fb6986c3 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspacePatch.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspacePatch.Serialization.cs @@ -8,9 +8,12 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.Models; using Azure.ResourceManager.OperationalInsights; @@ -433,6 +436,373 @@ internal static OperationalInsightsWorkspacePatch DeserializeOperationalInsights serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tags), out propertyOverride); + if (Optional.IsCollectionDefined(Tags) || hasPropertyOverride) + { + if (Tags.Any() || hasPropertyOverride) + { + builder.Append(" tags: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("{"); + foreach (var item in Tags) + { + builder.Append($" '{item.Key}': "); + if (item.Value == null) + { + builder.Append("null"); + continue; + } + if (item.Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{item.Value}'''"); + } + else + { + builder.AppendLine($"'{item.Value}'"); + } + } + builder.AppendLine(" }"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Identity), out propertyOverride); + if (Optional.IsDefined(Identity) || hasPropertyOverride) + { + builder.Append(" identity: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Identity, options, 2, false, " identity: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ETag), out propertyOverride); + if (Optional.IsDefined(ETag) || hasPropertyOverride) + { + builder.Append(" etag: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ETag.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); + if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) + { + builder.Append(" provisioningState: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ProvisioningState.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CustomerId), out propertyOverride); + if (Optional.IsDefined(CustomerId) || hasPropertyOverride) + { + builder.Append(" customerId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{CustomerId.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Sku), out propertyOverride); + if (Optional.IsDefined(Sku) || hasPropertyOverride) + { + builder.Append(" sku: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Sku, options, 4, false, " sku: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RetentionInDays), out propertyOverride); + if (Optional.IsDefined(RetentionInDays) || hasPropertyOverride) + { + builder.Append(" retentionInDays: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{RetentionInDays.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(WorkspaceCapping), out propertyOverride); + if (Optional.IsDefined(WorkspaceCapping) || hasPropertyOverride) + { + builder.Append(" workspaceCapping: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, WorkspaceCapping, options, 4, false, " workspaceCapping: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); + if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) + { + builder.Append(" createdDate: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ModifiedOn), out propertyOverride); + if (Optional.IsDefined(ModifiedOn) || hasPropertyOverride) + { + builder.Append(" modifiedDate: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(ModifiedOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PublicNetworkAccessForIngestion), out propertyOverride); + if (Optional.IsDefined(PublicNetworkAccessForIngestion) || hasPropertyOverride) + { + builder.Append(" publicNetworkAccessForIngestion: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{PublicNetworkAccessForIngestion.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PublicNetworkAccessForQuery), out propertyOverride); + if (Optional.IsDefined(PublicNetworkAccessForQuery) || hasPropertyOverride) + { + builder.Append(" publicNetworkAccessForQuery: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{PublicNetworkAccessForQuery.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ForceCmkForQuery), out propertyOverride); + if (Optional.IsDefined(ForceCmkForQuery) || hasPropertyOverride) + { + builder.Append(" forceCmkForQuery: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = ForceCmkForQuery.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrivateLinkScopedResources), out propertyOverride); + if (Optional.IsCollectionDefined(PrivateLinkScopedResources) || hasPropertyOverride) + { + if (PrivateLinkScopedResources.Any() || hasPropertyOverride) + { + builder.Append(" privateLinkScopedResources: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in PrivateLinkScopedResources) + { + AppendChildObject(builder, item, options, 6, true, " privateLinkScopedResources: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Features), out propertyOverride); + if (Optional.IsDefined(Features) || hasPropertyOverride) + { + builder.Append(" features: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Features, options, 4, false, " features: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DefaultDataCollectionRuleResourceId), out propertyOverride); + if (Optional.IsDefined(DefaultDataCollectionRuleResourceId) || hasPropertyOverride) + { + builder.Append(" defaultDataCollectionRuleResourceId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{DefaultDataCollectionRuleResourceId.ToString()}'"); + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -441,6 +811,8 @@ BinaryData IPersistableModel.Write(ModelReade { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(OperationalInsightsWorkspacePatch)} does not support '{options.Format}' format."); } @@ -457,6 +829,8 @@ OperationalInsightsWorkspacePatch IPersistableModel The identity of the resource. Current supported identity types: None, SystemAssigned, UserAssigned. + [WirePath("identity")] public ManagedServiceIdentity Identity { get; set; } /// Resource tags. Optional. + [WirePath("tags")] public IDictionary Tags { get; } /// The provisioning state of the workspace. + [WirePath("properties.provisioningState")] public OperationalInsightsWorkspaceEntityStatus? ProvisioningState { get; } /// This is a read-only property. Represents the ID associated with the workspace. + [WirePath("properties.customerId")] public Guid? CustomerId { get; } /// The SKU of the workspace. + [WirePath("properties.sku")] public OperationalInsightsWorkspaceSku Sku { get; set; } /// The workspace data retention in days. Allowed values are per pricing plan. See pricing tiers documentation for details. + [WirePath("properties.retentionInDays")] public int? RetentionInDays { get; set; } /// The daily volume cap for ingestion. + [WirePath("properties.workspaceCapping")] public OperationalInsightsWorkspaceCapping WorkspaceCapping { get; set; } /// Workspace creation date. + [WirePath("properties.createdDate")] public DateTimeOffset? CreatedOn { get; } /// Workspace modification date. + [WirePath("properties.modifiedDate")] public DateTimeOffset? ModifiedOn { get; } /// The network access type for accessing Log Analytics ingestion. + [WirePath("properties.publicNetworkAccessForIngestion")] public OperationalInsightsPublicNetworkAccessType? PublicNetworkAccessForIngestion { get; set; } /// The network access type for accessing Log Analytics query. + [WirePath("properties.publicNetworkAccessForQuery")] public OperationalInsightsPublicNetworkAccessType? PublicNetworkAccessForQuery { get; set; } /// Indicates whether customer managed storage is mandatory for query management. + [WirePath("properties.forceCmkForQuery")] public bool? ForceCmkForQuery { get; set; } /// List of linked private link scope resources. + [WirePath("properties.privateLinkScopedResources")] public IReadOnlyList PrivateLinkScopedResources { get; } /// Workspace features. + [WirePath("properties.features")] public OperationalInsightsWorkspaceFeatures Features { get; set; } /// The resource ID of the default Data Collection Rule to use for this workspace. Expected format is - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dcrName}. + [WirePath("properties.defaultDataCollectionRuleResourceId")] public ResourceIdentifier DefaultDataCollectionRuleResourceId { get; set; } /// Resource Etag. + [WirePath("etag")] public ETag? ETag { get; } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspacePurgeContent.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspacePurgeContent.cs index dfbe67b7f205e..026808fac11d5 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspacePurgeContent.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspacePurgeContent.cs @@ -77,8 +77,10 @@ internal OperationalInsightsWorkspacePurgeContent() } /// Table from which to purge data. + [WirePath("table")] public string Table { get; } /// The set of columns and filters (queries) to run over them to purge the resulting data. + [WirePath("filters")] public IList Filters { get; } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspacePurgeFilter.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspacePurgeFilter.cs index 4976e65da8cdd..7ae9eec8a2a97 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspacePurgeFilter.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspacePurgeFilter.cs @@ -66,8 +66,10 @@ internal OperationalInsightsWorkspacePurgeFilter(string column, string @operator } /// The column of the table over which the given query should run. + [WirePath("column")] public string Column { get; set; } /// A query operator to evaluate over the provided column and value(s). Supported operators are ==, =~, in, in~, >, >=, <, <=, between, and have the same behavior as they would in a KQL query. + [WirePath("operator")] public string Operator { get; set; } /// /// the value for the operator to function over. This can be a number (e.g., > 100), a string (timestamp >= '2017-09-01') or array of values. @@ -99,8 +101,10 @@ internal OperationalInsightsWorkspacePurgeFilter(string column, string @operator /// /// /// + [WirePath("value")] public BinaryData Value { get; set; } /// When filtering over custom dimensions, this key will be used as the name of the custom dimension. + [WirePath("key")] public string Key { get; set; } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspacePurgeResult.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspacePurgeResult.Serialization.cs index 94451f6735ca3..bf760b4ebb017 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspacePurgeResult.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspacePurgeResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; +using Azure.ResourceManager.OperationalInsights; namespace Azure.ResourceManager.OperationalInsights.Models { @@ -85,6 +88,85 @@ internal static OperationalInsightsWorkspacePurgeResult DeserializeOperationalIn return new OperationalInsightsWorkspacePurgeResult(operationId, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(OperationStringId), out propertyOverride); + if (Optional.IsDefined(OperationStringId) || hasPropertyOverride) + { + builder.Append(" operationId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (OperationStringId.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{OperationStringId}'''"); + } + else + { + builder.AppendLine($"'{OperationStringId}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -93,6 +175,8 @@ BinaryData IPersistableModel.Write(Mode { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(OperationalInsightsWorkspacePurgeResult)} does not support '{options.Format}' format."); } @@ -109,6 +193,8 @@ OperationalInsightsWorkspacePurgeResult IPersistableModel Id to use when querying for status for a particular purge operation. + [WirePath("operationId")] public string OperationStringId { get; } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspacePurgeStatusResult.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspacePurgeStatusResult.Serialization.cs index 472e139408084..855095ae69257 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspacePurgeStatusResult.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspacePurgeStatusResult.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; namespace Azure.ResourceManager.OperationalInsights.Models { @@ -85,6 +87,74 @@ internal static OperationalInsightsWorkspacePurgeStatusResult DeserializeOperati return new OperationalInsightsWorkspacePurgeStatusResult(status, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); + builder.Append(" status: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Status.ToString()}'"); + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -93,6 +163,8 @@ BinaryData IPersistableModel.Writ { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(OperationalInsightsWorkspacePurgeStatusResult)} does not support '{options.Format}' format."); } @@ -109,6 +181,8 @@ OperationalInsightsWorkspacePurgeStatusResult IPersistableModel Status of the operation represented by the requested Id. + [WirePath("status")] public OperationalInsightsWorkspacePurgeState Status { get; } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspaceSharedKeys.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspaceSharedKeys.Serialization.cs index f29d94c8d5c28..48c4658bf0758 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspaceSharedKeys.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspaceSharedKeys.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.OperationalInsights; namespace Azure.ResourceManager.OperationalInsights.Models @@ -100,6 +102,107 @@ internal static OperationalInsightsWorkspaceSharedKeys DeserializeOperationalIns return new OperationalInsightsWorkspaceSharedKeys(primarySharedKey, secondarySharedKey, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrimarySharedKey), out propertyOverride); + if (Optional.IsDefined(PrimarySharedKey) || hasPropertyOverride) + { + builder.Append(" primarySharedKey: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (PrimarySharedKey.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{PrimarySharedKey}'''"); + } + else + { + builder.AppendLine($"'{PrimarySharedKey}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SecondarySharedKey), out propertyOverride); + if (Optional.IsDefined(SecondarySharedKey) || hasPropertyOverride) + { + builder.Append(" secondarySharedKey: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (SecondarySharedKey.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{SecondarySharedKey}'''"); + } + else + { + builder.AppendLine($"'{SecondarySharedKey}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -108,6 +211,8 @@ BinaryData IPersistableModel.Write(Model { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(OperationalInsightsWorkspaceSharedKeys)} does not support '{options.Format}' format."); } @@ -124,6 +229,8 @@ OperationalInsightsWorkspaceSharedKeys IPersistableModel The primary shared key of a workspace. + [WirePath("primarySharedKey")] public string PrimarySharedKey { get; } /// The secondary shared key of a workspace. + [WirePath("secondarySharedKey")] public string SecondarySharedKey { get; } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspaceSku.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspaceSku.Serialization.cs index 2d7087a9d01f5..948f48ae5d808 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspaceSku.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspaceSku.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.OperationalInsights; namespace Azure.ResourceManager.OperationalInsights.Models @@ -116,6 +118,103 @@ internal static OperationalInsightsWorkspaceSku DeserializeOperationalInsightsWo return new OperationalInsightsWorkspaceSku(name, capacityReservationLevel, lastSkuUpdate, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Name.ToString()}'"); + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CapacityReservationLevel), out propertyOverride); + if (Optional.IsDefined(CapacityReservationLevel) || hasPropertyOverride) + { + builder.Append(" capacityReservationLevel: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine(CapacityReservationLevel.Value.ToString()); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastSkuUpdatedOn), out propertyOverride); + if (Optional.IsDefined(LastSkuUpdatedOn) || hasPropertyOverride) + { + builder.Append(" lastSkuUpdate: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(LastSkuUpdatedOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -124,6 +223,8 @@ BinaryData IPersistableModel.Write(ModelReaderW { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(OperationalInsightsWorkspaceSku)} does not support '{options.Format}' format."); } @@ -140,6 +241,8 @@ OperationalInsightsWorkspaceSku IPersistableModel The name of the SKU. + [WirePath("name")] public OperationalInsightsWorkspaceSkuName Name { get; set; } /// The capacity reservation level in GB for this workspace, when CapacityReservation sku is selected. + [WirePath("capacityReservationLevel")] public OperationalInsightsWorkspaceCapacityReservationLevel? CapacityReservationLevel { get; set; } /// The last time when the sku was updated. + [WirePath("lastSkuUpdate")] public DateTimeOffset? LastSkuUpdatedOn { get; } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SavedSearchesListResult.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SavedSearchesListResult.Serialization.cs index 1b853bdc0fb63..6889243a3bdd6 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SavedSearchesListResult.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SavedSearchesListResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.OperationalInsights; namespace Azure.ResourceManager.OperationalInsights.Models @@ -103,6 +106,85 @@ internal static SavedSearchesListResult DeserializeSavedSearchesListResult(JsonE return new SavedSearchesListResult(value ?? new ChangeTrackingList(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -111,6 +193,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpt { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(SavedSearchesListResult)} does not support '{options.Format}' format."); } @@ -127,6 +211,8 @@ SavedSearchesListResult IPersistableModel.Create(Binary using JsonDocument document = JsonDocument.Parse(data); return DeserializeSavedSearchesListResult(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(SavedSearchesListResult)} does not support '{options.Format}' format."); } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SavedSearchesListResult.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SavedSearchesListResult.cs index af9a3a5568cf6..6e36879507ed3 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SavedSearchesListResult.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SavedSearchesListResult.cs @@ -62,6 +62,7 @@ internal SavedSearchesListResult(IReadOnlyList The array of result values. + [WirePath("value")] public IReadOnlyList Value { get; } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SearchGetSchemaResponse.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SearchGetSchemaResponse.Serialization.cs index e574e3a294b1e..2ddf724098404 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SearchGetSchemaResponse.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SearchGetSchemaResponse.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.OperationalInsights; namespace Azure.ResourceManager.OperationalInsights.Models @@ -118,6 +121,99 @@ internal static SearchGetSchemaResponse DeserializeSearchGetSchemaResponse(JsonE return new SearchGetSchemaResponse(metadata, value ?? new ChangeTrackingList(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Metadata), out propertyOverride); + if (Optional.IsDefined(Metadata) || hasPropertyOverride) + { + builder.Append(" metadata: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Metadata, options, 2, false, " metadata: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -126,6 +222,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpt { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(SearchGetSchemaResponse)} does not support '{options.Format}' format."); } @@ -142,6 +240,8 @@ SearchGetSchemaResponse IPersistableModel.Create(Binary using JsonDocument document = JsonDocument.Parse(data); return DeserializeSearchGetSchemaResponse(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(SearchGetSchemaResponse)} does not support '{options.Format}' format."); } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SearchGetSchemaResponse.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SearchGetSchemaResponse.cs index 8a82d5c2a5e42..8e4ed876eddf1 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SearchGetSchemaResponse.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SearchGetSchemaResponse.cs @@ -64,8 +64,10 @@ internal SearchGetSchemaResponse(SearchMetadata metadata, IReadOnlyList The metadata from search results. + [WirePath("metadata")] public SearchMetadata Metadata { get; } /// The array of result values. + [WirePath("value")] public IReadOnlyList Value { get; } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SearchMetadata.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SearchMetadata.Serialization.cs index 4d99fa92c810e..7d467ce079c54 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SearchMetadata.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SearchMetadata.Serialization.cs @@ -8,9 +8,12 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.OperationalInsights; namespace Azure.ResourceManager.OperationalInsights.Models @@ -348,6 +351,367 @@ internal static SearchMetadata DeserializeSearchMetadata(JsonElement element, Mo serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SearchId), out propertyOverride); + if (Optional.IsDefined(SearchId) || hasPropertyOverride) + { + builder.Append(" requestId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (SearchId.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{SearchId}'''"); + } + else + { + builder.AppendLine($"'{SearchId}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ResultType), out propertyOverride); + if (Optional.IsDefined(ResultType) || hasPropertyOverride) + { + builder.Append(" resultType: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ResultType.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ResultType}'''"); + } + else + { + builder.AppendLine($"'{ResultType}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Total), out propertyOverride); + if (Optional.IsDefined(Total) || hasPropertyOverride) + { + builder.Append(" total: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Total.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Top), out propertyOverride); + if (Optional.IsDefined(Top) || hasPropertyOverride) + { + builder.Append(" top: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Top.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Id.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Id}'''"); + } + else + { + builder.AppendLine($"'{Id}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CoreSummaries), out propertyOverride); + if (Optional.IsCollectionDefined(CoreSummaries) || hasPropertyOverride) + { + if (CoreSummaries.Any() || hasPropertyOverride) + { + builder.Append(" coreSummaries: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in CoreSummaries) + { + AppendChildObject(builder, item, options, 4, true, " coreSummaries: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); + if (Optional.IsDefined(Status) || hasPropertyOverride) + { + builder.Append(" status: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Status.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Status}'''"); + } + else + { + builder.AppendLine($"'{Status}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartOn), out propertyOverride); + if (Optional.IsDefined(StartOn) || hasPropertyOverride) + { + builder.Append(" startTime: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(StartOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastUpdated), out propertyOverride); + if (Optional.IsDefined(LastUpdated) || hasPropertyOverride) + { + builder.Append(" lastUpdated: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(LastUpdated.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ETag), out propertyOverride); + if (Optional.IsDefined(ETag) || hasPropertyOverride) + { + builder.Append(" eTag: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ETag.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Sort), out propertyOverride); + if (Optional.IsCollectionDefined(Sort) || hasPropertyOverride) + { + if (Sort.Any() || hasPropertyOverride) + { + builder.Append(" sort: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Sort) + { + AppendChildObject(builder, item, options, 4, true, " sort: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RequestTime), out propertyOverride); + if (Optional.IsDefined(RequestTime) || hasPropertyOverride) + { + builder.Append(" requestTime: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{RequestTime.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AggregatedValueField), out propertyOverride); + if (Optional.IsDefined(AggregatedValueField) || hasPropertyOverride) + { + builder.Append(" aggregatedValueField: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (AggregatedValueField.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{AggregatedValueField}'''"); + } + else + { + builder.AppendLine($"'{AggregatedValueField}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AggregatedGroupingFields), out propertyOverride); + if (Optional.IsDefined(AggregatedGroupingFields) || hasPropertyOverride) + { + builder.Append(" aggregatedGroupingFields: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (AggregatedGroupingFields.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{AggregatedGroupingFields}'''"); + } + else + { + builder.AppendLine($"'{AggregatedGroupingFields}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Sum), out propertyOverride); + if (Optional.IsDefined(Sum) || hasPropertyOverride) + { + builder.Append(" sum: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Sum.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Max), out propertyOverride); + if (Optional.IsDefined(Max) || hasPropertyOverride) + { + builder.Append(" max: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Max.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Schema), out propertyOverride); + if (Optional.IsDefined(Schema) || hasPropertyOverride) + { + builder.Append(" schema: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Schema, options, 2, false, " schema: "); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -356,6 +720,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions opti { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(SearchMetadata)} does not support '{options.Format}' format."); } @@ -372,6 +738,8 @@ SearchMetadata IPersistableModel.Create(BinaryData data, ModelRe using JsonDocument document = JsonDocument.Parse(data); return DeserializeSearchMetadata(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(SearchMetadata)} does not support '{options.Format}' format."); } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SearchMetadata.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SearchMetadata.cs index 55bf82ef465c1..b23133c9c8aed 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SearchMetadata.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SearchMetadata.cs @@ -96,38 +96,55 @@ internal SearchMetadata(string searchId, string resultType, long? total, long? t } /// The request id of the search. + [WirePath("requestId")] public string SearchId { get; } /// The search result type. + [WirePath("resultType")] public string ResultType { get; } /// The total number of search results. + [WirePath("total")] public long? Total { get; } /// The number of top search results. + [WirePath("top")] public long? Top { get; } /// The id of the search results request. + [WirePath("id")] public string Id { get; } /// The core summaries. + [WirePath("coreSummaries")] public IReadOnlyList CoreSummaries { get; } /// The status of the search results. + [WirePath("status")] public string Status { get; } /// The start time for the search. + [WirePath("startTime")] public DateTimeOffset? StartOn { get; } /// The time of last update. + [WirePath("lastUpdated")] public DateTimeOffset? LastUpdated { get; } /// The ETag of the search results. + [WirePath("eTag")] public ETag? ETag { get; } /// How the results are sorted. + [WirePath("sort")] public IReadOnlyList Sort { get; } /// The request time. + [WirePath("requestTime")] public long? RequestTime { get; } /// The aggregated value field. + [WirePath("aggregatedValueField")] public string AggregatedValueField { get; } /// The aggregated grouping fields. + [WirePath("aggregatedGroupingFields")] public string AggregatedGroupingFields { get; } /// The sum of all aggregates returned in the result set. + [WirePath("sum")] public long? Sum { get; } /// The max of all aggregates returned in the result set. + [WirePath("max")] public long? Max { get; } /// The schema. + [WirePath("schema")] public SearchMetadataSchema Schema { get; } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SearchMetadataSchema.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SearchMetadataSchema.Serialization.cs index 0d8092666c97e..a37bf47169eac 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SearchMetadataSchema.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SearchMetadataSchema.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.OperationalInsights; namespace Azure.ResourceManager.OperationalInsights.Models @@ -104,6 +106,99 @@ internal static SearchMetadataSchema DeserializeSearchMetadataSchema(JsonElement return new SearchMetadataSchema(name, version, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Version), out propertyOverride); + if (Optional.IsDefined(Version) || hasPropertyOverride) + { + builder.Append(" version: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{Version.Value}"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -112,6 +207,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOption { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(SearchMetadataSchema)} does not support '{options.Format}' format."); } @@ -128,6 +225,8 @@ SearchMetadataSchema IPersistableModel.Create(BinaryData d using JsonDocument document = JsonDocument.Parse(data); return DeserializeSearchMetadataSchema(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(SearchMetadataSchema)} does not support '{options.Format}' format."); } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SearchMetadataSchema.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SearchMetadataSchema.cs index 6a6cab7e2573e..e686ef2376bc7 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SearchMetadataSchema.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SearchMetadataSchema.cs @@ -62,8 +62,10 @@ internal SearchMetadataSchema(string name, int? version, IDictionary The name of the metadata schema. + [WirePath("name")] public string Name { get; } /// The version of the metadata schema. + [WirePath("version")] public int? Version { get; } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SearchSort.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SearchSort.Serialization.cs index 5674281512353..60dd5cb94c57c 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SearchSort.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SearchSort.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.OperationalInsights; namespace Azure.ResourceManager.OperationalInsights.Models @@ -104,6 +106,99 @@ internal static SearchSort DeserializeSearchSort(JsonElement element, ModelReade return new SearchSort(name, order, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Order), out propertyOverride); + if (Optional.IsDefined(Order) || hasPropertyOverride) + { + builder.Append(" order: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Order.Value.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -112,6 +207,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(SearchSort)} does not support '{options.Format}' format."); } @@ -128,6 +225,8 @@ SearchSort IPersistableModel.Create(BinaryData data, ModelReaderWrit using JsonDocument document = JsonDocument.Parse(data); return DeserializeSearchSort(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(SearchSort)} does not support '{options.Format}' format."); } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SearchSort.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SearchSort.cs index c633c0785a907..0f894f582c08c 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SearchSort.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SearchSort.cs @@ -62,8 +62,10 @@ internal SearchSort(string name, SearchSortEnum? order, IDictionary The name of the field the search query is sorted on. + [WirePath("name")] public string Name { get; } /// The sort order of the search. + [WirePath("order")] public SearchSortEnum? Order { get; } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/StorageInsightListResult.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/StorageInsightListResult.Serialization.cs index 39f09c8250741..54258f662e467 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/StorageInsightListResult.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/StorageInsightListResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.OperationalInsights; namespace Azure.ResourceManager.OperationalInsights.Models @@ -114,6 +117,107 @@ internal static StorageInsightListResult DeserializeStorageInsightListResult(Jso return new StorageInsightListResult(value ?? new ChangeTrackingList(), odataNextLink, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(OdataNextLink), out propertyOverride); + if (Optional.IsDefined(OdataNextLink) || hasPropertyOverride) + { + builder.Append(" @odata.nextLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (OdataNextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{OdataNextLink}'''"); + } + else + { + builder.AppendLine($"'{OdataNextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -122,6 +226,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOp { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(StorageInsightListResult)} does not support '{options.Format}' format."); } @@ -138,6 +244,8 @@ StorageInsightListResult IPersistableModel.Create(Bina using JsonDocument document = JsonDocument.Parse(data); return DeserializeStorageInsightListResult(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(StorageInsightListResult)} does not support '{options.Format}' format."); } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/StorageInsightStatus.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/StorageInsightStatus.Serialization.cs index 720c7c390bbf3..26e9d5947cbc7 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/StorageInsightStatus.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/StorageInsightStatus.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.OperationalInsights; namespace Azure.ResourceManager.OperationalInsights.Models @@ -97,6 +99,96 @@ internal static StorageInsightStatus DeserializeStorageInsightStatus(JsonElement return new StorageInsightStatus(state, description, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); + builder.Append(" state: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{State.ToString()}'"); + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); + if (Optional.IsDefined(Description) || hasPropertyOverride) + { + builder.Append(" description: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Description.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Description}'''"); + } + else + { + builder.AppendLine($"'{Description}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -105,6 +197,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOption { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(StorageInsightStatus)} does not support '{options.Format}' format."); } @@ -121,6 +215,8 @@ StorageInsightStatus IPersistableModel.Create(BinaryData d using JsonDocument document = JsonDocument.Parse(data); return DeserializeStorageInsightStatus(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(StorageInsightStatus)} does not support '{options.Format}' format."); } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/StorageInsightStatus.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/StorageInsightStatus.cs index 20d1bfc02edd6..37f040ad1f1c0 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/StorageInsightStatus.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/StorageInsightStatus.cs @@ -69,8 +69,10 @@ internal StorageInsightStatus() } /// The state of the storage insight connection to the workspace. + [WirePath("state")] public StorageInsightState State { get; } /// Description of the state of the storage insight. + [WirePath("description")] public string Description { get; } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/TablesListResult.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/TablesListResult.Serialization.cs index 118e062a7bf63..2b4cc38ed28af 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/TablesListResult.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/TablesListResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.OperationalInsights; namespace Azure.ResourceManager.OperationalInsights.Models @@ -103,6 +106,85 @@ internal static TablesListResult DeserializeTablesListResult(JsonElement element return new TablesListResult(value ?? new ChangeTrackingList(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -111,6 +193,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions op { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(TablesListResult)} does not support '{options.Format}' format."); } @@ -127,6 +211,8 @@ TablesListResult IPersistableModel.Create(BinaryData data, Mod using JsonDocument document = JsonDocument.Parse(data); return DeserializeTablesListResult(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(TablesListResult)} does not support '{options.Format}' format."); } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/WorkspaceListManagementGroupsResult.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/WorkspaceListManagementGroupsResult.Serialization.cs index ced858462b949..73e1f5938d887 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/WorkspaceListManagementGroupsResult.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/WorkspaceListManagementGroupsResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.OperationalInsights; namespace Azure.ResourceManager.OperationalInsights.Models @@ -103,6 +106,85 @@ internal static WorkspaceListManagementGroupsResult DeserializeWorkspaceListMana return new WorkspaceListManagementGroupsResult(value ?? new ChangeTrackingList(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -111,6 +193,8 @@ BinaryData IPersistableModel.Write(ModelRea { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(WorkspaceListManagementGroupsResult)} does not support '{options.Format}' format."); } @@ -127,6 +211,8 @@ WorkspaceListManagementGroupsResult IPersistableModel(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -111,6 +193,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(WorkspaceListResult)} does not support '{options.Format}' format."); } @@ -127,6 +211,8 @@ WorkspaceListResult IPersistableModel.Create(BinaryData dat using JsonDocument document = JsonDocument.Parse(data); return DeserializeWorkspaceListResult(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(WorkspaceListResult)} does not support '{options.Format}' format."); } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/WorkspaceListUsagesResult.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/WorkspaceListUsagesResult.Serialization.cs index 4e299134db7a6..233e26a886c86 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/WorkspaceListUsagesResult.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/WorkspaceListUsagesResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.OperationalInsights; namespace Azure.ResourceManager.OperationalInsights.Models @@ -103,6 +106,85 @@ internal static WorkspaceListUsagesResult DeserializeWorkspaceListUsagesResult(J return new WorkspaceListUsagesResult(value ?? new ChangeTrackingList(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -111,6 +193,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterO { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(WorkspaceListUsagesResult)} does not support '{options.Format}' format."); } @@ -127,6 +211,8 @@ WorkspaceListUsagesResult IPersistableModel.Create(Bi using JsonDocument document = JsonDocument.Parse(data); return DeserializeWorkspaceListUsagesResult(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(WorkspaceListUsagesResult)} does not support '{options.Format}' format."); } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsClusterData.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsClusterData.Serialization.cs index ca09677124a6a..9c86c8baa4813 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsClusterData.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsClusterData.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.Models; using Azure.ResourceManager.OperationalInsights.Models; @@ -385,6 +388,343 @@ internal static OperationalInsightsClusterData DeserializeOperationalInsightsClu serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); + builder.Append(" location: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Location.ToString()}'"); + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tags), out propertyOverride); + if (Optional.IsCollectionDefined(Tags) || hasPropertyOverride) + { + if (Tags.Any() || hasPropertyOverride) + { + builder.Append(" tags: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("{"); + foreach (var item in Tags) + { + builder.Append($" '{item.Key}': "); + if (item.Value == null) + { + builder.Append("null"); + continue; + } + if (item.Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{item.Value}'''"); + } + else + { + builder.AppendLine($"'{item.Value}'"); + } + } + builder.AppendLine(" }"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Identity), out propertyOverride); + if (Optional.IsDefined(Identity) || hasPropertyOverride) + { + builder.Append(" identity: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Identity, options, 2, false, " identity: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Sku), out propertyOverride); + if (Optional.IsDefined(Sku) || hasPropertyOverride) + { + builder.Append(" sku: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Sku, options, 2, false, " sku: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ClusterId), out propertyOverride); + if (Optional.IsDefined(ClusterId) || hasPropertyOverride) + { + builder.Append(" clusterId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ClusterId.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); + if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) + { + builder.Append(" provisioningState: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ProvisioningState.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsDoubleEncryptionEnabled), out propertyOverride); + if (Optional.IsDefined(IsDoubleEncryptionEnabled) || hasPropertyOverride) + { + builder.Append(" isDoubleEncryptionEnabled: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsDoubleEncryptionEnabled.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsAvailabilityZonesEnabled), out propertyOverride); + if (Optional.IsDefined(IsAvailabilityZonesEnabled) || hasPropertyOverride) + { + builder.Append(" isAvailabilityZonesEnabled: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsAvailabilityZonesEnabled.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BillingType), out propertyOverride); + if (Optional.IsDefined(BillingType) || hasPropertyOverride) + { + builder.Append(" billingType: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{BillingType.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyVaultProperties), out propertyOverride); + if (Optional.IsDefined(KeyVaultProperties) || hasPropertyOverride) + { + builder.Append(" keyVaultProperties: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, KeyVaultProperties, options, 4, false, " keyVaultProperties: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastModifiedOn), out propertyOverride); + if (Optional.IsDefined(LastModifiedOn) || hasPropertyOverride) + { + builder.Append(" lastModifiedDate: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(LastModifiedOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); + if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) + { + builder.Append(" createdDate: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AssociatedWorkspaces), out propertyOverride); + if (Optional.IsCollectionDefined(AssociatedWorkspaces) || hasPropertyOverride) + { + if (AssociatedWorkspaces.Any() || hasPropertyOverride) + { + builder.Append(" associatedWorkspaces: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in AssociatedWorkspaces) + { + AppendChildObject(builder, item, options, 6, true, " associatedWorkspaces: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CapacityReservationProperties), out propertyOverride); + if (Optional.IsDefined(CapacityReservationProperties) || hasPropertyOverride) + { + builder.Append(" capacityReservationProperties: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, CapacityReservationProperties, options, 4, false, " capacityReservationProperties: "); + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -393,6 +733,8 @@ BinaryData IPersistableModel.Write(ModelReaderWr { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(OperationalInsightsClusterData)} does not support '{options.Format}' format."); } @@ -409,6 +751,8 @@ OperationalInsightsClusterData IPersistableModel using JsonDocument document = JsonDocument.Parse(data); return DeserializeOperationalInsightsClusterData(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(OperationalInsightsClusterData)} does not support '{options.Format}' format."); } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsClusterData.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsClusterData.cs index 7e63b70d33f4c..e247d40aa9db9 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsClusterData.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsClusterData.cs @@ -101,28 +101,40 @@ internal OperationalInsightsClusterData() } /// The identity of the resource. Current supported identity types: None, SystemAssigned, UserAssigned. + [WirePath("identity")] public ManagedServiceIdentity Identity { get; set; } /// The sku properties. + [WirePath("sku")] public OperationalInsightsClusterSku Sku { get; set; } /// The ID associated with the cluster. + [WirePath("properties.clusterId")] public Guid? ClusterId { get; } /// The provisioning state of the cluster. + [WirePath("properties.provisioningState")] public OperationalInsightsClusterEntityStatus? ProvisioningState { get; } /// Configures whether cluster will use double encryption. This Property can not be modified after cluster creation. Default value is 'true'. + [WirePath("properties.isDoubleEncryptionEnabled")] public bool? IsDoubleEncryptionEnabled { get; set; } /// Sets whether the cluster will support availability zones. This can be set as true only in regions where Azure Data Explorer support Availability Zones. This Property can not be modified after cluster creation. Default value is 'true' if region supports Availability Zones. + [WirePath("properties.isAvailabilityZonesEnabled")] public bool? IsAvailabilityZonesEnabled { get; set; } /// The cluster's billing type. + [WirePath("properties.billingType")] public OperationalInsightsBillingType? BillingType { get; set; } /// The associated key properties. + [WirePath("properties.keyVaultProperties")] public OperationalInsightsKeyVaultProperties KeyVaultProperties { get; set; } /// The last time the cluster was updated. + [WirePath("properties.lastModifiedDate")] public DateTimeOffset? LastModifiedOn { get; } /// The cluster creation time. + [WirePath("properties.createdDate")] public DateTimeOffset? CreatedOn { get; } /// The list of Log Analytics workspaces associated with the cluster. + [WirePath("properties.associatedWorkspaces")] public IList AssociatedWorkspaces { get; } /// Additional properties for capacity reservation. + [WirePath("properties.capacityReservationProperties")] public OperationalInsightsCapacityReservationProperties CapacityReservationProperties { get; set; } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsDataExportData.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsDataExportData.Serialization.cs index 79e5cf72c30fc..de4f7f4c2a552 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsDataExportData.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsDataExportData.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.Models; using Azure.ResourceManager.OperationalInsights.Models; @@ -311,6 +314,266 @@ internal static OperationalInsightsDataExportData DeserializeOperationalInsights serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DataExportId), out propertyOverride); + if (Optional.IsDefined(DataExportId) || hasPropertyOverride) + { + builder.Append(" dataExportId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{DataExportId.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TableNames), out propertyOverride); + if (Optional.IsCollectionDefined(TableNames) || hasPropertyOverride) + { + if (TableNames.Any() || hasPropertyOverride) + { + builder.Append(" tableNames: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in TableNames) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsEnabled), out propertyOverride); + if (Optional.IsDefined(IsEnabled) || hasPropertyOverride) + { + builder.Append(" enable: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsEnabled.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); + if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) + { + builder.Append(" createdDate: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastModifiedOn), out propertyOverride); + if (Optional.IsDefined(LastModifiedOn) || hasPropertyOverride) + { + builder.Append(" lastModifiedDate: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(LastModifiedOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + builder.Append(" destination:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ResourceId), out propertyOverride); + if (Optional.IsDefined(ResourceId) || hasPropertyOverride) + { + builder.Append(" resourceId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ResourceId.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DestinationType), out propertyOverride); + if (Optional.IsDefined(DestinationType) || hasPropertyOverride) + { + builder.Append(" type: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{DestinationType.Value.ToString()}'"); + } + } + + builder.Append(" metaData:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EventHubName), out propertyOverride); + if (Optional.IsDefined(EventHubName) || hasPropertyOverride) + { + builder.Append(" eventHubName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (EventHubName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{EventHubName}'''"); + } + else + { + builder.AppendLine($"'{EventHubName}'"); + } + } + } + + builder.AppendLine(" }"); + builder.AppendLine(" }"); + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -319,6 +582,8 @@ BinaryData IPersistableModel.Write(ModelReade { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(OperationalInsightsDataExportData)} does not support '{options.Format}' format."); } @@ -335,6 +600,8 @@ OperationalInsightsDataExportData IPersistableModel The data export rule ID. + [WirePath("properties.dataExportId")] public Guid? DataExportId { get; set; } /// An array of tables to export, for example: [“Heartbeat, SecurityEvent”]. + [WirePath("properties.tableNames")] public IList TableNames { get; } /// Active when enabled. + [WirePath("properties.enable")] public bool? IsEnabled { get; set; } /// The latest data export rule modification time. + [WirePath("properties.createdDate")] public DateTimeOffset? CreatedOn { get; set; } /// Date and time when the export was last modified. + [WirePath("properties.lastModifiedDate")] public DateTimeOffset? LastModifiedOn { get; set; } /// The destination resource ID. This can be copied from the Properties entry of the destination resource in Azure. + [WirePath("properties.resourceId")] public ResourceIdentifier ResourceId { get; set; } /// The type of the destination resource. + [WirePath("properties.type")] public OperationalInsightsDataExportDestinationType? DestinationType { get; } /// Optional. Allows to define an Event Hub name. Not applicable when destination is Storage Account. + [WirePath("properties.eventHubName")] public string EventHubName { get; set; } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsDataSourceData.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsDataSourceData.Serialization.cs index 2da23a50c3279..3a06359a6163b 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsDataSourceData.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsDataSourceData.Serialization.cs @@ -8,9 +8,12 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.Models; using Azure.ResourceManager.OperationalInsights.Models; @@ -201,6 +204,188 @@ internal static OperationalInsightsDataSourceData DeserializeOperationalInsights serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tags), out propertyOverride); + if (Optional.IsCollectionDefined(Tags) || hasPropertyOverride) + { + if (Tags.Any() || hasPropertyOverride) + { + builder.Append(" tags: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("{"); + foreach (var item in Tags) + { + builder.Append($" '{item.Key}': "); + if (item.Value == null) + { + builder.Append("null"); + continue; + } + if (item.Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{item.Value}'''"); + } + else + { + builder.AppendLine($"'{item.Value}'"); + } + } + builder.AppendLine(" }"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Properties), out propertyOverride); + if (Optional.IsDefined(Properties) || hasPropertyOverride) + { + builder.Append(" properties: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Properties.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ETag), out propertyOverride); + if (Optional.IsDefined(ETag) || hasPropertyOverride) + { + builder.Append(" etag: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ETag.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); + builder.Append(" kind: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Kind.ToString()}'"); + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -209,6 +394,8 @@ BinaryData IPersistableModel.Write(ModelReade { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(OperationalInsightsDataSourceData)} does not support '{options.Format}' format."); } @@ -225,6 +412,8 @@ OperationalInsightsDataSourceData IPersistableModel /// /// + [WirePath("properties")] public BinaryData Properties { get; set; } /// The ETag of the data source. + [WirePath("etag")] public ETag? ETag { get; set; } /// The kind of the DataSource. + [WirePath("kind")] public OperationalInsightsDataSourceKind Kind { get; set; } /// Resource tags. + [WirePath("tags")] public IDictionary Tags { get; } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsLinkedServiceData.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsLinkedServiceData.Serialization.cs index 352d48b80680e..44b4b2af46cdd 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsLinkedServiceData.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsLinkedServiceData.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.Models; using Azure.ResourceManager.OperationalInsights.Models; @@ -222,6 +225,194 @@ internal static OperationalInsightsLinkedServiceData DeserializeOperationalInsig serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tags), out propertyOverride); + if (Optional.IsCollectionDefined(Tags) || hasPropertyOverride) + { + if (Tags.Any() || hasPropertyOverride) + { + builder.Append(" tags: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("{"); + foreach (var item in Tags) + { + builder.Append($" '{item.Key}': "); + if (item.Value == null) + { + builder.Append("null"); + continue; + } + if (item.Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{item.Value}'''"); + } + else + { + builder.AppendLine($"'{item.Value}'"); + } + } + builder.AppendLine(" }"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ResourceId), out propertyOverride); + if (Optional.IsDefined(ResourceId) || hasPropertyOverride) + { + builder.Append(" resourceId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ResourceId.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(WriteAccessResourceId), out propertyOverride); + if (Optional.IsDefined(WriteAccessResourceId) || hasPropertyOverride) + { + builder.Append(" writeAccessResourceId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{WriteAccessResourceId.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); + if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) + { + builder.Append(" provisioningState: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ProvisioningState.Value.ToString()}'"); + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -230,6 +421,8 @@ BinaryData IPersistableModel.Write(ModelRe { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(OperationalInsightsLinkedServiceData)} does not support '{options.Format}' format."); } @@ -246,6 +439,8 @@ OperationalInsightsLinkedServiceData IPersistableModel Resource tags. + [WirePath("tags")] public IDictionary Tags { get; } /// The resource id of the resource that will be linked to the workspace. This should be used for linking resources which require read access. + [WirePath("properties.resourceId")] public ResourceIdentifier ResourceId { get; set; } /// The resource id of the resource that will be linked to the workspace. This should be used for linking resources which require write access. + [WirePath("properties.writeAccessResourceId")] public ResourceIdentifier WriteAccessResourceId { get; set; } /// The provisioning state of the linked service. + [WirePath("properties.provisioningState")] public OperationalInsightsLinkedServiceEntityStatus? ProvisioningState { get; set; } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsLinkedStorageAccountsData.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsLinkedStorageAccountsData.Serialization.cs index 00946e35c96bd..578490145f449 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsLinkedStorageAccountsData.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsLinkedStorageAccountsData.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.Models; using Azure.ResourceManager.OperationalInsights.Models; @@ -201,6 +204,157 @@ internal static OperationalInsightsLinkedStorageAccountsData DeserializeOperatio serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DataSourceType), out propertyOverride); + if (Optional.IsDefined(DataSourceType) || hasPropertyOverride) + { + builder.Append(" dataSourceType: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{DataSourceType.Value.ToSerialString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageAccountIds), out propertyOverride); + if (Optional.IsCollectionDefined(StorageAccountIds) || hasPropertyOverride) + { + if (StorageAccountIds.Any() || hasPropertyOverride) + { + builder.Append(" storageAccountIds: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in StorageAccountIds) + { + if (item == null) + { + builder.Append("null"); + continue; + } + builder.AppendLine($" '{item.ToString()}'"); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -209,6 +363,8 @@ BinaryData IPersistableModel.Write { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(OperationalInsightsLinkedStorageAccountsData)} does not support '{options.Format}' format."); } @@ -225,6 +381,8 @@ OperationalInsightsLinkedStorageAccountsData IPersistableModel Linked storage accounts type. + [WirePath("properties.dataSourceType")] public OperationalInsightsDataSourceType? DataSourceType { get; } /// Linked storage accounts resources ids. + [WirePath("properties.storageAccountIds")] public IList StorageAccountIds { get; } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsSavedSearchData.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsSavedSearchData.Serialization.cs index 3b0b8e8554385..cebf2928a52cb 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsSavedSearchData.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsSavedSearchData.Serialization.cs @@ -8,9 +8,12 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.Models; using Azure.ResourceManager.OperationalInsights.Models; @@ -257,6 +260,276 @@ internal static OperationalInsightsSavedSearchData DeserializeOperationalInsight serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ETag), out propertyOverride); + if (Optional.IsDefined(ETag) || hasPropertyOverride) + { + builder.Append(" etag: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ETag.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Category), out propertyOverride); + if (Optional.IsDefined(Category) || hasPropertyOverride) + { + builder.Append(" category: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Category.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Category}'''"); + } + else + { + builder.AppendLine($"'{Category}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayName), out propertyOverride); + if (Optional.IsDefined(DisplayName) || hasPropertyOverride) + { + builder.Append(" displayName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (DisplayName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{DisplayName}'''"); + } + else + { + builder.AppendLine($"'{DisplayName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Query), out propertyOverride); + if (Optional.IsDefined(Query) || hasPropertyOverride) + { + builder.Append(" query: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Query.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Query}'''"); + } + else + { + builder.AppendLine($"'{Query}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FunctionAlias), out propertyOverride); + if (Optional.IsDefined(FunctionAlias) || hasPropertyOverride) + { + builder.Append(" functionAlias: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (FunctionAlias.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{FunctionAlias}'''"); + } + else + { + builder.AppendLine($"'{FunctionAlias}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FunctionParameters), out propertyOverride); + if (Optional.IsDefined(FunctionParameters) || hasPropertyOverride) + { + builder.Append(" functionParameters: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (FunctionParameters.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{FunctionParameters}'''"); + } + else + { + builder.AppendLine($"'{FunctionParameters}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Version), out propertyOverride); + if (Optional.IsDefined(Version) || hasPropertyOverride) + { + builder.Append(" version: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Version.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tags), out propertyOverride); + if (Optional.IsCollectionDefined(Tags) || hasPropertyOverride) + { + if (Tags.Any() || hasPropertyOverride) + { + builder.Append(" tags: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Tags) + { + AppendChildObject(builder, item, options, 6, true, " tags: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -265,6 +538,8 @@ BinaryData IPersistableModel.Write(ModelRead { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(OperationalInsightsSavedSearchData)} does not support '{options.Format}' format."); } @@ -281,6 +556,8 @@ OperationalInsightsSavedSearchData IPersistableModel The ETag of the saved search. To override an existing saved search, use "*" or specify the current Etag. + [WirePath("etag")] public ETag? ETag { get; set; } /// The category of the saved search. This helps the user to find a saved search faster. + [WirePath("properties.category")] public string Category { get; set; } /// Saved search display name. + [WirePath("properties.displayName")] public string DisplayName { get; set; } /// The query expression for the saved search. + [WirePath("properties.query")] public string Query { get; set; } /// The function alias if query serves as a function. + [WirePath("properties.functionAlias")] public string FunctionAlias { get; set; } /// The optional function parameters if query serves as a function. Value should be in the following format: 'param-name1:type1 = default_value1, param-name2:type2 = default_value2'. For more examples and proper syntax please refer to https://docs.microsoft.com/en-us/azure/kusto/query/functions/user-defined-functions. + [WirePath("properties.functionParameters")] public string FunctionParameters { get; set; } /// The version number of the query language. The current version is 2 and is the default. + [WirePath("properties.version")] public long? Version { get; set; } /// The tags attached to the saved search. + [WirePath("properties.tags")] public IList Tags { get; } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsTableData.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsTableData.Serialization.cs index 32d003c897c25..6dc9a50e00b6e 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsTableData.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsTableData.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.Models; using Azure.ResourceManager.OperationalInsights.Models; @@ -335,6 +337,294 @@ internal static OperationalInsightsTableData DeserializeOperationalInsightsTable serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RetentionInDays), out propertyOverride); + if (Optional.IsDefined(RetentionInDays) || hasPropertyOverride) + { + builder.Append(" retentionInDays: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{RetentionInDays.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TotalRetentionInDays), out propertyOverride); + if (Optional.IsDefined(TotalRetentionInDays) || hasPropertyOverride) + { + builder.Append(" totalRetentionInDays: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{TotalRetentionInDays.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ArchiveRetentionInDays), out propertyOverride); + if (Optional.IsDefined(ArchiveRetentionInDays) || hasPropertyOverride) + { + builder.Append(" archiveRetentionInDays: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{ArchiveRetentionInDays.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SearchResults), out propertyOverride); + if (Optional.IsDefined(SearchResults) || hasPropertyOverride) + { + builder.Append(" searchResults: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, SearchResults, options, 4, false, " searchResults: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RestoredLogs), out propertyOverride); + if (Optional.IsDefined(RestoredLogs) || hasPropertyOverride) + { + builder.Append(" restoredLogs: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, RestoredLogs, options, 4, false, " restoredLogs: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ResultStatistics), out propertyOverride); + if (Optional.IsDefined(ResultStatistics) || hasPropertyOverride) + { + builder.Append(" resultStatistics: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, ResultStatistics, options, 4, false, " resultStatistics: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Plan), out propertyOverride); + if (Optional.IsDefined(Plan) || hasPropertyOverride) + { + builder.Append(" plan: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Plan.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastPlanModifiedDate), out propertyOverride); + if (Optional.IsDefined(LastPlanModifiedDate) || hasPropertyOverride) + { + builder.Append(" lastPlanModifiedDate: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (LastPlanModifiedDate.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{LastPlanModifiedDate}'''"); + } + else + { + builder.AppendLine($"'{LastPlanModifiedDate}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Schema), out propertyOverride); + if (Optional.IsDefined(Schema) || hasPropertyOverride) + { + builder.Append(" schema: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Schema, options, 4, false, " schema: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); + if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) + { + builder.Append(" provisioningState: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ProvisioningState.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsRetentionInDaysAsDefault), out propertyOverride); + if (Optional.IsDefined(IsRetentionInDaysAsDefault) || hasPropertyOverride) + { + builder.Append(" retentionInDaysAsDefault: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsRetentionInDaysAsDefault.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsTotalRetentionInDaysAsDefault), out propertyOverride); + if (Optional.IsDefined(IsTotalRetentionInDaysAsDefault) || hasPropertyOverride) + { + builder.Append(" totalRetentionInDaysAsDefault: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsTotalRetentionInDaysAsDefault.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -343,6 +633,8 @@ BinaryData IPersistableModel.Write(ModelReaderWrit { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(OperationalInsightsTableData)} does not support '{options.Format}' format."); } @@ -359,6 +651,8 @@ OperationalInsightsTableData IPersistableModel.Cre using JsonDocument document = JsonDocument.Parse(data); return DeserializeOperationalInsightsTableData(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(OperationalInsightsTableData)} does not support '{options.Format}' format."); } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsTableData.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsTableData.cs index 10ee32b362dd4..5569dacddae4c 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsTableData.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsTableData.cs @@ -92,28 +92,40 @@ internal OperationalInsightsTableData(ResourceIdentifier id, string name, Resour } /// The table retention in days, between 4 and 730. Setting this property to -1 will default to the workspace retention. + [WirePath("properties.retentionInDays")] public int? RetentionInDays { get; set; } /// The table total retention in days, between 4 and 2556. Setting this property to -1 will default to table retention. + [WirePath("properties.totalRetentionInDays")] public int? TotalRetentionInDays { get; set; } /// The table data archive retention in days. Calculated as (totalRetentionInDays-retentionInDays). + [WirePath("properties.archiveRetentionInDays")] public int? ArchiveRetentionInDays { get; } /// Parameters of the search job that initiated this table. + [WirePath("properties.searchResults")] public OperationalInsightsTableSearchResults SearchResults { get; set; } /// Parameters of the restore operation that initiated this table. + [WirePath("properties.restoredLogs")] public OperationalInsightsTableRestoredLogs RestoredLogs { get; set; } /// Search job execution statistics. + [WirePath("properties.resultStatistics")] public OperationalInsightsTableResultStatistics ResultStatistics { get; } /// Instruct the system how to handle and charge the logs ingested to this table. + [WirePath("properties.plan")] public OperationalInsightsTablePlan? Plan { get; set; } /// The timestamp that table plan was last modified (UTC). + [WirePath("properties.lastPlanModifiedDate")] public string LastPlanModifiedDate { get; } /// Table schema. + [WirePath("properties.schema")] public OperationalInsightsSchema Schema { get; set; } /// Table's current provisioning state. If set to 'updating', indicates a resource lock due to ongoing operation, forbidding any update to the table until the ongoing operation is concluded. + [WirePath("properties.provisioningState")] public OperationalInsightsTableProvisioningState? ProvisioningState { get; } /// True - Value originates from workspace retention in days, False - Customer specific. + [WirePath("properties.retentionInDaysAsDefault")] public bool? IsRetentionInDaysAsDefault { get; } /// True - Value originates from retention in days, False - Customer specific. + [WirePath("properties.totalRetentionInDaysAsDefault")] public bool? IsTotalRetentionInDaysAsDefault { get; } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsWorkspaceData.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsWorkspaceData.Serialization.cs index 8c39a3ac72b2d..264cc3cf64242 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsWorkspaceData.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsWorkspaceData.Serialization.cs @@ -8,9 +8,12 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.Models; using Azure.ResourceManager.OperationalInsights.Models; @@ -442,6 +445,384 @@ internal static OperationalInsightsWorkspaceData DeserializeOperationalInsightsW serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); + builder.Append(" location: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Location.ToString()}'"); + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tags), out propertyOverride); + if (Optional.IsCollectionDefined(Tags) || hasPropertyOverride) + { + if (Tags.Any() || hasPropertyOverride) + { + builder.Append(" tags: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("{"); + foreach (var item in Tags) + { + builder.Append($" '{item.Key}': "); + if (item.Value == null) + { + builder.Append("null"); + continue; + } + if (item.Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{item.Value}'''"); + } + else + { + builder.AppendLine($"'{item.Value}'"); + } + } + builder.AppendLine(" }"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Identity), out propertyOverride); + if (Optional.IsDefined(Identity) || hasPropertyOverride) + { + builder.Append(" identity: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Identity, options, 2, false, " identity: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ETag), out propertyOverride); + if (Optional.IsDefined(ETag) || hasPropertyOverride) + { + builder.Append(" etag: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ETag.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); + if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) + { + builder.Append(" provisioningState: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ProvisioningState.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CustomerId), out propertyOverride); + if (Optional.IsDefined(CustomerId) || hasPropertyOverride) + { + builder.Append(" customerId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{CustomerId.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Sku), out propertyOverride); + if (Optional.IsDefined(Sku) || hasPropertyOverride) + { + builder.Append(" sku: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Sku, options, 4, false, " sku: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RetentionInDays), out propertyOverride); + if (Optional.IsDefined(RetentionInDays) || hasPropertyOverride) + { + builder.Append(" retentionInDays: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{RetentionInDays.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(WorkspaceCapping), out propertyOverride); + if (Optional.IsDefined(WorkspaceCapping) || hasPropertyOverride) + { + builder.Append(" workspaceCapping: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, WorkspaceCapping, options, 4, false, " workspaceCapping: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); + if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) + { + builder.Append(" createdDate: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ModifiedOn), out propertyOverride); + if (Optional.IsDefined(ModifiedOn) || hasPropertyOverride) + { + builder.Append(" modifiedDate: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(ModifiedOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PublicNetworkAccessForIngestion), out propertyOverride); + if (Optional.IsDefined(PublicNetworkAccessForIngestion) || hasPropertyOverride) + { + builder.Append(" publicNetworkAccessForIngestion: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{PublicNetworkAccessForIngestion.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PublicNetworkAccessForQuery), out propertyOverride); + if (Optional.IsDefined(PublicNetworkAccessForQuery) || hasPropertyOverride) + { + builder.Append(" publicNetworkAccessForQuery: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{PublicNetworkAccessForQuery.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ForceCmkForQuery), out propertyOverride); + if (Optional.IsDefined(ForceCmkForQuery) || hasPropertyOverride) + { + builder.Append(" forceCmkForQuery: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = ForceCmkForQuery.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrivateLinkScopedResources), out propertyOverride); + if (Optional.IsCollectionDefined(PrivateLinkScopedResources) || hasPropertyOverride) + { + if (PrivateLinkScopedResources.Any() || hasPropertyOverride) + { + builder.Append(" privateLinkScopedResources: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in PrivateLinkScopedResources) + { + AppendChildObject(builder, item, options, 6, true, " privateLinkScopedResources: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Features), out propertyOverride); + if (Optional.IsDefined(Features) || hasPropertyOverride) + { + builder.Append(" features: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Features, options, 4, false, " features: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DefaultDataCollectionRuleResourceId), out propertyOverride); + if (Optional.IsDefined(DefaultDataCollectionRuleResourceId) || hasPropertyOverride) + { + builder.Append(" defaultDataCollectionRuleResourceId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{DefaultDataCollectionRuleResourceId.ToString()}'"); + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -450,6 +831,8 @@ BinaryData IPersistableModel.Write(ModelReader { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(OperationalInsightsWorkspaceData)} does not support '{options.Format}' format."); } @@ -466,6 +849,8 @@ OperationalInsightsWorkspaceData IPersistableModel The identity of the resource. Current supported identity types: None, SystemAssigned, UserAssigned. + [WirePath("identity")] public ManagedServiceIdentity Identity { get; set; } /// The etag of the workspace. + [WirePath("etag")] public ETag? ETag { get; set; } /// The provisioning state of the workspace. + [WirePath("properties.provisioningState")] public OperationalInsightsWorkspaceEntityStatus? ProvisioningState { get; } /// This is a read-only property. Represents the ID associated with the workspace. + [WirePath("properties.customerId")] public Guid? CustomerId { get; } /// The SKU of the workspace. + [WirePath("properties.sku")] public OperationalInsightsWorkspaceSku Sku { get; set; } /// The workspace data retention in days. Allowed values are per pricing plan. See pricing tiers documentation for details. + [WirePath("properties.retentionInDays")] public int? RetentionInDays { get; set; } /// The daily volume cap for ingestion. + [WirePath("properties.workspaceCapping")] public OperationalInsightsWorkspaceCapping WorkspaceCapping { get; set; } /// Workspace creation date. + [WirePath("properties.createdDate")] public DateTimeOffset? CreatedOn { get; } /// Workspace modification date. + [WirePath("properties.modifiedDate")] public DateTimeOffset? ModifiedOn { get; } /// The network access type for accessing Log Analytics ingestion. + [WirePath("properties.publicNetworkAccessForIngestion")] public OperationalInsightsPublicNetworkAccessType? PublicNetworkAccessForIngestion { get; set; } /// The network access type for accessing Log Analytics query. + [WirePath("properties.publicNetworkAccessForQuery")] public OperationalInsightsPublicNetworkAccessType? PublicNetworkAccessForQuery { get; set; } /// Indicates whether customer managed storage is mandatory for query management. + [WirePath("properties.forceCmkForQuery")] public bool? ForceCmkForQuery { get; set; } /// List of linked private link scope resources. + [WirePath("properties.privateLinkScopedResources")] public IReadOnlyList PrivateLinkScopedResources { get; } /// Workspace features. + [WirePath("properties.features")] public OperationalInsightsWorkspaceFeatures Features { get; set; } /// The resource ID of the default Data Collection Rule to use for this workspace. Expected format is - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dcrName}. + [WirePath("properties.defaultDataCollectionRuleResourceId")] public ResourceIdentifier DefaultDataCollectionRuleResourceId { get; set; } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/StorageInsightData.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/StorageInsightData.Serialization.cs index c427d3e996f6b..667a76064f3a2 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/StorageInsightData.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/StorageInsightData.Serialization.cs @@ -8,9 +8,12 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.Models; using Azure.ResourceManager.OperationalInsights.Models; @@ -275,6 +278,264 @@ internal static StorageInsightData DeserializeStorageInsightData(JsonElement ele serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tags), out propertyOverride); + if (Optional.IsCollectionDefined(Tags) || hasPropertyOverride) + { + if (Tags.Any() || hasPropertyOverride) + { + builder.Append(" tags: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("{"); + foreach (var item in Tags) + { + builder.Append($" '{item.Key}': "); + if (item.Value == null) + { + builder.Append("null"); + continue; + } + if (item.Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{item.Value}'''"); + } + else + { + builder.AppendLine($"'{item.Value}'"); + } + } + builder.AppendLine(" }"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ETag), out propertyOverride); + if (Optional.IsDefined(ETag) || hasPropertyOverride) + { + builder.Append(" eTag: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ETag.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Containers), out propertyOverride); + if (Optional.IsCollectionDefined(Containers) || hasPropertyOverride) + { + if (Containers.Any() || hasPropertyOverride) + { + builder.Append(" containers: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Containers) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tables), out propertyOverride); + if (Optional.IsCollectionDefined(Tables) || hasPropertyOverride) + { + if (Tables.Any() || hasPropertyOverride) + { + builder.Append(" tables: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Tables) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageAccount), out propertyOverride); + if (Optional.IsDefined(StorageAccount) || hasPropertyOverride) + { + builder.Append(" storageAccount: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, StorageAccount, options, 4, false, " storageAccount: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); + if (Optional.IsDefined(Status) || hasPropertyOverride) + { + builder.Append(" status: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Status, options, 4, false, " status: "); + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -283,6 +544,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(StorageInsightData)} does not support '{options.Format}' format."); } @@ -299,6 +562,8 @@ StorageInsightData IPersistableModel.Create(BinaryData data, using JsonDocument document = JsonDocument.Parse(data); return DeserializeStorageInsightData(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(StorageInsightData)} does not support '{options.Format}' format."); } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/StorageInsightData.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/StorageInsightData.cs index 305015c4c330f..68207644f0114 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/StorageInsightData.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/StorageInsightData.cs @@ -84,16 +84,22 @@ internal StorageInsightData(ResourceIdentifier id, string name, ResourceType res } /// The ETag of the storage insight. + [WirePath("eTag")] public ETag? ETag { get; set; } /// Resource tags. + [WirePath("tags")] public IDictionary Tags { get; } /// The names of the blob containers that the workspace should read. + [WirePath("properties.containers")] public IList Containers { get; } /// The names of the Azure tables that the workspace should read. + [WirePath("properties.tables")] public IList Tables { get; } /// The storage account connection details. + [WirePath("properties.storageAccount")] public OperationalInsightsStorageAccount StorageAccount { get; set; } /// The status of the storage insight. + [WirePath("properties.status")] public StorageInsightStatus Status { get; } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/autorest.md b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/autorest.md index 4d543a86c21ed..2f029b7486304 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/autorest.md +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/autorest.md @@ -17,6 +17,7 @@ skip-csproj: true modelerfour: flatten-payloads: false use-model-reader-writer: true +enable-bicep-serialization: true # mgmt-debug: # show-serialized-names: true From 57cf52216152b932722458d1337fc19570d74064 Mon Sep 17 00:00:00 2001 From: jolov Date: Thu, 14 Mar 2024 15:16:00 -0700 Subject: [PATCH 02/10] bump autorest --- eng/Packages.Data.props | 2 +- eng/emitter-package-lock.json | 16 ++++++++-------- eng/emitter-package.json | 14 +++++++------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/eng/Packages.Data.props b/eng/Packages.Data.props index 3e9cdbd35a061..8e15202ded99b 100644 --- a/eng/Packages.Data.props +++ b/eng/Packages.Data.props @@ -218,7 +218,7 @@ All should have PrivateAssets="All" set so they don't become package dependencies --> - + diff --git a/eng/emitter-package-lock.json b/eng/emitter-package-lock.json index 84c100bf6ef78..6894d3c440a90 100644 --- a/eng/emitter-package-lock.json +++ b/eng/emitter-package-lock.json @@ -5,7 +5,7 @@ "packages": { "": { "dependencies": { - "@azure-tools/typespec-csharp": "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js-test-autorest@local/npm/registry/@azure-tools/typespec-csharp/-/typespec-csharp-0.2.0-alpha.20240309.3.tgz" + "@azure-tools/typespec-csharp": "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js-test-autorest@local/npm/registry/@azure-tools/typespec-csharp/-/typespec-csharp-0.2.0-alpha.20240314.7.tgz" }, "devDependencies": { "@azure-tools/typespec-azure-core": "0.40.0", @@ -18,9 +18,9 @@ } }, "node_modules/@autorest/csharp": { - "version": "3.0.0-alpha.20240309.3", - "resolved": "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js-test-autorest@local/npm/registry/@autorest/csharp/-/csharp-3.0.0-alpha.20240309.3.tgz", - "integrity": "sha512-SFWybZFXyafj3LIofM+sR0FEG6/6SawWMGmBAjwGkYcsyFPSc/8LUvIrbfBh2mvNAdM8/LsvOK+BqFOXodFr1A==" + "version": "3.0.0-alpha.20240314.7", + "resolved": "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js-test-autorest@local/npm/registry/@autorest/csharp/-/csharp-3.0.0-alpha.20240314.7.tgz", + "integrity": "sha512-9yVqpNi/oaeWTL4mFlQ05qAsolB0WsGfZbYQRoQ6DBOglm2ExxPug3cqaLzqbHfuM6DIVN2ZmUUhJYQ+8mW1fA==" }, "node_modules/@azure-tools/typespec-azure-core": { "version": "0.40.0", @@ -56,12 +56,12 @@ } }, "node_modules/@azure-tools/typespec-csharp": { - "version": "0.2.0-alpha.20240309.3", - "resolved": "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js-test-autorest@local/npm/registry/@azure-tools/typespec-csharp/-/typespec-csharp-0.2.0-alpha.20240309.3.tgz", - "integrity": "sha512-510YLqTKdKbBd9Mk2X8p9kB5YzWdyo9Op7x4+vJGWWSEedskchzcm0j9yGUoToAJlIh6haL2/arFZDZDJNH/Kw==", + "version": "0.2.0-alpha.20240314.7", + "resolved": "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js-test-autorest@local/npm/registry/@azure-tools/typespec-csharp/-/typespec-csharp-0.2.0-alpha.20240314.7.tgz", + "integrity": "sha512-Bngs16BOlrDJvl4os/eBpGdmHtYjXKzbuKX4Hmis6QdyEFj3xCRcSyXs6E8I2CzXXSF2G4XTShzF7V6NUIkduA==", "license": "MIT", "dependencies": { - "@autorest/csharp": "3.0.0-alpha.20240309.3", + "@autorest/csharp": "3.0.0-alpha.20240314.7", "json-serialize-refs": "0.1.0-0", "winston": "^3.8.2" }, diff --git a/eng/emitter-package.json b/eng/emitter-package.json index 0cc173ef59086..92b67e2f9ee61 100644 --- a/eng/emitter-package.json +++ b/eng/emitter-package.json @@ -1,18 +1,18 @@ { "main": "dist/src/index.js", "dependencies": { - "@azure-tools/typespec-csharp": "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js-test-autorest@local/npm/registry/@azure-tools/typespec-csharp/-/typespec-csharp-0.2.0-alpha.20240309.3.tgz" + "@azure-tools/typespec-csharp": "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js-test-autorest@local/npm/registry/@azure-tools/typespec-csharp/-/typespec-csharp-0.2.0-alpha.20240314.7.tgz" }, "devDependencies": { - "@typespec/rest": "0.54.0", + "@azure-tools/typespec-client-generator-core": "0.40.0", + "@typespec/http": "0.54.0", + "@typespec/compiler": "0.54.0", "@typespec/versioning": "0.54.0", + "@typespec/rest": "0.54.0", "@azure-tools/typespec-azure-core": "0.40.0", - "@typespec/http": "0.54.0", - "@azure-tools/typespec-client-generator-core": "0.40.0", - "@typespec/openapi": "0.54.0", - "@typespec/compiler": "0.54.0" + "@typespec/openapi": "0.54.0" }, "overrides": { - "@autorest/csharp": "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js-test-autorest@local/npm/registry/@autorest/csharp/-/csharp-3.0.0-alpha.20240309.3.tgz" + "@autorest/csharp": "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js-test-autorest@local/npm/registry/@autorest/csharp/-/csharp-3.0.0-alpha.20240314.7.tgz" } } \ No newline at end of file From 5ff8453abb1c7a8a62ae4ff197d884603a75af9a Mon Sep 17 00:00:00 2001 From: jolov Date: Thu, 14 Mar 2024 15:20:14 -0700 Subject: [PATCH 03/10] regen --- ...ontainerAppAuthConfigData.Serialization.cs | 52 +- ...ntainerAppCertificateData.Serialization.cs | 44 +- ...pConnectedEnvironmentData.Serialization.cs | 46 +- ...tedEnvironmentStorageData.Serialization.cs | 44 +- ...ainerAppDaprComponentData.Serialization.cs | 46 +- .../ContainerAppData.Serialization.cs | 50 +- ...ontainerAppDiagnosticData.Serialization.cs | 44 +- .../ContainerAppJobData.Serialization.cs | 48 +- ...tainerAppJobExecutionData.Serialization.cs | 44 +- ...AppManagedCertificateData.Serialization.cs | 44 +- ...AppManagedEnvironmentData.Serialization.cs | 56 +-- ...gedEnvironmentStorageData.Serialization.cs | 44 +- .../ContainerAppReplicaData.Serialization.cs | 46 +- .../ContainerAppRevisionData.Serialization.cs | 44 +- ...ainerAppSourceControlData.Serialization.cs | 44 +- .../Internal/BicepSerializationHelpers.cs | 58 +++ .../Internal/ChangeTrackingDictionary.cs | 167 +++++++ .../src/Generated/Internal/Optional.cs | 1 - .../Internal/Utf8JsonRequestContent.cs | 55 +++ ...llowedAudiencesValidation.Serialization.cs | 42 -- .../AppContainerResources.Serialization.cs | 42 -- .../AuthConfigCollection.Serialization.cs | 44 +- ...orkloadProfilesCollection.Serialization.cs | 44 +- ...StaticWebAppsRegistration.Serialization.cs | 42 -- .../BillingMeterCollection.Serialization.cs | 44 +- .../CertificateCollection.Serialization.cs | 44 +- ...ctedEnvironmentCollection.Serialization.cs | 44 +- ...ironmentStorageProperties.Serialization.cs | 44 +- ...ronmentStoragesCollection.Serialization.cs | 44 +- ...ainerAppAllowedPrincipals.Serialization.cs | 42 -- ...inerAppAppleConfiguration.Serialization.cs | 46 +- ...RegistrationConfiguration.Serialization.cs | 42 -- .../ContainerAppAuthPlatform.Serialization.cs | 42 -- .../ContainerAppAuthToken.Serialization.cs | 42 -- ...pAvailableWorkloadProfile.Serialization.cs | 44 +- ...WorkloadProfileProperties.Serialization.cs | 42 -- ...iveDirectoryConfiguration.Serialization.cs | 48 +- ...rectoryLoginConfiguration.Serialization.cs | 42 -- ...RegistrationConfiguration.Serialization.cs | 42 -- ...ryValidationConfiguration.Serialization.cs | 46 +- ...nerAppAzureFileProperties.Serialization.cs | 42 -- ...taticWebAppsConfiguration.Serialization.cs | 44 +- ...ContainerAppBaseContainer.Serialization.cs | 72 +-- .../ContainerAppBillingMeter.Serialization.cs | 44 +- ...AppBillingMeterProperties.Serialization.cs | 42 -- .../Models/ContainerAppCertificatePatch.cs | 2 +- ...rAppCertificateProperties.Serialization.cs | 42 -- ...inerAppClientRegistration.Serialization.cs | 42 -- .../ContainerAppCollection.Serialization.cs | 44 +- ...ContainerAppConfiguration.Serialization.cs | 52 +- .../ContainerAppContainer.Serialization.cs | 94 +--- ...tainerAppCookieExpiration.Serialization.cs | 42 -- .../ContainerAppCorsPolicy.Serialization.cs | 42 -- .../ContainerAppCredentials.Serialization.cs | 42 -- .../ContainerAppCustomDomain.Serialization.cs | 42 -- ...CustomDomainConfiguration.Serialization.cs | 42 -- ...inVerificationFailureInfo.Serialization.cs | 44 +- ...ionFailureInfoDetailsItem.Serialization.cs | 42 -- ...tomHostnameAnalysisResult.Serialization.cs | 44 +- ...nectProviderConfiguration.Serialization.cs | 46 +- ...ntainerAppCustomScaleRule.Serialization.cs | 66 +-- .../Models/ContainerAppCustomScaleRule.cs | 1 - ...ainerAppDaprConfiguration.Serialization.cs | 42 -- .../ContainerAppDaprMetadata.Serialization.cs | 42 -- .../ContainerAppDaprSecret.Serialization.cs | 42 -- ...efaultAuthorizationPolicy.Serialization.cs | 44 +- ...erAppDiagnosticDataColumn.Serialization.cs | 42 -- ...osticDataProviderMetadata.Serialization.cs | 44 +- ...erMetadataPropertyBagItem.Serialization.cs | 42 -- ...DiagnosticDataTableResult.Serialization.cs | 44 +- ...nerAppDiagnosticRendering.Serialization.cs | 56 +-- ...AppDiagnosticSupportTopic.Serialization.cs | 42 -- ...pDiagnosticsDataApiResult.Serialization.cs | 46 +- ...nerAppDiagnosticsMetadata.Serialization.cs | 44 +- ...rAppDiagnosticsProperties.Serialization.cs | 50 +- ...ainerAppDiagnosticsStatus.Serialization.cs | 42 -- ...erAppEnvironmentAuthToken.Serialization.cs | 42 -- ...nerAppEnvironmentVariable.Serialization.cs | 42 -- ...tainerAppExtendedLocation.Serialization.cs | 46 +- ...rAppFacebookConfiguration.Serialization.cs | 46 +- .../ContainerAppForwardProxy.Serialization.cs | 42 -- ...GitHubActionConfiguration.Serialization.cs | 46 +- ...nerAppGitHubConfiguration.Serialization.cs | 46 +- ...tainerAppGlobalValidation.Serialization.cs | 42 -- ...nerAppGoogleConfiguration.Serialization.cs | 48 +- ...ontainerAppHttpHeaderInfo.Serialization.cs | 42 -- ...ntainerAppHttpRequestInfo.Serialization.cs | 44 +- ...ContainerAppHttpScaleRule.Serialization.cs | 44 +- .../Models/ContainerAppHttpScaleRule.cs | 1 - .../ContainerAppHttpSettings.Serialization.cs | 46 +- ...IPSecurityRestrictionRule.Serialization.cs | 42 -- ...ityProvidersConfiguration.Serialization.cs | 58 +-- ...tainerAppIdentityProvidersConfiguration.cs | 2 +- ...erAppIngressConfiguration.Serialization.cs | 52 +- ...ContainerAppInitContainer.Serialization.cs | 72 +-- ...tainerAppJobConfiguration.Serialization.cs | 52 +- ...tainerAppJobExecutionBase.Serialization.cs | 42 -- ...erAppJobExecutionTemplate.Serialization.cs | 46 +- ...ContainerAppJobExecutions.Serialization.cs | 44 +- .../Generated/Models/ContainerAppJobPatch.cs | 2 +- .../ContainerAppJobScale.Serialization.cs | 44 +- .../ContainerAppJobScaleRule.Serialization.cs | 66 +-- .../ContainerAppJobTemplate.Serialization.cs | 48 +- ...ontainerAppJobsCollection.Serialization.cs | 44 +- ...ontainerAppJwtClaimChecks.Serialization.cs | 42 -- ...LogAnalyticsConfiguration.Serialization.cs | 42 -- .../Models/ContainerAppLogin.Serialization.cs | 48 +- .../ContainerAppLoginNonce.Serialization.cs | 42 -- ...ainerAppLogsConfiguration.Serialization.cs | 44 +- .../ContainerAppManagedCertificatePatch.cs | 2 +- ...AppNameAvailabilityResult.Serialization.cs | 42 -- ...IdConnectClientCredential.Serialization.cs | 42 -- ...nerAppOpenIdConnectConfig.Serialization.cs | 42 -- ...inerAppOpenIdConnectLogin.Serialization.cs | 42 -- ...OpenIdConnectRegistration.Serialization.cs | 46 +- .../Models/ContainerAppProbe.Serialization.cs | 50 +- ...ontainerAppQueueScaleRule.Serialization.cs | 44 +- .../ContainerAppRegistration.Serialization.cs | 42 -- ...nerAppRegistryCredentials.Serialization.cs | 42 -- .../ContainerAppRegistryInfo.Serialization.cs | 42 -- ...tainerAppReplicaContainer.Serialization.cs | 42 -- ...rAppRevisionTrafficWeight.Serialization.cs | 42 -- .../Models/ContainerAppScale.Serialization.cs | 44 +- .../ContainerAppScaleRule.Serialization.cs | 50 +- ...ContainerAppScaleRuleAuth.Serialization.cs | 42 -- .../ContainerAppSecret.Serialization.cs | 42 -- .../ContainerAppServiceBind.Serialization.cs | 70 +-- .../ContainerAppTcpScaleRule.Serialization.cs | 44 +- .../Models/ContainerAppTcpScaleRule.cs | 1 - ...erAppTcpSocketRequestInfo.Serialization.cs | 42 -- .../ContainerAppTemplate.Serialization.cs | 52 +- ...erAppTwitterConfiguration.Serialization.cs | 44 +- ...nerAppTwitterRegistration.Serialization.cs | 42 -- ...ainerAppVnetConfiguration.Serialization.cs | 42 -- .../ContainerAppVolume.Serialization.cs | 44 +- .../ContainerAppVolumeMount.Serialization.cs | 42 -- ...ntainerAppWorkloadProfile.Serialization.cs | 42 -- ...erAppWorkloadProfileState.Serialization.cs | 44 +- ...oadProfileStateProperties.Serialization.cs | 42 -- ...ontainerAppWritableSecret.Serialization.cs | 42 -- .../DaprComponentsCollection.Serialization.cs | 44 +- .../Models/DaprConfiguration.Serialization.cs | 42 -- .../DaprSecretsCollection.Serialization.cs | 44 +- .../DiagnosticsCollection.Serialization.cs | 44 +- ...EventTriggerConfiguration.Serialization.cs | 44 +- .../HttpSettingsRoutes.Serialization.cs | 42 -- .../IngressStickySessions.Serialization.cs | 42 -- ...rationManualTriggerConfig.Serialization.cs | 42 -- ...tionScheduleTriggerConfig.Serialization.cs | 42 -- .../JobExecutionContainer.Serialization.cs | 70 +-- .../JobSecretsCollection.Serialization.cs | 44 +- .../Models/KedaConfiguration.Serialization.cs | 42 -- .../Models/LoginRoutes.Serialization.cs | 42 -- .../Models/LoginScopes.Serialization.cs | 42 -- ...agedCertificateCollection.Serialization.cs | 44 +- ...agedCertificateProperties.Serialization.cs | 42 -- ...pertiesPeerAuthentication.Serialization.cs | 44 +- ...ironmentStorageProperties.Serialization.cs | 44 +- ...ronmentStoragesCollection.Serialization.cs | 44 +- ...gedEnvironmentsCollection.Serialization.cs | 44 +- .../Generated/Models/Mtls.Serialization.cs | 42 -- .../Models/ReplicaCollection.Serialization.cs | 44 +- .../RevisionCollection.Serialization.cs | 44 +- .../Models/SecretVolumeItem.Serialization.cs | 42 -- .../Models/SecretsCollection.Serialization.cs | 44 +- .../Generated/Models/Service.Serialization.cs | 55 +-- .../SourceControlCollection.Serialization.cs | 44 +- ...adProfileStatesCollection.Serialization.cs | 44 +- ...inerRegistryAgentPoolData.Serialization.cs | 200 ++++++++ .../ContainerRegistryAgentPoolData.cs | 5 + .../ContainerRegistryData.Serialization.cs | 386 +++++++++++++++ .../src/Generated/ContainerRegistryData.cs | 16 + ...ateEndpointConnectionData.Serialization.cs | 116 +++++ ...erRegistryPrivateEndpointConnectionData.cs | 3 + ...ryPrivateLinkResourceData.Serialization.cs | 167 +++++++ ...ontainerRegistryPrivateLinkResourceData.cs | 3 + ...erRegistryReplicationData.Serialization.cs | 179 +++++++ .../ContainerRegistryReplicationData.cs | 4 + .../ContainerRegistryRunData.Serialization.cs | 465 ++++++++++++++++++ .../src/Generated/ContainerRegistryRunData.cs | 22 + ...ContainerRegistryTaskData.Serialization.cs | 322 ++++++++++++ .../Generated/ContainerRegistryTaskData.cs | 13 + ...tainerRegistryTaskRunData.Serialization.cs | 166 +++++++ .../Generated/ContainerRegistryTaskRunData.cs | 6 + ...ontainerRegistryTokenData.Serialization.cs | 145 ++++++ .../Generated/ContainerRegistryTokenData.cs | 5 + ...tainerRegistryWebhookData.Serialization.cs | 194 ++++++++ .../Generated/ContainerRegistryWebhookData.cs | 4 + .../Internal/BicepSerializationHelpers.cs | 58 +++ .../Internal/ChangeTrackingDictionary.cs | 167 +++++++ .../src/Generated/Internal/Optional.cs | 1 - .../Internal/Utf8JsonRequestContent.cs | 55 +++ .../Generated/Internal/WirePathAttribute.cs | 27 + ...gistryAgentPoolListResult.Serialization.cs | 66 +++ .../Models/ContainerRegistryAgentPoolPatch.cs | 4 +- ...istryAgentPoolQueueStatus.Serialization.cs | 35 ++ .../ContainerRegistryAgentPoolQueueStatus.cs | 1 + ...erRegistryAgentProperties.Serialization.cs | 35 ++ .../ContainerRegistryAgentProperties.cs | 1 + ...gistryBaseImageDependency.Serialization.cs | 123 +++++ .../ContainerRegistryBaseImageDependency.cs | 5 + ...rRegistryBaseImageTrigger.Serialization.cs | 104 ++++ .../ContainerRegistryBaseImageTrigger.cs | 5 + ...erRegistryBaseImageTriggerUpdateContent.cs | 5 + ...inerRegistryCredentialRegenerateContent.cs | 1 + ...tainerRegistryCredentials.Serialization.cs | 59 +++ .../Models/ContainerRegistryCredentials.cs | 4 +- ...egistryDockerBuildContent.Serialization.cs | 312 ++++++++++++ .../ContainerRegistryDockerBuildContent.cs | 11 + ...erRegistryDockerBuildStep.Serialization.cs | 230 +++++++++ .../ContainerRegistryDockerBuildStep.cs | 6 + ...nerRegistryDockerBuildStepUpdateContent.cs | 6 + ...stryEncodedTaskRunContent.Serialization.cs | 247 ++++++++++ .../ContainerRegistryEncodedTaskRunContent.cs | 8 + ...erRegistryEncodedTaskStep.Serialization.cs | 165 +++++++ .../ContainerRegistryEncodedTaskStep.cs | 3 + ...nerRegistryEncodedTaskStepUpdateContent.cs | 3 + ...ntainerRegistryEncryption.Serialization.cs | 49 ++ .../Models/ContainerRegistryEncryption.cs | 2 + ...ainerRegistryExportPolicy.Serialization.cs | 35 ++ .../Models/ContainerRegistryExportPolicy.cs | 1 + ...egistryFileTaskRunContent.Serialization.cs | 247 ++++++++++ .../ContainerRegistryFileTaskRunContent.cs | 8 + ...ainerRegistryFileTaskStep.Serialization.cs | 165 +++++++ .../Models/ContainerRegistryFileTaskStep.cs | 3 + ...tainerRegistryFileTaskStepUpdateContent.cs | 3 + ...ainerRegistryGenerateCredentialsContent.cs | 3 + ...GenerateCredentialsResult.Serialization.cs | 66 +++ ...tainerRegistryGenerateCredentialsResult.cs | 2 + .../ContainerRegistryIPRule.Serialization.cs | 57 +++ .../Models/ContainerRegistryIPRule.cs | 2 + ...erRegistryImageDescriptor.Serialization.cs | 109 ++++ .../ContainerRegistryImageDescriptor.cs | 4 + ...egistryImageUpdateTrigger.Serialization.cs | 73 +++ .../ContainerRegistryImageUpdateTrigger.cs | 3 + .../ContainerRegistryImportImageContent.cs | 4 + .../Models/ContainerRegistryImportSource.cs | 4 + ...ontainerRegistryImportSourceCredentials.cs | 2 + ...egistryKeyVaultProperties.Serialization.cs | 117 +++++ .../ContainerRegistryKeyVaultProperties.cs | 5 + ...stryListCredentialsResult.Serialization.cs | 66 +++ .../ContainerRegistryListCredentialsResult.cs | 2 + ...ntainerRegistryListResult.Serialization.cs | 66 +++ ...ontainerRegistryNameAvailabilityContent.cs | 2 + ...gistryNameAvailableResult.Serialization.cs | 80 +++ .../ContainerRegistryNameAvailableResult.cs | 3 + ...nerRegistryNetworkRuleSet.Serialization.cs | 55 +++ .../Models/ContainerRegistryNetworkRuleSet.cs | 2 + ...verrideTaskStepProperties.Serialization.cs | 154 ++++++ ...ainerRegistryOverrideTaskStepProperties.cs | 6 + ...ContainerRegistryPassword.Serialization.cs | 57 +++ .../Models/ContainerRegistryPassword.cs | 2 + .../Models/ContainerRegistryPatch.cs | 12 +- ...egistryPlatformProperties.Serialization.cs | 60 +++ .../ContainerRegistryPlatformProperties.cs | 3 + .../ContainerRegistryPlatformUpdateContent.cs | 3 + ...ContainerRegistryPolicies.Serialization.cs | 77 +++ .../Models/ContainerRegistryPolicies.cs | 4 + ...pointConnectionListResult.Serialization.cs | 66 +++ ...ateLinkResourceListResult.Serialization.cs | 66 +++ ...inkServiceConnectionState.Serialization.cs | 71 +++ ...gistryPrivateLinkServiceConnectionState.cs | 3 + ...rRegistryQuarantinePolicy.Serialization.cs | 35 ++ .../ContainerRegistryQuarantinePolicy.cs | 1 + ...stryReplicationListResult.Serialization.cs | 66 +++ .../ContainerRegistryReplicationPatch.cs | 4 +- ...nerRegistryResourceStatus.Serialization.cs | 80 +++ .../Models/ContainerRegistryResourceStatus.cs | 3 + ...erRegistryRetentionPolicy.Serialization.cs | 64 +++ .../ContainerRegistryRetentionPolicy.cs | 3 + ...tainerRegistryRunArgument.Serialization.cs | 80 +++ .../Models/ContainerRegistryRunArgument.cs | 3 + ...ntainerRegistryRunContent.Serialization.cs | 103 ++++ .../Models/ContainerRegistryRunContent.cs | 3 + ...erRegistryRunGetLogResult.Serialization.cs | 65 +++ .../ContainerRegistryRunGetLogResult.cs | 2 + ...inerRegistryRunListResult.Serialization.cs | 66 +++ .../Models/ContainerRegistryRunPatch.cs | 1 + ...ainerRegistrySecretObject.Serialization.cs | 57 +++ .../Models/ContainerRegistrySecretObject.cs | 2 + .../ContainerRegistrySku.Serialization.cs | 46 ++ .../Generated/Models/ContainerRegistrySku.cs | 2 + ...inerRegistrySourceTrigger.Serialization.cs | 94 ++++ .../Models/ContainerRegistrySourceTrigger.cs | 4 + ...rySourceTriggerDescriptor.Serialization.cs | 159 ++++++ ...ontainerRegistrySourceTriggerDescriptor.cs | 7 + ...ainerRegistrySourceTriggerUpdateContent.cs | 4 + ...nerRegistryTaskListResult.Serialization.cs | 66 +++ ...istryTaskOverridableValue.Serialization.cs | 80 +++ .../ContainerRegistryTaskOverridableValue.cs | 3 + .../Models/ContainerRegistryTaskPatch.cs | 13 +- ...nerRegistryTaskRunContent.Serialization.cs | 130 +++++ .../Models/ContainerRegistryTaskRunContent.cs | 2 + ...RegistryTaskRunListResult.Serialization.cs | 66 +++ .../Models/ContainerRegistryTaskRunPatch.cs | 6 + ...egistryTaskStepProperties.Serialization.cs | 100 ++++ .../ContainerRegistryTaskStepProperties.cs | 3 + .../ContainerRegistryTaskStepUpdateContent.cs | 2 + ...ainerRegistryTimerTrigger.Serialization.cs | 79 +++ .../Models/ContainerRegistryTimerTrigger.cs | 3 + ...tryTimerTriggerDescriptor.Serialization.cs | 65 +++ ...ContainerRegistryTimerTriggerDescriptor.cs | 2 + ...tainerRegistryTimerTriggerUpdateContent.cs | 3 + ...rRegistryTokenCertificate.Serialization.cs | 94 ++++ .../ContainerRegistryTokenCertificate.cs | 4 + ...rRegistryTokenCredentials.Serialization.cs | 66 +++ .../ContainerRegistryTokenCredentials.cs | 2 + ...erRegistryTokenListResult.Serialization.cs | 66 +++ ...inerRegistryTokenPassword.Serialization.cs | 87 ++++ .../Models/ContainerRegistryTokenPassword.cs | 4 + .../Models/ContainerRegistryTokenPatch.cs | 3 + ...RegistryTriggerProperties.Serialization.cs | 80 +++ .../ContainerRegistryTriggerProperties.cs | 3 + .../ContainerRegistryTriggerUpdateContent.cs | 3 + ...tainerRegistryTrustPolicy.Serialization.cs | 49 ++ .../Models/ContainerRegistryTrustPolicy.cs | 2 + .../ContainerRegistryUsage.Serialization.cs | 85 ++++ .../Models/ContainerRegistryUsage.cs | 4 + ...erRegistryUsageListResult.Serialization.cs | 44 ++ .../ContainerRegistryUsageListResult.cs | 1 + ...stryWebhookCallbackConfig.Serialization.cs | 72 +++ .../ContainerRegistryWebhookCallbackConfig.cs | 3 +- ...nerRegistryWebhookCreateOrUpdateContent.cs | 7 + ...ainerRegistryWebhookEvent.Serialization.cs | 63 +++ .../Models/ContainerRegistryWebhookEvent.cs | 2 + ...RegistryWebhookEventActor.Serialization.cs | 43 ++ .../ContainerRegistryWebhookEventActor.cs | 1 + ...gistryWebhookEventContent.Serialization.cs | 128 +++++ .../ContainerRegistryWebhookEventContent.cs | 7 + ...rRegistryWebhookEventInfo.Serialization.cs | 35 ++ .../ContainerRegistryWebhookEventInfo.cs | 1 + ...tryWebhookEventListResult.Serialization.cs | 66 +++ ...ebhookEventRequestContent.Serialization.cs | 123 +++++ ...ainerRegistryWebhookEventRequestContent.cs | 5 + ...ebhookEventRequestMessage.Serialization.cs | 130 +++++ ...ainerRegistryWebhookEventRequestMessage.cs | 7 +- ...bhookEventResponseMessage.Serialization.cs | 146 ++++++ ...inerRegistryWebhookEventResponseMessage.cs | 7 +- ...egistryWebhookEventSource.Serialization.cs | 65 +++ .../ContainerRegistryWebhookEventSource.cs | 2 + ...egistryWebhookEventTarget.Serialization.cs | 195 ++++++++ .../ContainerRegistryWebhookEventTarget.cs | 9 + ...RegistryWebhookListResult.Serialization.cs | 66 +++ .../Models/ContainerRegistryWebhookPatch.cs | 7 +- ...CustomRegistryCredentials.Serialization.cs | 71 +++ .../Models/CustomRegistryCredentials.cs | 3 + .../ScopeMapListResult.Serialization.cs | 66 +++ .../src/Generated/Models/ScopeMapPatch.cs | 2 + .../SourceCodeRepoAuthInfo.Serialization.cs | 112 +++++ .../Models/SourceCodeRepoAuthInfo.cs | 5 + .../SourceCodeRepoAuthInfoUpdateContent.cs | 5 + .../SourceCodeRepoProperties.Serialization.cs | 82 +++ .../Models/SourceCodeRepoProperties.cs | 4 + .../Models/SourceCodeRepoUpdateContent.cs | 4 + ...SourceRegistryCredentials.Serialization.cs | 35 ++ .../Models/SourceRegistryCredentials.cs | 1 + .../SourceUploadDefinition.Serialization.cs | 57 +++ .../Models/SourceUploadDefinition.cs | 2 + .../Models/UnknownRunRequest.Serialization.cs | 102 ++++ ...UnknownTaskStepProperties.Serialization.cs | 99 ++++ .../Generated/ScopeMapData.Serialization.cs | 183 +++++++ .../src/Generated/ScopeMapData.cs | 5 + .../Internal/BicepSerializationHelpers.cs | 58 +++ .../Internal/ChangeTrackingDictionary.cs | 167 +++++++ .../src/Generated/Internal/Optional.cs | 1 - .../Internal/Utf8JsonRequestContent.cs | 55 +++ .../LogAnalyticsQueryData.Serialization.cs | 44 +- ...LogAnalyticsQueryPackData.Serialization.cs | 42 -- .../Models/ClusterListResult.Serialization.cs | 44 +- .../DataExportListResult.Serialization.cs | 44 +- .../DataSourceListResult.Serialization.cs | 44 +- .../LinkedServiceListResult.Serialization.cs | 44 +- ...StorageAccountsListResult.Serialization.cs | 44 +- ...lyticsQueryPackListResult.Serialization.cs | 44 +- .../Models/LogAnalyticsQueryPackPatch.cs | 2 +- ...sQueryPackQueryListResult.Serialization.cs | 44 +- ...yticsQueryRelatedMetadata.Serialization.cs | 42 -- .../LogAnalyticsQuerySearchProperties.cs | 2 +- ...ightsAvailableServiceTier.Serialization.cs | 42 -- ...cityReservationProperties.Serialization.cs | 42 -- ...lusterAssociatedWorkspace.Serialization.cs | 42 -- .../Models/OperationalInsightsClusterPatch.cs | 2 +- ...OperationalInsightsColumn.Serialization.cs | 56 +-- ...lInsightsIntelligencePack.Serialization.cs | 42 -- ...nsightsKeyVaultProperties.Serialization.cs | 42 -- ...alInsightsManagementGroup.Serialization.cs | 42 -- ...ationalInsightsMetricName.Serialization.cs | 42 -- ...ateLinkScopedResourceInfo.Serialization.cs | 42 -- ...OperationalInsightsSchema.Serialization.cs | 46 +- ...InsightsSearchCoreSummary.Serialization.cs | 42 -- ...InsightsSearchSchemaValue.Serialization.cs | 64 +-- ...nalInsightsStorageAccount.Serialization.cs | 42 -- ...InsightsTableRestoredLogs.Serialization.cs | 42 -- ...ghtsTableResultStatistics.Serialization.cs | 42 -- ...nsightsTableSearchResults.Serialization.cs | 42 -- .../OperationalInsightsTag.Serialization.cs | 42 -- ...tionalInsightsUsageMetric.Serialization.cs | 44 +- ...lInsightsWorkspaceCapping.Serialization.cs | 42 -- ...InsightsWorkspaceFeatures.Serialization.cs | 42 -- .../OperationalInsightsWorkspaceFeatures.cs | 1 + ...nalInsightsWorkspacePatch.Serialization.cs | 52 +- ...ightsWorkspacePurgeResult.Serialization.cs | 42 -- ...orkspacePurgeStatusResult.Serialization.cs | 42 -- ...sightsWorkspaceSharedKeys.Serialization.cs | 42 -- ...ionalInsightsWorkspaceSku.Serialization.cs | 42 -- .../SavedSearchesListResult.Serialization.cs | 44 +- .../SearchGetSchemaResponse.Serialization.cs | 46 +- .../Models/SearchMetadata.Serialization.cs | 48 +- .../SearchMetadataSchema.Serialization.cs | 42 -- .../Models/SearchSort.Serialization.cs | 42 -- .../StorageInsightListResult.Serialization.cs | 44 +- .../StorageInsightStatus.Serialization.cs | 42 -- .../Models/TablesListResult.Serialization.cs | 44 +- ...istManagementGroupsResult.Serialization.cs | 44 +- .../WorkspaceListResult.Serialization.cs | 44 +- ...WorkspaceListUsagesResult.Serialization.cs | 44 +- ...tionalInsightsClusterData.Serialization.cs | 52 +- ...nalInsightsDataExportData.Serialization.cs | 42 -- ...nalInsightsDataSourceData.Serialization.cs | 42 -- ...InsightsLinkedServiceData.Serialization.cs | 42 -- ...LinkedStorageAccountsData.Serialization.cs | 42 -- ...alInsightsSavedSearchData.Serialization.cs | 44 +- ...rationalInsightsTableData.Serialization.cs | 50 +- ...onalInsightsWorkspaceData.Serialization.cs | 52 +- .../StorageInsightData.Serialization.cs | 46 +- 425 files changed, 11159 insertions(+), 9188 deletions(-) create mode 100644 sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Internal/BicepSerializationHelpers.cs create mode 100644 sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Internal/ChangeTrackingDictionary.cs create mode 100644 sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Internal/Utf8JsonRequestContent.cs create mode 100644 sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Internal/BicepSerializationHelpers.cs create mode 100644 sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Internal/ChangeTrackingDictionary.cs create mode 100644 sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Internal/Utf8JsonRequestContent.cs create mode 100644 sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Internal/WirePathAttribute.cs create mode 100644 sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Internal/BicepSerializationHelpers.cs create mode 100644 sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Internal/ChangeTrackingDictionary.cs create mode 100644 sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Internal/Utf8JsonRequestContent.cs diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppAuthConfigData.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppAuthConfigData.Serialization.cs index 33f2868a60f5f..7277e9d3afd70 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppAuthConfigData.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppAuthConfigData.Serialization.cs @@ -302,7 +302,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Platform, options, 4, false, " platform: "); + BicepSerializationHelpers.AppendChildObject(builder, Platform, options, 4, false, " platform: "); } } @@ -316,7 +316,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, GlobalValidation, options, 4, false, " globalValidation: "); + BicepSerializationHelpers.AppendChildObject(builder, GlobalValidation, options, 4, false, " globalValidation: "); } } @@ -330,7 +330,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, IdentityProviders, options, 4, false, " identityProviders: "); + BicepSerializationHelpers.AppendChildObject(builder, IdentityProviders, options, 4, false, " identityProviders: "); } } @@ -344,7 +344,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Login, options, 4, false, " login: "); + BicepSerializationHelpers.AppendChildObject(builder, Login, options, 4, false, " login: "); } } @@ -358,7 +358,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, HttpSettings, options, 4, false, " httpSettings: "); + BicepSerializationHelpers.AppendChildObject(builder, HttpSettings, options, 4, false, " httpSettings: "); } } @@ -367,48 +367,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppCertificateData.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppCertificateData.Serialization.cs index 309096c3b03cd..70ccd58b1c9a0 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppCertificateData.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppCertificateData.Serialization.cs @@ -277,7 +277,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Properties, options, 2, false, " properties: "); + BicepSerializationHelpers.AppendChildObject(builder, Properties, options, 2, false, " properties: "); } } @@ -313,48 +313,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppConnectedEnvironmentData.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppConnectedEnvironmentData.Serialization.cs index acdcf374a0a40..ff5cdf16a7e55 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppConnectedEnvironmentData.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppConnectedEnvironmentData.Serialization.cs @@ -377,7 +377,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, ExtendedLocation, options, 2, false, " extendedLocation: "); + BicepSerializationHelpers.AppendChildObject(builder, ExtendedLocation, options, 2, false, " extendedLocation: "); } } @@ -515,7 +515,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, CustomDomainConfiguration, options, 4, false, " customDomainConfiguration: "); + BicepSerializationHelpers.AppendChildObject(builder, CustomDomainConfiguration, options, 4, false, " customDomainConfiguration: "); } } @@ -524,48 +524,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppConnectedEnvironmentStorageData.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppConnectedEnvironmentStorageData.Serialization.cs index 01709b130b18a..fc6b7bc8c0350 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppConnectedEnvironmentStorageData.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppConnectedEnvironmentStorageData.Serialization.cs @@ -193,7 +193,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Properties, options, 2, false, " properties: "); + BicepSerializationHelpers.AppendChildObject(builder, Properties, options, 2, false, " properties: "); } } @@ -229,48 +229,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppDaprComponentData.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppDaprComponentData.Serialization.cs index ee6fb11789769..1dcdab8473cf7 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppDaprComponentData.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppDaprComponentData.Serialization.cs @@ -451,7 +451,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Secrets) { - AppendChildObject(builder, item, options, 6, true, " secrets: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 6, true, " secrets: "); } builder.AppendLine(" ]"); } @@ -495,7 +495,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Metadata) { - AppendChildObject(builder, item, options, 6, true, " metadata: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 6, true, " metadata: "); } builder.AppendLine(" ]"); } @@ -542,48 +542,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppData.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppData.Serialization.cs index 8feae7db281f6..64cde1d9d10a6 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppData.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppData.Serialization.cs @@ -517,7 +517,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, ExtendedLocation, options, 2, false, " extendedLocation: "); + BicepSerializationHelpers.AppendChildObject(builder, ExtendedLocation, options, 2, false, " extendedLocation: "); } } @@ -531,7 +531,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Identity, options, 2, false, " identity: "); + BicepSerializationHelpers.AppendChildObject(builder, Identity, options, 2, false, " identity: "); } } @@ -749,7 +749,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Configuration, options, 4, false, " configuration: "); + BicepSerializationHelpers.AppendChildObject(builder, Configuration, options, 4, false, " configuration: "); } } @@ -763,7 +763,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Template, options, 4, false, " template: "); + BicepSerializationHelpers.AppendChildObject(builder, Template, options, 4, false, " template: "); } } @@ -813,48 +813,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppDiagnosticData.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppDiagnosticData.Serialization.cs index 4854d060aa8ef..bc19a2eb236dc 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppDiagnosticData.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppDiagnosticData.Serialization.cs @@ -193,7 +193,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Properties, options, 2, false, " properties: "); + BicepSerializationHelpers.AppendChildObject(builder, Properties, options, 2, false, " properties: "); } } @@ -229,48 +229,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppJobData.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppJobData.Serialization.cs index 863ff8173f9d9..4947160c41f9f 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppJobData.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppJobData.Serialization.cs @@ -404,7 +404,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Identity, options, 2, false, " identity: "); + BicepSerializationHelpers.AppendChildObject(builder, Identity, options, 2, false, " identity: "); } } @@ -506,7 +506,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Configuration, options, 4, false, " configuration: "); + BicepSerializationHelpers.AppendChildObject(builder, Configuration, options, 4, false, " configuration: "); } } @@ -520,7 +520,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Template, options, 4, false, " template: "); + BicepSerializationHelpers.AppendChildObject(builder, Template, options, 4, false, " template: "); } } @@ -586,48 +586,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppJobExecutionData.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppJobExecutionData.Serialization.cs index 9d3f4c7e55475..10c04e37b8080 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppJobExecutionData.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppJobExecutionData.Serialization.cs @@ -330,7 +330,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Template, options, 4, false, " template: "); + BicepSerializationHelpers.AppendChildObject(builder, Template, options, 4, false, " template: "); } } @@ -339,48 +339,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppManagedCertificateData.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppManagedCertificateData.Serialization.cs index 30e34388e9abb..a8e722b583442 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppManagedCertificateData.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppManagedCertificateData.Serialization.cs @@ -277,7 +277,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Properties, options, 2, false, " properties: "); + BicepSerializationHelpers.AppendChildObject(builder, Properties, options, 2, false, " properties: "); } } @@ -313,48 +313,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppManagedEnvironmentData.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppManagedEnvironmentData.Serialization.cs index 525f88f6bc2ed..18c1ef0805173 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppManagedEnvironmentData.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppManagedEnvironmentData.Serialization.cs @@ -641,7 +641,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, VnetConfiguration, options, 4, false, " vnetConfiguration: "); + BicepSerializationHelpers.AppendChildObject(builder, VnetConfiguration, options, 4, false, " vnetConfiguration: "); } } @@ -713,7 +713,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, AppLogsConfiguration, options, 4, false, " appLogsConfiguration: "); + BicepSerializationHelpers.AppendChildObject(builder, AppLogsConfiguration, options, 4, false, " appLogsConfiguration: "); } } @@ -742,7 +742,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, CustomDomainConfiguration, options, 4, false, " customDomainConfiguration: "); + BicepSerializationHelpers.AppendChildObject(builder, CustomDomainConfiguration, options, 4, false, " customDomainConfiguration: "); } } @@ -783,7 +783,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in WorkloadProfiles) { - AppendChildObject(builder, item, options, 6, true, " workloadProfiles: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 6, true, " workloadProfiles: "); } builder.AppendLine(" ]"); } @@ -800,7 +800,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, KedaConfiguration, options, 4, false, " kedaConfiguration: "); + BicepSerializationHelpers.AppendChildObject(builder, KedaConfiguration, options, 4, false, " kedaConfiguration: "); } } @@ -814,7 +814,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, DaprConfiguration, options, 4, false, " daprConfiguration: "); + BicepSerializationHelpers.AppendChildObject(builder, DaprConfiguration, options, 4, false, " daprConfiguration: "); } } @@ -850,7 +850,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, PeerAuthentication, options, 4, false, " peerAuthentication: "); + BicepSerializationHelpers.AppendChildObject(builder, PeerAuthentication, options, 4, false, " peerAuthentication: "); } } @@ -859,48 +859,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppManagedEnvironmentStorageData.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppManagedEnvironmentStorageData.Serialization.cs index 6cb1fae7df143..1d72ff9c634b0 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppManagedEnvironmentStorageData.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppManagedEnvironmentStorageData.Serialization.cs @@ -193,7 +193,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Properties, options, 2, false, " properties: "); + BicepSerializationHelpers.AppendChildObject(builder, Properties, options, 2, false, " properties: "); } } @@ -229,48 +229,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppReplicaData.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppReplicaData.Serialization.cs index ac24ff556f909..144879952ca70 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppReplicaData.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppReplicaData.Serialization.cs @@ -375,7 +375,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Containers) { - AppendChildObject(builder, item, options, 6, true, " containers: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 6, true, " containers: "); } builder.AppendLine(" ]"); } @@ -397,7 +397,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in InitContainers) { - AppendChildObject(builder, item, options, 6, true, " initContainers: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 6, true, " initContainers: "); } builder.AppendLine(" ]"); } @@ -409,48 +409,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppRevisionData.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppRevisionData.Serialization.cs index 6d5d11fa384c2..4ae2de4797b33 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppRevisionData.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppRevisionData.Serialization.cs @@ -442,7 +442,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Template, options, 4, false, " template: "); + BicepSerializationHelpers.AppendChildObject(builder, Template, options, 4, false, " template: "); } } @@ -558,48 +558,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppSourceControlData.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppSourceControlData.Serialization.cs index 61ed7d18f6c7b..0944c641e2a04 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppSourceControlData.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/ContainerAppSourceControlData.Serialization.cs @@ -332,7 +332,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, GitHubActionConfiguration, options, 4, false, " githubActionConfiguration: "); + BicepSerializationHelpers.AppendChildObject(builder, GitHubActionConfiguration, options, 4, false, " githubActionConfiguration: "); } } @@ -341,48 +341,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Internal/BicepSerializationHelpers.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Internal/BicepSerializationHelpers.cs new file mode 100644 index 0000000000000..d0b309ca92a89 --- /dev/null +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Internal/BicepSerializationHelpers.cs @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text; + +namespace Azure.ResourceManager.AppContainers +{ + internal static class BicepSerializationHelpers + { + public static void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + } +} diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Internal/ChangeTrackingDictionary.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Internal/ChangeTrackingDictionary.cs new file mode 100644 index 0000000000000..f7db3df3ce80a --- /dev/null +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/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.AppContainers +{ + 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/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Internal/Optional.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Internal/Optional.cs index 6016879c8f313..86e51ee65d083 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Internal/Optional.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Internal/Optional.cs @@ -7,7 +7,6 @@ using System.Collections.Generic; using System.Text.Json; -using Azure.Core; namespace Azure.ResourceManager.AppContainers { diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Internal/Utf8JsonRequestContent.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Internal/Utf8JsonRequestContent.cs new file mode 100644 index 0000000000000..7486884bebecc --- /dev/null +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/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.AppContainers +{ + 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/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/AllowedAudiencesValidation.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/AllowedAudiencesValidation.Serialization.cs index e2400b310e51b..591d1444f6ae2 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/AllowedAudiencesValidation.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/AllowedAudiencesValidation.Serialization.cs @@ -156,48 +156,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/AppContainerResources.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/AppContainerResources.Serialization.cs index be3ba9108644a..73cc9c83e7c33 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/AppContainerResources.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/AppContainerResources.Serialization.cs @@ -190,48 +190,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/AuthConfigCollection.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/AuthConfigCollection.Serialization.cs index ed8ab9ddc0964..5e8a20e56728f 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/AuthConfigCollection.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/AuthConfigCollection.Serialization.cs @@ -136,7 +136,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -169,48 +169,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/AvailableWorkloadProfilesCollection.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/AvailableWorkloadProfilesCollection.Serialization.cs index 8b74d6d46e8de..3bffe56ef67eb 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/AvailableWorkloadProfilesCollection.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/AvailableWorkloadProfilesCollection.Serialization.cs @@ -136,7 +136,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -169,48 +169,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/AzureStaticWebAppsRegistration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/AzureStaticWebAppsRegistration.Serialization.cs index bc0f63687c965..540de50f88525 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/AzureStaticWebAppsRegistration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/AzureStaticWebAppsRegistration.Serialization.cs @@ -128,48 +128,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/BillingMeterCollection.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/BillingMeterCollection.Serialization.cs index 297b0c0e97130..e89efa6b947a2 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/BillingMeterCollection.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/BillingMeterCollection.Serialization.cs @@ -125,7 +125,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -136,48 +136,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/CertificateCollection.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/CertificateCollection.Serialization.cs index 25878be62b83b..98826ed8462e7 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/CertificateCollection.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/CertificateCollection.Serialization.cs @@ -136,7 +136,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -169,48 +169,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ConnectedEnvironmentCollection.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ConnectedEnvironmentCollection.Serialization.cs index 9e5bbc789d5ba..d0dc7988c3c67 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ConnectedEnvironmentCollection.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ConnectedEnvironmentCollection.Serialization.cs @@ -143,7 +143,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -176,48 +176,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ConnectedEnvironmentStorageProperties.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ConnectedEnvironmentStorageProperties.Serialization.cs index 5bad7d13af25b..7b5fc44052b77 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ConnectedEnvironmentStorageProperties.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ConnectedEnvironmentStorageProperties.Serialization.cs @@ -116,7 +116,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, AzureFile, options, 2, false, " azureFile: "); + BicepSerializationHelpers.AppendChildObject(builder, AzureFile, options, 2, false, " azureFile: "); } } @@ -124,48 +124,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ConnectedEnvironmentStoragesCollection.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ConnectedEnvironmentStoragesCollection.Serialization.cs index 0fb2e02e80c3a..c16cdbdcf3ff3 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ConnectedEnvironmentStoragesCollection.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ConnectedEnvironmentStoragesCollection.Serialization.cs @@ -125,7 +125,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -136,48 +136,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAllowedPrincipals.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAllowedPrincipals.Serialization.cs index 456ee208dfecd..2d6f80df8f5f8 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAllowedPrincipals.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAllowedPrincipals.Serialization.cs @@ -216,48 +216,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAppleConfiguration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAppleConfiguration.Serialization.cs index 64924d5213783..8d077877fd873 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAppleConfiguration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAppleConfiguration.Serialization.cs @@ -161,7 +161,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Registration, options, 2, false, " registration: "); + BicepSerializationHelpers.AppendChildObject(builder, Registration, options, 2, false, " registration: "); } } @@ -175,7 +175,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Login, options, 2, false, " login: "); + BicepSerializationHelpers.AppendChildObject(builder, Login, options, 2, false, " login: "); } } @@ -183,48 +183,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAppleRegistrationConfiguration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAppleRegistrationConfiguration.Serialization.cs index e4557889cd13f..cbccef8478f02 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAppleRegistrationConfiguration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAppleRegistrationConfiguration.Serialization.cs @@ -161,48 +161,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAuthPlatform.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAuthPlatform.Serialization.cs index a9d15c7187e21..98aa9513d12e7 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAuthPlatform.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAuthPlatform.Serialization.cs @@ -158,48 +158,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAuthToken.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAuthToken.Serialization.cs index 05c2dce78fa5a..d2fe0758c55fa 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAuthToken.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAuthToken.Serialization.cs @@ -366,48 +366,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAvailableWorkloadProfile.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAvailableWorkloadProfile.Serialization.cs index f9965b65d1dce..a0e15b5fb786e 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAvailableWorkloadProfile.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAvailableWorkloadProfile.Serialization.cs @@ -223,7 +223,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Properties, options, 2, false, " properties: "); + BicepSerializationHelpers.AppendChildObject(builder, Properties, options, 2, false, " properties: "); } } @@ -259,48 +259,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAvailableWorkloadProfileProperties.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAvailableWorkloadProfileProperties.Serialization.cs index 35c21f29ea5ad..82365dc4cdf14 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAvailableWorkloadProfileProperties.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAvailableWorkloadProfileProperties.Serialization.cs @@ -254,48 +254,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAzureActiveDirectoryConfiguration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAzureActiveDirectoryConfiguration.Serialization.cs index faf600f7ba5d9..23c731eda3e35 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAzureActiveDirectoryConfiguration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAzureActiveDirectoryConfiguration.Serialization.cs @@ -197,7 +197,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Registration, options, 2, false, " registration: "); + BicepSerializationHelpers.AppendChildObject(builder, Registration, options, 2, false, " registration: "); } } @@ -211,7 +211,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Login, options, 2, false, " login: "); + BicepSerializationHelpers.AppendChildObject(builder, Login, options, 2, false, " login: "); } } @@ -225,7 +225,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Validation, options, 2, false, " validation: "); + BicepSerializationHelpers.AppendChildObject(builder, Validation, options, 2, false, " validation: "); } } @@ -248,48 +248,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAzureActiveDirectoryLoginConfiguration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAzureActiveDirectoryLoginConfiguration.Serialization.cs index f69552370d76b..9ab5e38160b90 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAzureActiveDirectoryLoginConfiguration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAzureActiveDirectoryLoginConfiguration.Serialization.cs @@ -186,48 +186,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAzureActiveDirectoryRegistrationConfiguration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAzureActiveDirectoryRegistrationConfiguration.Serialization.cs index feab3dd77a8be..c0748cc2abaa5 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAzureActiveDirectoryRegistrationConfiguration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAzureActiveDirectoryRegistrationConfiguration.Serialization.cs @@ -300,48 +300,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAzureActiveDirectoryValidationConfiguration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAzureActiveDirectoryValidationConfiguration.Serialization.cs index 0570571723430..fd12d4f0b5f4a 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAzureActiveDirectoryValidationConfiguration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAzureActiveDirectoryValidationConfiguration.Serialization.cs @@ -157,7 +157,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, JwtClaimChecks, options, 2, false, " jwtClaimChecks: "); + BicepSerializationHelpers.AppendChildObject(builder, JwtClaimChecks, options, 2, false, " jwtClaimChecks: "); } } @@ -206,7 +206,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, DefaultAuthorizationPolicy, options, 2, false, " defaultAuthorizationPolicy: "); + BicepSerializationHelpers.AppendChildObject(builder, DefaultAuthorizationPolicy, options, 2, false, " defaultAuthorizationPolicy: "); } } @@ -214,48 +214,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAzureFileProperties.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAzureFileProperties.Serialization.cs index 9e85a26e04d9b..38c2c20ea32c2 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAzureFileProperties.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAzureFileProperties.Serialization.cs @@ -223,48 +223,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAzureStaticWebAppsConfiguration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAzureStaticWebAppsConfiguration.Serialization.cs index d961fda2c5ffb..cdd946d65713b 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAzureStaticWebAppsConfiguration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppAzureStaticWebAppsConfiguration.Serialization.cs @@ -146,7 +146,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Registration, options, 2, false, " registration: "); + BicepSerializationHelpers.AppendChildObject(builder, Registration, options, 2, false, " registration: "); } } @@ -154,48 +154,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppBaseContainer.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppBaseContainer.Serialization.cs index ad31ecf8bf648..d7b668fef0140 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppBaseContainer.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppBaseContainer.Serialization.cs @@ -237,46 +237,46 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("{"); - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); - if (Optional.IsDefined(Name) || hasPropertyOverride) + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Image), out propertyOverride); + if (Optional.IsDefined(Image) || hasPropertyOverride) { - builder.Append(" name: "); + builder.Append(" image: "); if (hasPropertyOverride) { builder.AppendLine($"{propertyOverride}"); } else { - if (Name.Contains(Environment.NewLine)) + if (Image.Contains(Environment.NewLine)) { builder.AppendLine("'''"); - builder.AppendLine($"{Name}'''"); + builder.AppendLine($"{Image}'''"); } else { - builder.AppendLine($"'{Name}'"); + builder.AppendLine($"'{Image}'"); } } } - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Image), out propertyOverride); - if (Optional.IsDefined(Image) || hasPropertyOverride) + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" image: "); + builder.Append(" name: "); if (hasPropertyOverride) { builder.AppendLine($"{propertyOverride}"); } else { - if (Image.Contains(Environment.NewLine)) + if (Name.Contains(Environment.NewLine)) { builder.AppendLine("'''"); - builder.AppendLine($"{Image}'''"); + builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($"'{Image}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -366,7 +366,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Env) { - AppendChildObject(builder, item, options, 4, true, " env: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " env: "); } builder.AppendLine(" ]"); } @@ -383,7 +383,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Resources, options, 2, false, " resources: "); + BicepSerializationHelpers.AppendChildObject(builder, Resources, options, 2, false, " resources: "); } } @@ -402,7 +402,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in VolumeMounts) { - AppendChildObject(builder, item, options, 4, true, " volumeMounts: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " volumeMounts: "); } builder.AppendLine(" ]"); } @@ -413,48 +413,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppBillingMeter.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppBillingMeter.Serialization.cs index dfd331c251ca5..9eaca0dab6063 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppBillingMeter.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppBillingMeter.Serialization.cs @@ -223,7 +223,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Properties, options, 2, false, " properties: "); + BicepSerializationHelpers.AppendChildObject(builder, Properties, options, 2, false, " properties: "); } } @@ -259,48 +259,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppBillingMeterProperties.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppBillingMeterProperties.Serialization.cs index c6f0a7adbe21b..41c733d53008d 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppBillingMeterProperties.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppBillingMeterProperties.Serialization.cs @@ -194,48 +194,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCertificatePatch.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCertificatePatch.cs index 9be781701e5ce..65da30f1acbb4 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCertificatePatch.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCertificatePatch.cs @@ -7,7 +7,7 @@ using System; using System.Collections.Generic; -using Azure.Core; +using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models { diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCertificateProperties.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCertificateProperties.Serialization.cs index 5c8074a2505ab..5b8f54b9d5391 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCertificateProperties.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCertificateProperties.Serialization.cs @@ -481,48 +481,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppClientRegistration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppClientRegistration.Serialization.cs index f00edd8fe599d..73793ae40bb3f 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppClientRegistration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppClientRegistration.Serialization.cs @@ -161,48 +161,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCollection.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCollection.Serialization.cs index 55dd05419e67e..fb965f4a380f9 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCollection.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCollection.Serialization.cs @@ -136,7 +136,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -169,48 +169,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppConfiguration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppConfiguration.Serialization.cs index 63573c66b9852..b08454f198077 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppConfiguration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppConfiguration.Serialization.cs @@ -240,7 +240,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Secrets) { - AppendChildObject(builder, item, options, 4, true, " secrets: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " secrets: "); } builder.AppendLine(" ]"); } @@ -271,7 +271,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Ingress, options, 2, false, " ingress: "); + BicepSerializationHelpers.AppendChildObject(builder, Ingress, options, 2, false, " ingress: "); } } @@ -290,7 +290,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Registries) { - AppendChildObject(builder, item, options, 4, true, " registries: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " registries: "); } builder.AppendLine(" ]"); } @@ -307,7 +307,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Dapr, options, 2, false, " dapr: "); + BicepSerializationHelpers.AppendChildObject(builder, Dapr, options, 2, false, " dapr: "); } } @@ -335,7 +335,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Service, options, 2, false, " service: "); + BicepSerializationHelpers.AppendChildObject(builder, Service, options, 2, false, " service: "); } } @@ -343,48 +343,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppContainer.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppContainer.Serialization.cs index f496095b1ca85..82a3f81c1460e 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppContainer.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppContainer.Serialization.cs @@ -263,28 +263,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("{"); - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); - if (Optional.IsDefined(Name) || hasPropertyOverride) - { - builder.Append(" name: "); - if (hasPropertyOverride) - { - builder.AppendLine($"{propertyOverride}"); - } - else - { - if (Name.Contains(Environment.NewLine)) - { - builder.AppendLine("'''"); - builder.AppendLine($"{Name}'''"); - } - else - { - builder.AppendLine($"'{Name}'"); - } - } - } - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Probes), out propertyOverride); if (Optional.IsCollectionDefined(Probes) || hasPropertyOverride) { @@ -300,7 +278,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Probes) { - AppendChildObject(builder, item, options, 4, true, " probes: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " probes: "); } builder.AppendLine(" ]"); } @@ -329,6 +307,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } } + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Command), out propertyOverride); if (Optional.IsCollectionDefined(Command) || hasPropertyOverride) { @@ -414,7 +414,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Env) { - AppendChildObject(builder, item, options, 4, true, " env: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " env: "); } builder.AppendLine(" ]"); } @@ -431,7 +431,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Resources, options, 2, false, " resources: "); + BicepSerializationHelpers.AppendChildObject(builder, Resources, options, 2, false, " resources: "); } } @@ -450,7 +450,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in VolumeMounts) { - AppendChildObject(builder, item, options, 4, true, " volumeMounts: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " volumeMounts: "); } builder.AppendLine(" ]"); } @@ -461,48 +461,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCookieExpiration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCookieExpiration.Serialization.cs index 43a3781cc1e55..4357fc80b7c36 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCookieExpiration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCookieExpiration.Serialization.cs @@ -157,48 +157,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCorsPolicy.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCorsPolicy.Serialization.cs index 63d17ad954177..77da99b1b25d8 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCorsPolicy.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCorsPolicy.Serialization.cs @@ -395,48 +395,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCredentials.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCredentials.Serialization.cs index 4c12edd8f780e..23962eba5711a 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCredentials.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCredentials.Serialization.cs @@ -262,48 +262,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomDomain.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomDomain.Serialization.cs index f0815574f2442..2cf08a4f793dc 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomDomain.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomDomain.Serialization.cs @@ -183,48 +183,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomDomainConfiguration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomDomainConfiguration.Serialization.cs index a9177a412394d..d726641510b55 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomDomainConfiguration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomDomainConfiguration.Serialization.cs @@ -327,48 +327,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomDomainVerificationFailureInfo.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomDomainVerificationFailureInfo.Serialization.cs index 9cb3df3eb3fe0..56c10c152b3b2 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomDomainVerificationFailureInfo.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomDomainVerificationFailureInfo.Serialization.cs @@ -231,7 +231,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Details) { - AppendChildObject(builder, item, options, 4, true, " details: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " details: "); } builder.AppendLine(" ]"); } @@ -242,48 +242,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomDomainVerificationFailureInfoDetailsItem.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomDomainVerificationFailureInfoDetailsItem.Serialization.cs index ec61633adf8ac..8ab2132716e9b 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomDomainVerificationFailureInfoDetailsItem.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomDomainVerificationFailureInfoDetailsItem.Serialization.cs @@ -194,48 +194,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomHostnameAnalysisResult.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomHostnameAnalysisResult.Serialization.cs index b03a0c5467943..a772670c50ba7 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomHostnameAnalysisResult.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomHostnameAnalysisResult.Serialization.cs @@ -388,7 +388,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, CustomDomainVerificationFailureInfo, options, 2, false, " customDomainVerificationFailureInfo: "); + BicepSerializationHelpers.AppendChildObject(builder, CustomDomainVerificationFailureInfo, options, 2, false, " customDomainVerificationFailureInfo: "); } } @@ -623,48 +623,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomOpenIdConnectProviderConfiguration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomOpenIdConnectProviderConfiguration.Serialization.cs index ddf98a39805e5..c923f0590f963 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomOpenIdConnectProviderConfiguration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomOpenIdConnectProviderConfiguration.Serialization.cs @@ -161,7 +161,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Registration, options, 2, false, " registration: "); + BicepSerializationHelpers.AppendChildObject(builder, Registration, options, 2, false, " registration: "); } } @@ -175,7 +175,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Login, options, 2, false, " login: "); + BicepSerializationHelpers.AppendChildObject(builder, Login, options, 2, false, " login: "); } } @@ -183,48 +183,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomScaleRule.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomScaleRule.Serialization.cs index 8f9ebbf119a58..dec78eaae4138 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomScaleRule.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomScaleRule.Serialization.cs @@ -154,6 +154,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("{"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CustomScaleRuleType), out propertyOverride); + if (Optional.IsDefined(CustomScaleRuleType) || hasPropertyOverride) + { + builder.Append(" type: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (CustomScaleRuleType.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{CustomScaleRuleType}'''"); + } + else + { + builder.AppendLine($"'{CustomScaleRuleType}'"); + } + } + } + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Metadata), out propertyOverride); if (Optional.IsCollectionDefined(Metadata) || hasPropertyOverride) { @@ -205,7 +227,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Auth) { - AppendChildObject(builder, item, options, 4, true, " auth: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " auth: "); } builder.AppendLine(" ]"); } @@ -216,48 +238,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomScaleRule.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomScaleRule.cs index d9d9550d79357..bdb20592cea76 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomScaleRule.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppCustomScaleRule.cs @@ -7,7 +7,6 @@ using System; using System.Collections.Generic; -using Azure.Core; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDaprConfiguration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDaprConfiguration.Serialization.cs index 0937663c029ed..d10b21a8fcbfb 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDaprConfiguration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDaprConfiguration.Serialization.cs @@ -342,48 +342,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDaprMetadata.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDaprMetadata.Serialization.cs index 8ad649851fbc5..b0fec9325b69a 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDaprMetadata.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDaprMetadata.Serialization.cs @@ -194,48 +194,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDaprSecret.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDaprSecret.Serialization.cs index af75a95a090af..037ed97b6df14 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDaprSecret.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDaprSecret.Serialization.cs @@ -161,48 +161,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDefaultAuthorizationPolicy.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDefaultAuthorizationPolicy.Serialization.cs index 2918c9c388992..7462c4042f289 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDefaultAuthorizationPolicy.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDefaultAuthorizationPolicy.Serialization.cs @@ -142,7 +142,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, AllowedPrincipals, options, 2, false, " allowedPrincipals: "); + BicepSerializationHelpers.AppendChildObject(builder, AllowedPrincipals, options, 2, false, " allowedPrincipals: "); } } @@ -185,48 +185,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticDataColumn.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticDataColumn.Serialization.cs index 313fba2a5f632..0d3b7103b776c 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticDataColumn.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticDataColumn.Serialization.cs @@ -194,48 +194,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticDataProviderMetadata.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticDataProviderMetadata.Serialization.cs index 49f5c14083a59..43af187c95240 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticDataProviderMetadata.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticDataProviderMetadata.Serialization.cs @@ -165,7 +165,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in PropertyBag) { - AppendChildObject(builder, item, options, 4, true, " propertyBag: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " propertyBag: "); } builder.AppendLine(" ]"); } @@ -176,48 +176,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticDataProviderMetadataPropertyBagItem.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticDataProviderMetadataPropertyBagItem.Serialization.cs index 3b459e563a6c2..356abc5256304 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticDataProviderMetadataPropertyBagItem.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticDataProviderMetadataPropertyBagItem.Serialization.cs @@ -161,48 +161,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticDataTableResult.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticDataTableResult.Serialization.cs index d912c0a3dc174..b7fc1d4212e38 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticDataTableResult.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticDataTableResult.Serialization.cs @@ -209,7 +209,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Columns) { - AppendChildObject(builder, item, options, 4, true, " columns: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " columns: "); } builder.AppendLine(" ]"); } @@ -247,48 +247,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticRendering.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticRendering.Serialization.cs index 4299859ddd1e7..92812c09892dc 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticRendering.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticRendering.Serialization.cs @@ -143,6 +143,20 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("{"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DiagnosticRenderingType), out propertyOverride); + if (Optional.IsDefined(DiagnosticRenderingType) || hasPropertyOverride) + { + builder.Append(" type: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{DiagnosticRenderingType.Value}"); + } + } + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Title), out propertyOverride); if (Optional.IsDefined(Title) || hasPropertyOverride) { @@ -206,48 +220,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticSupportTopic.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticSupportTopic.Serialization.cs index 60972ed56c6bc..fb44cd80b4fcb 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticSupportTopic.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticSupportTopic.Serialization.cs @@ -161,48 +161,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticsDataApiResult.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticsDataApiResult.Serialization.cs index 018970e850a84..98f3769b444e3 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticsDataApiResult.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticsDataApiResult.Serialization.cs @@ -131,7 +131,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Table, options, 2, false, " table: "); + BicepSerializationHelpers.AppendChildObject(builder, Table, options, 2, false, " table: "); } } @@ -145,7 +145,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, RenderingProperties, options, 2, false, " renderingProperties: "); + BicepSerializationHelpers.AppendChildObject(builder, RenderingProperties, options, 2, false, " renderingProperties: "); } } @@ -153,48 +153,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticsMetadata.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticsMetadata.Serialization.cs index 330ce0755cec1..176421b33876c 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticsMetadata.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticsMetadata.Serialization.cs @@ -353,7 +353,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in SupportTopicList) { - AppendChildObject(builder, item, options, 4, true, " supportTopicList: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " supportTopicList: "); } builder.AppendLine(" ]"); } @@ -441,48 +441,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticsProperties.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticsProperties.Serialization.cs index 949afad22254b..918e16d4ed1f3 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticsProperties.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticsProperties.Serialization.cs @@ -172,7 +172,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Metadata, options, 2, false, " metadata: "); + BicepSerializationHelpers.AppendChildObject(builder, Metadata, options, 2, false, " metadata: "); } } @@ -191,7 +191,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Dataset) { - AppendChildObject(builder, item, options, 4, true, " dataset: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " dataset: "); } builder.AppendLine(" ]"); } @@ -208,7 +208,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Status, options, 2, false, " status: "); + BicepSerializationHelpers.AppendChildObject(builder, Status, options, 2, false, " status: "); } } @@ -222,7 +222,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, DataProviderMetadata, options, 2, false, " dataProviderMetadata: "); + BicepSerializationHelpers.AppendChildObject(builder, DataProviderMetadata, options, 2, false, " dataProviderMetadata: "); } } @@ -230,48 +230,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticsStatus.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticsStatus.Serialization.cs index bbd6a7c9a1681..76594f50ef59c 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticsStatus.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppDiagnosticsStatus.Serialization.cs @@ -157,48 +157,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppEnvironmentAuthToken.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppEnvironmentAuthToken.Serialization.cs index dd04e5cafe04c..a15c8617c54c6 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppEnvironmentAuthToken.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppEnvironmentAuthToken.Serialization.cs @@ -366,48 +366,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppEnvironmentVariable.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppEnvironmentVariable.Serialization.cs index cd6f292b5e34d..dcae11c3546f5 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppEnvironmentVariable.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppEnvironmentVariable.Serialization.cs @@ -194,48 +194,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppExtendedLocation.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppExtendedLocation.Serialization.cs index feeab7e1959eb..b5e412ea99d95 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppExtendedLocation.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppExtendedLocation.Serialization.cs @@ -139,50 +139,22 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } } - builder.AppendLine("}"); - return BinaryData.FromString(builder.ToString()); - } - - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExtendedLocationType), out propertyOverride); + if (Optional.IsDefined(ExtendedLocationType) || hasPropertyOverride) { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) + builder.Append(" type: "); + if (hasPropertyOverride) { - stringBuilder.AppendLine($"{line}"); + builder.AppendLine($"{propertyOverride}"); } else { - stringBuilder.AppendLine($"{indent}{line}"); + builder.AppendLine($"'{ExtendedLocationType.Value.ToString()}'"); } } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppFacebookConfiguration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppFacebookConfiguration.Serialization.cs index bf306af2e2745..73b65ccf5a9ac 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppFacebookConfiguration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppFacebookConfiguration.Serialization.cs @@ -172,7 +172,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Registration, options, 2, false, " registration: "); + BicepSerializationHelpers.AppendChildObject(builder, Registration, options, 2, false, " registration: "); } } @@ -208,7 +208,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Login, options, 2, false, " login: "); + BicepSerializationHelpers.AppendChildObject(builder, Login, options, 2, false, " login: "); } } @@ -216,48 +216,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppForwardProxy.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppForwardProxy.Serialization.cs index 45fe922a5b328..10352d0ca545b 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppForwardProxy.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppForwardProxy.Serialization.cs @@ -190,48 +190,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppGitHubActionConfiguration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppGitHubActionConfiguration.Serialization.cs index 52b26a422f508..be1fd06ecac02 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppGitHubActionConfiguration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppGitHubActionConfiguration.Serialization.cs @@ -218,7 +218,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, RegistryInfo, options, 2, false, " registryInfo: "); + BicepSerializationHelpers.AppendChildObject(builder, RegistryInfo, options, 2, false, " registryInfo: "); } } @@ -232,7 +232,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, AzureCredentials, options, 2, false, " azureCredentials: "); + BicepSerializationHelpers.AppendChildObject(builder, AzureCredentials, options, 2, false, " azureCredentials: "); } } @@ -394,48 +394,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppGitHubConfiguration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppGitHubConfiguration.Serialization.cs index 2b41edd14691b..ddacadbe9bf44 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppGitHubConfiguration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppGitHubConfiguration.Serialization.cs @@ -161,7 +161,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Registration, options, 2, false, " registration: "); + BicepSerializationHelpers.AppendChildObject(builder, Registration, options, 2, false, " registration: "); } } @@ -175,7 +175,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Login, options, 2, false, " login: "); + BicepSerializationHelpers.AppendChildObject(builder, Login, options, 2, false, " login: "); } } @@ -183,48 +183,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppGlobalValidation.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppGlobalValidation.Serialization.cs index 4d97a0abcf940..fd498eb97773c 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppGlobalValidation.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppGlobalValidation.Serialization.cs @@ -218,48 +218,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppGoogleConfiguration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppGoogleConfiguration.Serialization.cs index ed71f5bb33f64..5651a1a1ef601 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppGoogleConfiguration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppGoogleConfiguration.Serialization.cs @@ -176,7 +176,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Registration, options, 2, false, " registration: "); + BicepSerializationHelpers.AppendChildObject(builder, Registration, options, 2, false, " registration: "); } } @@ -190,7 +190,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Login, options, 2, false, " login: "); + BicepSerializationHelpers.AppendChildObject(builder, Login, options, 2, false, " login: "); } } @@ -204,7 +204,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Validation, options, 2, false, " validation: "); + BicepSerializationHelpers.AppendChildObject(builder, Validation, options, 2, false, " validation: "); } } @@ -212,48 +212,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpHeaderInfo.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpHeaderInfo.Serialization.cs index acf5259063c7e..f7c33f015d222 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpHeaderInfo.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpHeaderInfo.Serialization.cs @@ -155,48 +155,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpRequestInfo.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpRequestInfo.Serialization.cs index 366092a30af39..1bd932b0a261d 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpRequestInfo.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpRequestInfo.Serialization.cs @@ -205,7 +205,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in HttpHeaders) { - AppendChildObject(builder, item, options, 4, true, " httpHeaders: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " httpHeaders: "); } builder.AppendLine(" ]"); } @@ -263,48 +263,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpScaleRule.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpScaleRule.Serialization.cs index 72b6ef0af056e..e3c90eb6c9f1b 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpScaleRule.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpScaleRule.Serialization.cs @@ -194,7 +194,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Auth) { - AppendChildObject(builder, item, options, 4, true, " auth: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " auth: "); } builder.AppendLine(" ]"); } @@ -205,48 +205,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpScaleRule.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpScaleRule.cs index ee722c6a32377..1d7a9047ef63c 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpScaleRule.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpScaleRule.cs @@ -7,7 +7,6 @@ using System; using System.Collections.Generic; -using Azure.Core; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpSettings.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpSettings.Serialization.cs index fa986b4b2197e..c89709ecf5b8b 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpSettings.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppHttpSettings.Serialization.cs @@ -161,7 +161,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Routes, options, 2, false, " routes: "); + BicepSerializationHelpers.AppendChildObject(builder, Routes, options, 2, false, " routes: "); } } @@ -175,7 +175,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, ForwardProxy, options, 2, false, " forwardProxy: "); + BicepSerializationHelpers.AppendChildObject(builder, ForwardProxy, options, 2, false, " forwardProxy: "); } } @@ -183,48 +183,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppIPSecurityRestrictionRule.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppIPSecurityRestrictionRule.Serialization.cs index 57e8630d7fb08..b7573450e9b41 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppIPSecurityRestrictionRule.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppIPSecurityRestrictionRule.Serialization.cs @@ -207,48 +207,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppIdentityProvidersConfiguration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppIdentityProvidersConfiguration.Serialization.cs index 156ba28e294b4..c9f34b74d75fc 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppIdentityProvidersConfiguration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppIdentityProvidersConfiguration.Serialization.cs @@ -242,7 +242,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, AzureActiveDirectory, options, 2, false, " azureActiveDirectory: "); + BicepSerializationHelpers.AppendChildObject(builder, AzureActiveDirectory, options, 2, false, " azureActiveDirectory: "); } } @@ -256,7 +256,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Facebook, options, 2, false, " facebook: "); + BicepSerializationHelpers.AppendChildObject(builder, Facebook, options, 2, false, " facebook: "); } } @@ -270,7 +270,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, GitHub, options, 2, false, " gitHub: "); + BicepSerializationHelpers.AppendChildObject(builder, GitHub, options, 2, false, " gitHub: "); } } @@ -284,7 +284,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Google, options, 2, false, " google: "); + BicepSerializationHelpers.AppendChildObject(builder, Google, options, 2, false, " google: "); } } @@ -298,7 +298,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Twitter, options, 2, false, " twitter: "); + BicepSerializationHelpers.AppendChildObject(builder, Twitter, options, 2, false, " twitter: "); } } @@ -312,7 +312,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Apple, options, 2, false, " apple: "); + BicepSerializationHelpers.AppendChildObject(builder, Apple, options, 2, false, " apple: "); } } @@ -326,7 +326,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, AzureStaticWebApps, options, 2, false, " azureStaticWebApps: "); + BicepSerializationHelpers.AppendChildObject(builder, AzureStaticWebApps, options, 2, false, " azureStaticWebApps: "); } } @@ -346,7 +346,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) foreach (var item in CustomOpenIdConnectProviders) { builder.Append($" '{item.Key}': "); - AppendChildObject(builder, item.Value, options, 4, false, " customOpenIdConnectProviders: "); + BicepSerializationHelpers.AppendChildObject(builder, item.Value, options, 4, false, " customOpenIdConnectProviders: "); } builder.AppendLine(" }"); } @@ -357,48 +357,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppIdentityProvidersConfiguration.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppIdentityProvidersConfiguration.cs index 9cf2c6a7f9917..3efc78b2b024c 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppIdentityProvidersConfiguration.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppIdentityProvidersConfiguration.cs @@ -7,7 +7,7 @@ using System; using System.Collections.Generic; -using Azure.Core; +using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models { diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppIngressConfiguration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppIngressConfiguration.Serialization.cs index 107e9719a3880..b798ec26d7f21 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppIngressConfiguration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppIngressConfiguration.Serialization.cs @@ -405,7 +405,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Traffic) { - AppendChildObject(builder, item, options, 4, true, " traffic: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " traffic: "); } builder.AppendLine(" ]"); } @@ -427,7 +427,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in CustomDomains) { - AppendChildObject(builder, item, options, 4, true, " customDomains: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " customDomains: "); } builder.AppendLine(" ]"); } @@ -464,7 +464,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in IPSecurityRestrictions) { - AppendChildObject(builder, item, options, 4, true, " ipSecurityRestrictions: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " ipSecurityRestrictions: "); } builder.AppendLine(" ]"); } @@ -481,7 +481,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, StickySessions, options, 2, false, " stickySessions: "); + BicepSerializationHelpers.AppendChildObject(builder, StickySessions, options, 2, false, " stickySessions: "); } } @@ -509,7 +509,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, CorsPolicy, options, 2, false, " corsPolicy: "); + BicepSerializationHelpers.AppendChildObject(builder, CorsPolicy, options, 2, false, " corsPolicy: "); } } @@ -517,48 +517,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppInitContainer.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppInitContainer.Serialization.cs index 87bee20ba9802..ad7ae7500ba0c 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppInitContainer.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppInitContainer.Serialization.cs @@ -237,46 +237,46 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("{"); - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); - if (Optional.IsDefined(Name) || hasPropertyOverride) + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Image), out propertyOverride); + if (Optional.IsDefined(Image) || hasPropertyOverride) { - builder.Append(" name: "); + builder.Append(" image: "); if (hasPropertyOverride) { builder.AppendLine($"{propertyOverride}"); } else { - if (Name.Contains(Environment.NewLine)) + if (Image.Contains(Environment.NewLine)) { builder.AppendLine("'''"); - builder.AppendLine($"{Name}'''"); + builder.AppendLine($"{Image}'''"); } else { - builder.AppendLine($"'{Name}'"); + builder.AppendLine($"'{Image}'"); } } } - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Image), out propertyOverride); - if (Optional.IsDefined(Image) || hasPropertyOverride) + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" image: "); + builder.Append(" name: "); if (hasPropertyOverride) { builder.AppendLine($"{propertyOverride}"); } else { - if (Image.Contains(Environment.NewLine)) + if (Name.Contains(Environment.NewLine)) { builder.AppendLine("'''"); - builder.AppendLine($"{Image}'''"); + builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($"'{Image}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -366,7 +366,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Env) { - AppendChildObject(builder, item, options, 4, true, " env: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " env: "); } builder.AppendLine(" ]"); } @@ -383,7 +383,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Resources, options, 2, false, " resources: "); + BicepSerializationHelpers.AppendChildObject(builder, Resources, options, 2, false, " resources: "); } } @@ -402,7 +402,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in VolumeMounts) { - AppendChildObject(builder, item, options, 4, true, " volumeMounts: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " volumeMounts: "); } builder.AppendLine(" ]"); } @@ -413,48 +413,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobConfiguration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobConfiguration.Serialization.cs index 6aa10c6352b9f..3c7538534a897 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobConfiguration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobConfiguration.Serialization.cs @@ -242,7 +242,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Secrets) { - AppendChildObject(builder, item, options, 4, true, " secrets: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " secrets: "); } builder.AppendLine(" ]"); } @@ -295,7 +295,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, ManualTriggerConfig, options, 2, false, " manualTriggerConfig: "); + BicepSerializationHelpers.AppendChildObject(builder, ManualTriggerConfig, options, 2, false, " manualTriggerConfig: "); } } @@ -309,7 +309,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, ScheduleTriggerConfig, options, 2, false, " scheduleTriggerConfig: "); + BicepSerializationHelpers.AppendChildObject(builder, ScheduleTriggerConfig, options, 2, false, " scheduleTriggerConfig: "); } } @@ -323,7 +323,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, EventTriggerConfig, options, 2, false, " eventTriggerConfig: "); + BicepSerializationHelpers.AppendChildObject(builder, EventTriggerConfig, options, 2, false, " eventTriggerConfig: "); } } @@ -342,7 +342,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Registries) { - AppendChildObject(builder, item, options, 4, true, " registries: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " registries: "); } builder.AppendLine(" ]"); } @@ -353,48 +353,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobExecutionBase.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobExecutionBase.Serialization.cs index 1df9d4785bc86..1551e41928bc2 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobExecutionBase.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobExecutionBase.Serialization.cs @@ -161,48 +161,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobExecutionTemplate.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobExecutionTemplate.Serialization.cs index 7a2cfc27e439c..4dae9555753f1 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobExecutionTemplate.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobExecutionTemplate.Serialization.cs @@ -157,7 +157,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Containers) { - AppendChildObject(builder, item, options, 4, true, " containers: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " containers: "); } builder.AppendLine(" ]"); } @@ -179,7 +179,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in InitContainers) { - AppendChildObject(builder, item, options, 4, true, " initContainers: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " initContainers: "); } builder.AppendLine(" ]"); } @@ -190,48 +190,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobExecutions.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobExecutions.Serialization.cs index f6bec2558ca93..0f910ac4628cd 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobExecutions.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobExecutions.Serialization.cs @@ -136,7 +136,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -169,48 +169,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobPatch.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobPatch.cs index 44a83af450828..058acbc62aa63 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobPatch.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobPatch.cs @@ -7,7 +7,7 @@ using System; using System.Collections.Generic; -using Azure.Core; +using Azure.ResourceManager.AppContainers; using Azure.ResourceManager.Models; namespace Azure.ResourceManager.AppContainers.Models diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobScale.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobScale.Serialization.cs index 73722019d2cb8..1728c723339ca 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobScale.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobScale.Serialization.cs @@ -219,7 +219,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Rules) { - AppendChildObject(builder, item, options, 4, true, " rules: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " rules: "); } builder.AppendLine(" ]"); } @@ -230,48 +230,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobScaleRule.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobScaleRule.Serialization.cs index e5d396d06e033..a54c39383a65d 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobScaleRule.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobScaleRule.Serialization.cs @@ -183,6 +183,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } } + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(JobScaleRuleType), out propertyOverride); + if (Optional.IsDefined(JobScaleRuleType) || hasPropertyOverride) + { + builder.Append(" type: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (JobScaleRuleType.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{JobScaleRuleType}'''"); + } + else + { + builder.AppendLine($"'{JobScaleRuleType}'"); + } + } + } + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Metadata), out propertyOverride); if (Optional.IsDefined(Metadata) || hasPropertyOverride) { @@ -212,7 +234,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Auth) { - AppendChildObject(builder, item, options, 4, true, " auth: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " auth: "); } builder.AppendLine(" ]"); } @@ -223,48 +245,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobTemplate.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobTemplate.Serialization.cs index 33c857b17ff89..d5c2f5cafeef9 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobTemplate.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobTemplate.Serialization.cs @@ -182,7 +182,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in InitContainers) { - AppendChildObject(builder, item, options, 4, true, " initContainers: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " initContainers: "); } builder.AppendLine(" ]"); } @@ -204,7 +204,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Containers) { - AppendChildObject(builder, item, options, 4, true, " containers: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " containers: "); } builder.AppendLine(" ]"); } @@ -226,7 +226,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Volumes) { - AppendChildObject(builder, item, options, 4, true, " volumes: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " volumes: "); } builder.AppendLine(" ]"); } @@ -237,48 +237,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobsCollection.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobsCollection.Serialization.cs index 8f094abcd3a91..7b41bd583103d 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobsCollection.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJobsCollection.Serialization.cs @@ -136,7 +136,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -169,48 +169,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJwtClaimChecks.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJwtClaimChecks.Serialization.cs index 38c7bcad066a4..e87ec84901250 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJwtClaimChecks.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppJwtClaimChecks.Serialization.cs @@ -216,48 +216,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppLogAnalyticsConfiguration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppLogAnalyticsConfiguration.Serialization.cs index 03f9b9de49973..00db96c64ecfc 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppLogAnalyticsConfiguration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppLogAnalyticsConfiguration.Serialization.cs @@ -161,48 +161,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppLogin.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppLogin.Serialization.cs index fa714ddebfdf5..9ff56b6974a92 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppLogin.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppLogin.Serialization.cs @@ -193,7 +193,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Routes, options, 2, false, " routes: "); + BicepSerializationHelpers.AppendChildObject(builder, Routes, options, 2, false, " routes: "); } } @@ -257,7 +257,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, CookieExpiration, options, 2, false, " cookieExpiration: "); + BicepSerializationHelpers.AppendChildObject(builder, CookieExpiration, options, 2, false, " cookieExpiration: "); } } @@ -271,7 +271,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Nonce, options, 2, false, " nonce: "); + BicepSerializationHelpers.AppendChildObject(builder, Nonce, options, 2, false, " nonce: "); } } @@ -279,48 +279,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppLoginNonce.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppLoginNonce.Serialization.cs index 1b703d4f33031..ebc91436f0d6e 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppLoginNonce.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppLoginNonce.Serialization.cs @@ -158,48 +158,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppLogsConfiguration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppLogsConfiguration.Serialization.cs index 59b988d749f0a..1a41f9e3a36c9 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppLogsConfiguration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppLogsConfiguration.Serialization.cs @@ -149,7 +149,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, LogAnalyticsConfiguration, options, 2, false, " logAnalyticsConfiguration: "); + BicepSerializationHelpers.AppendChildObject(builder, LogAnalyticsConfiguration, options, 2, false, " logAnalyticsConfiguration: "); } } @@ -157,48 +157,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppManagedCertificatePatch.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppManagedCertificatePatch.cs index 24cc5bb041467..175debb25946f 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppManagedCertificatePatch.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppManagedCertificatePatch.cs @@ -7,7 +7,7 @@ using System; using System.Collections.Generic; -using Azure.Core; +using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models { diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppNameAvailabilityResult.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppNameAvailabilityResult.Serialization.cs index 078ab98788fd2..3582a7826d41d 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppNameAvailabilityResult.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppNameAvailabilityResult.Serialization.cs @@ -187,48 +187,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppOpenIdConnectClientCredential.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppOpenIdConnectClientCredential.Serialization.cs index f403159800951..f3d471b81e8ae 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppOpenIdConnectClientCredential.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppOpenIdConnectClientCredential.Serialization.cs @@ -157,48 +157,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppOpenIdConnectConfig.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppOpenIdConnectConfig.Serialization.cs index 43ee4af272004..05857031c756f 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppOpenIdConnectConfig.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppOpenIdConnectConfig.Serialization.cs @@ -262,48 +262,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppOpenIdConnectLogin.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppOpenIdConnectLogin.Serialization.cs index 4d0897cdcabbb..a071a1f238beb 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppOpenIdConnectLogin.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppOpenIdConnectLogin.Serialization.cs @@ -189,48 +189,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppOpenIdConnectRegistration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppOpenIdConnectRegistration.Serialization.cs index ec63d9bd30994..dc8d1b4f6b36f 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppOpenIdConnectRegistration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppOpenIdConnectRegistration.Serialization.cs @@ -164,7 +164,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, ClientCredential, options, 2, false, " clientCredential: "); + BicepSerializationHelpers.AppendChildObject(builder, ClientCredential, options, 2, false, " clientCredential: "); } } @@ -178,7 +178,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, OpenIdConnectConfiguration, options, 2, false, " openIdConnectConfiguration: "); + BicepSerializationHelpers.AppendChildObject(builder, OpenIdConnectConfiguration, options, 2, false, " openIdConnectConfiguration: "); } } @@ -186,48 +186,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppProbe.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppProbe.Serialization.cs index 22a60c45f6c03..6a06d91d06d1f 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppProbe.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppProbe.Serialization.cs @@ -260,7 +260,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, HttpGet, options, 2, false, " httpGet: "); + BicepSerializationHelpers.AppendChildObject(builder, HttpGet, options, 2, false, " httpGet: "); } } @@ -316,7 +316,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, TcpSocket, options, 2, false, " tcpSocket: "); + BicepSerializationHelpers.AppendChildObject(builder, TcpSocket, options, 2, false, " tcpSocket: "); } } @@ -348,50 +348,22 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } } - builder.AppendLine("}"); - return BinaryData.FromString(builder.ToString()); - } - - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProbeType), out propertyOverride); + if (Optional.IsDefined(ProbeType) || hasPropertyOverride) { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) + builder.Append(" type: "); + if (hasPropertyOverride) { - stringBuilder.AppendLine($"{line}"); + builder.AppendLine($"{propertyOverride}"); } else { - stringBuilder.AppendLine($"{indent}{line}"); + builder.AppendLine($"'{ProbeType.Value.ToString()}'"); } } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppQueueScaleRule.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppQueueScaleRule.Serialization.cs index 8b81bb8532e7e..061b7e0139f9f 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppQueueScaleRule.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppQueueScaleRule.Serialization.cs @@ -194,7 +194,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Auth) { - AppendChildObject(builder, item, options, 4, true, " auth: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " auth: "); } builder.AppendLine(" ]"); } @@ -205,48 +205,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppRegistration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppRegistration.Serialization.cs index eb967c043c98a..e42e6783e5e21 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppRegistration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppRegistration.Serialization.cs @@ -161,48 +161,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppRegistryCredentials.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppRegistryCredentials.Serialization.cs index 843d0d6230e00..dff151360b683 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppRegistryCredentials.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppRegistryCredentials.Serialization.cs @@ -227,48 +227,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppRegistryInfo.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppRegistryInfo.Serialization.cs index 48d34bdf63d40..8c6b6d9c5a417 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppRegistryInfo.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppRegistryInfo.Serialization.cs @@ -194,48 +194,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppReplicaContainer.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppReplicaContainer.Serialization.cs index df28661317c41..4113f98ae0aa3 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppReplicaContainer.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppReplicaContainer.Serialization.cs @@ -388,48 +388,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppRevisionTrafficWeight.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppRevisionTrafficWeight.Serialization.cs index 9eff5ddca6170..2bb4df31ad68b 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppRevisionTrafficWeight.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppRevisionTrafficWeight.Serialization.cs @@ -220,48 +220,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppScale.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppScale.Serialization.cs index c1ef0eb600791..4aa13275191e3 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppScale.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppScale.Serialization.cs @@ -190,7 +190,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Rules) { - AppendChildObject(builder, item, options, 4, true, " rules: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " rules: "); } builder.AppendLine(" ]"); } @@ -201,48 +201,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppScaleRule.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppScaleRule.Serialization.cs index 6c5e61916e42e..4f3afe5827eb0 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppScaleRule.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppScaleRule.Serialization.cs @@ -200,7 +200,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, AzureQueue, options, 2, false, " azureQueue: "); + BicepSerializationHelpers.AppendChildObject(builder, AzureQueue, options, 2, false, " azureQueue: "); } } @@ -214,7 +214,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Custom, options, 2, false, " custom: "); + BicepSerializationHelpers.AppendChildObject(builder, Custom, options, 2, false, " custom: "); } } @@ -228,7 +228,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Http, options, 2, false, " http: "); + BicepSerializationHelpers.AppendChildObject(builder, Http, options, 2, false, " http: "); } } @@ -242,7 +242,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Tcp, options, 2, false, " tcp: "); + BicepSerializationHelpers.AppendChildObject(builder, Tcp, options, 2, false, " tcp: "); } } @@ -250,48 +250,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppScaleRuleAuth.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppScaleRuleAuth.Serialization.cs index d7b777cdb6db8..48b2beb0155b4 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppScaleRuleAuth.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppScaleRuleAuth.Serialization.cs @@ -161,48 +161,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppSecret.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppSecret.Serialization.cs index 0b1e2ae1190e6..c34d3554775cd 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppSecret.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppSecret.Serialization.cs @@ -223,48 +223,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppServiceBind.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppServiceBind.Serialization.cs index 34b14d65ecaec..5461399c26102 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppServiceBind.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppServiceBind.Serialization.cs @@ -117,6 +117,20 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("{"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ServiceId), out propertyOverride); + if (Optional.IsDefined(ServiceId) || hasPropertyOverride) + { + builder.Append(" serviceId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ServiceId.ToString()}'"); + } + } + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { @@ -139,66 +153,10 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } } - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ServiceId), out propertyOverride); - if (Optional.IsDefined(ServiceId) || hasPropertyOverride) - { - builder.Append(" serviceId: "); - if (hasPropertyOverride) - { - builder.AppendLine($"{propertyOverride}"); - } - else - { - builder.AppendLine($"'{ServiceId.ToString()}'"); - } - } - builder.AppendLine("}"); return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTcpScaleRule.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTcpScaleRule.Serialization.cs index 6aab73a919a1f..446e4779cd6eb 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTcpScaleRule.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTcpScaleRule.Serialization.cs @@ -194,7 +194,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Auth) { - AppendChildObject(builder, item, options, 4, true, " auth: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " auth: "); } builder.AppendLine(" ]"); } @@ -205,48 +205,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTcpScaleRule.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTcpScaleRule.cs index 82ab2e037e5c3..ae76f92516dfc 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTcpScaleRule.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTcpScaleRule.cs @@ -7,7 +7,6 @@ using System; using System.Collections.Generic; -using Azure.Core; using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTcpSocketRequestInfo.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTcpSocketRequestInfo.Serialization.cs index c77fb52343740..018a8aaae9f5f 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTcpSocketRequestInfo.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTcpSocketRequestInfo.Serialization.cs @@ -147,48 +147,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTemplate.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTemplate.Serialization.cs index 98b10ea10fba8..dd4702bc67860 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTemplate.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTemplate.Serialization.cs @@ -292,7 +292,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in InitContainers) { - AppendChildObject(builder, item, options, 4, true, " initContainers: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " initContainers: "); } builder.AppendLine(" ]"); } @@ -314,7 +314,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Containers) { - AppendChildObject(builder, item, options, 4, true, " containers: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " containers: "); } builder.AppendLine(" ]"); } @@ -331,7 +331,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Scale, options, 2, false, " scale: "); + BicepSerializationHelpers.AppendChildObject(builder, Scale, options, 2, false, " scale: "); } } @@ -350,7 +350,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Volumes) { - AppendChildObject(builder, item, options, 4, true, " volumes: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " volumes: "); } builder.AppendLine(" ]"); } @@ -372,7 +372,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in ServiceBinds) { - AppendChildObject(builder, item, options, 4, true, " serviceBinds: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " serviceBinds: "); } builder.AppendLine(" ]"); } @@ -383,48 +383,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTwitterConfiguration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTwitterConfiguration.Serialization.cs index fca519bf7c12f..571d1fbbf8783 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTwitterConfiguration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTwitterConfiguration.Serialization.cs @@ -146,7 +146,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Registration, options, 2, false, " registration: "); + BicepSerializationHelpers.AppendChildObject(builder, Registration, options, 2, false, " registration: "); } } @@ -154,48 +154,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTwitterRegistration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTwitterRegistration.Serialization.cs index 1ec78f062466c..e19d4a3c0c4ed 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTwitterRegistration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppTwitterRegistration.Serialization.cs @@ -161,48 +161,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppVnetConfiguration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppVnetConfiguration.Serialization.cs index 6692a0160dd55..e136ccdff5db2 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppVnetConfiguration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppVnetConfiguration.Serialization.cs @@ -259,48 +259,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppVolume.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppVolume.Serialization.cs index ef89ad74054a6..6a5a3b5dddaa5 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppVolume.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppVolume.Serialization.cs @@ -244,7 +244,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Secrets) { - AppendChildObject(builder, item, options, 4, true, " secrets: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " secrets: "); } builder.AppendLine(" ]"); } @@ -277,48 +277,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppVolumeMount.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppVolumeMount.Serialization.cs index 8c5c925e252fb..9df06c8e5f3b8 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppVolumeMount.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppVolumeMount.Serialization.cs @@ -194,48 +194,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppWorkloadProfile.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppWorkloadProfile.Serialization.cs index 8b1221e45ecd8..b3028ad527e56 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppWorkloadProfile.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppWorkloadProfile.Serialization.cs @@ -213,48 +213,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppWorkloadProfileState.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppWorkloadProfileState.Serialization.cs index 8b705cb7fb25f..73cb7e61dee42 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppWorkloadProfileState.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppWorkloadProfileState.Serialization.cs @@ -193,7 +193,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Properties, options, 2, false, " properties: "); + BicepSerializationHelpers.AppendChildObject(builder, Properties, options, 2, false, " properties: "); } } @@ -229,48 +229,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppWorkloadProfileStateProperties.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppWorkloadProfileStateProperties.Serialization.cs index 7720a071b2793..8b08501727072 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppWorkloadProfileStateProperties.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppWorkloadProfileStateProperties.Serialization.cs @@ -182,48 +182,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppWritableSecret.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppWritableSecret.Serialization.cs index 642505be91041..fc2c9fb9473db 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppWritableSecret.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ContainerAppWritableSecret.Serialization.cs @@ -223,48 +223,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/DaprComponentsCollection.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/DaprComponentsCollection.Serialization.cs index 6bd58c504dc25..f41c43f8ff351 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/DaprComponentsCollection.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/DaprComponentsCollection.Serialization.cs @@ -136,7 +136,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -169,48 +169,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/DaprConfiguration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/DaprConfiguration.Serialization.cs index c462faa73e7b2..89d248589cce3 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/DaprConfiguration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/DaprConfiguration.Serialization.cs @@ -128,48 +128,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/DaprSecretsCollection.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/DaprSecretsCollection.Serialization.cs index 04836daa39ed6..9d67216ff1c9e 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/DaprSecretsCollection.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/DaprSecretsCollection.Serialization.cs @@ -125,7 +125,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -136,48 +136,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/DiagnosticsCollection.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/DiagnosticsCollection.Serialization.cs index 24de1704277db..735fcc019cfea 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/DiagnosticsCollection.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/DiagnosticsCollection.Serialization.cs @@ -136,7 +136,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -169,48 +169,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/EventTriggerConfiguration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/EventTriggerConfiguration.Serialization.cs index dc43e21376abe..fa49830e816de 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/EventTriggerConfiguration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/EventTriggerConfiguration.Serialization.cs @@ -174,7 +174,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Scale, options, 2, false, " scale: "); + BicepSerializationHelpers.AppendChildObject(builder, Scale, options, 2, false, " scale: "); } } @@ -182,48 +182,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/HttpSettingsRoutes.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/HttpSettingsRoutes.Serialization.cs index 94495b0f5958a..739ffee07492d 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/HttpSettingsRoutes.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/HttpSettingsRoutes.Serialization.cs @@ -128,48 +128,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/IngressStickySessions.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/IngressStickySessions.Serialization.cs index af297efeebb0f..5a3c9fe4ab3b0 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/IngressStickySessions.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/IngressStickySessions.Serialization.cs @@ -124,48 +124,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/JobConfigurationManualTriggerConfig.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/JobConfigurationManualTriggerConfig.Serialization.cs index ff4ac72e5fcd1..eb0141a45fdb9 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/JobConfigurationManualTriggerConfig.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/JobConfigurationManualTriggerConfig.Serialization.cs @@ -153,48 +153,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/JobConfigurationScheduleTriggerConfig.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/JobConfigurationScheduleTriggerConfig.Serialization.cs index 6b541b5954437..5e164dcc66b0c 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/JobConfigurationScheduleTriggerConfig.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/JobConfigurationScheduleTriggerConfig.Serialization.cs @@ -183,48 +183,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/JobExecutionContainer.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/JobExecutionContainer.Serialization.cs index e989d5afef66a..01c98ed8b8436 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/JobExecutionContainer.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/JobExecutionContainer.Serialization.cs @@ -211,46 +211,46 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("{"); - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); - if (Optional.IsDefined(Name) || hasPropertyOverride) + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Image), out propertyOverride); + if (Optional.IsDefined(Image) || hasPropertyOverride) { - builder.Append(" name: "); + builder.Append(" image: "); if (hasPropertyOverride) { builder.AppendLine($"{propertyOverride}"); } else { - if (Name.Contains(Environment.NewLine)) + if (Image.Contains(Environment.NewLine)) { builder.AppendLine("'''"); - builder.AppendLine($"{Name}'''"); + builder.AppendLine($"{Image}'''"); } else { - builder.AppendLine($"'{Name}'"); + builder.AppendLine($"'{Image}'"); } } } - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Image), out propertyOverride); - if (Optional.IsDefined(Image) || hasPropertyOverride) + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" image: "); + builder.Append(" name: "); if (hasPropertyOverride) { builder.AppendLine($"{propertyOverride}"); } else { - if (Image.Contains(Environment.NewLine)) + if (Name.Contains(Environment.NewLine)) { builder.AppendLine("'''"); - builder.AppendLine($"{Image}'''"); + builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($"'{Image}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -340,7 +340,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Env) { - AppendChildObject(builder, item, options, 4, true, " env: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " env: "); } builder.AppendLine(" ]"); } @@ -357,7 +357,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Resources, options, 2, false, " resources: "); + BicepSerializationHelpers.AppendChildObject(builder, Resources, options, 2, false, " resources: "); } } @@ -365,48 +365,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/JobSecretsCollection.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/JobSecretsCollection.Serialization.cs index 4eabb6adfce75..8f6c21ec53709 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/JobSecretsCollection.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/JobSecretsCollection.Serialization.cs @@ -125,7 +125,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -136,48 +136,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/KedaConfiguration.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/KedaConfiguration.Serialization.cs index 177655f25efe5..bd9e718033ad5 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/KedaConfiguration.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/KedaConfiguration.Serialization.cs @@ -128,48 +128,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/LoginRoutes.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/LoginRoutes.Serialization.cs index 0b7e93bd26250..b98b1f9b2cebc 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/LoginRoutes.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/LoginRoutes.Serialization.cs @@ -128,48 +128,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/LoginScopes.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/LoginScopes.Serialization.cs index d338903001167..7eb46e726d8de 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/LoginScopes.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/LoginScopes.Serialization.cs @@ -156,48 +156,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedCertificateCollection.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedCertificateCollection.Serialization.cs index abb0c9c0972aa..b1a98113486b6 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedCertificateCollection.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedCertificateCollection.Serialization.cs @@ -136,7 +136,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -169,48 +169,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedCertificateProperties.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedCertificateProperties.Serialization.cs index 49bb2f579f059..c271b128b3b5b 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedCertificateProperties.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedCertificateProperties.Serialization.cs @@ -258,48 +258,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedEnvironmentPropertiesPeerAuthentication.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedEnvironmentPropertiesPeerAuthentication.Serialization.cs index 7dd7e89f1d6d9..5a9234a6f633d 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedEnvironmentPropertiesPeerAuthentication.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedEnvironmentPropertiesPeerAuthentication.Serialization.cs @@ -116,7 +116,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Mtls, options, 2, false, " mtls: "); + BicepSerializationHelpers.AppendChildObject(builder, Mtls, options, 2, false, " mtls: "); } } @@ -124,48 +124,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedEnvironmentStorageProperties.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedEnvironmentStorageProperties.Serialization.cs index d34eefbaa48f2..8880b97dee1e8 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedEnvironmentStorageProperties.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedEnvironmentStorageProperties.Serialization.cs @@ -116,7 +116,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, AzureFile, options, 2, false, " azureFile: "); + BicepSerializationHelpers.AppendChildObject(builder, AzureFile, options, 2, false, " azureFile: "); } } @@ -124,48 +124,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedEnvironmentStoragesCollection.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedEnvironmentStoragesCollection.Serialization.cs index 648e280355d3d..c2a561f6e7298 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedEnvironmentStoragesCollection.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedEnvironmentStoragesCollection.Serialization.cs @@ -125,7 +125,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -136,48 +136,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedEnvironmentsCollection.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedEnvironmentsCollection.Serialization.cs index c93525c14be26..8eeeec9532249 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedEnvironmentsCollection.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ManagedEnvironmentsCollection.Serialization.cs @@ -136,7 +136,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -169,48 +169,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/Mtls.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/Mtls.Serialization.cs index b0bffc07d1499..66d3d3608ec62 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/Mtls.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/Mtls.Serialization.cs @@ -125,48 +125,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ReplicaCollection.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ReplicaCollection.Serialization.cs index 3015ede29655b..f1e4281171ce6 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ReplicaCollection.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/ReplicaCollection.Serialization.cs @@ -125,7 +125,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -136,48 +136,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/RevisionCollection.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/RevisionCollection.Serialization.cs index 47d568f0d9484..5a32892bf6aee 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/RevisionCollection.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/RevisionCollection.Serialization.cs @@ -136,7 +136,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -169,48 +169,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/SecretVolumeItem.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/SecretVolumeItem.Serialization.cs index 7a768d09037d6..883a1ff226b33 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/SecretVolumeItem.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/SecretVolumeItem.Serialization.cs @@ -161,48 +161,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/SecretsCollection.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/SecretsCollection.Serialization.cs index b7f703f4d94ea..fcc3cc8b084ca 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/SecretsCollection.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/SecretsCollection.Serialization.cs @@ -125,7 +125,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -136,48 +136,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/Service.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/Service.Serialization.cs index 8195dc5e494b3..bbf8a3fd2babb 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/Service.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/Service.Serialization.cs @@ -12,6 +12,7 @@ using System.Text.Json; using Azure.Core; using Azure.ResourceManager; +using Azure.ResourceManager.AppContainers; namespace Azure.ResourceManager.AppContainers.Models { @@ -98,50 +99,30 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("{"); - builder.AppendLine("}"); - return BinaryData.FromString(builder.ToString()); - } - - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ServiceType), out propertyOverride); + if (Optional.IsDefined(ServiceType) || hasPropertyOverride) { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) + builder.Append(" type: "); + if (hasPropertyOverride) { - stringBuilder.AppendLine($"{line}"); + builder.AppendLine($"{propertyOverride}"); } else { - stringBuilder.AppendLine($"{indent}{line}"); + if (ServiceType.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ServiceType}'''"); + } + else + { + builder.AppendLine($"'{ServiceType}'"); + } } } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/SourceControlCollection.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/SourceControlCollection.Serialization.cs index 8bfd0f45a0962..b5bca95cf9507 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/SourceControlCollection.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/SourceControlCollection.Serialization.cs @@ -136,7 +136,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -169,48 +169,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/WorkloadProfileStatesCollection.Serialization.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/WorkloadProfileStatesCollection.Serialization.cs index c2436953b23b6..817fec980b85d 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/WorkloadProfileStatesCollection.Serialization.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/src/Generated/Models/WorkloadProfileStatesCollection.Serialization.cs @@ -136,7 +136,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -169,48 +169,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryAgentPoolData.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryAgentPoolData.Serialization.cs index 21368020df5c7..a4401195b3545 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryAgentPoolData.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryAgentPoolData.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry.Models; using Azure.ResourceManager.Models; @@ -259,6 +262,199 @@ internal static ContainerRegistryAgentPoolData DeserializeContainerRegistryAgent serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); + builder.Append(" location: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Location.ToString()}'"); + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tags), out propertyOverride); + if (Optional.IsCollectionDefined(Tags) || hasPropertyOverride) + { + if (Tags.Any() || hasPropertyOverride) + { + builder.Append(" tags: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("{"); + foreach (var item in Tags) + { + builder.Append($" '{item.Key}': "); + if (item.Value == null) + { + builder.Append("null"); + continue; + } + if (item.Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{item.Value}'''"); + } + else + { + builder.AppendLine($"'{item.Value}'"); + } + } + builder.AppendLine(" }"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Count), out propertyOverride); + if (Optional.IsDefined(Count) || hasPropertyOverride) + { + builder.Append(" count: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{Count.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tier), out propertyOverride); + if (Optional.IsDefined(Tier) || hasPropertyOverride) + { + builder.Append(" tier: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Tier.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Tier}'''"); + } + else + { + builder.AppendLine($"'{Tier}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(OS), out propertyOverride); + if (Optional.IsDefined(OS) || hasPropertyOverride) + { + builder.Append(" os: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{OS.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(VirtualNetworkSubnetResourceId), out propertyOverride); + if (Optional.IsDefined(VirtualNetworkSubnetResourceId) || hasPropertyOverride) + { + builder.Append(" virtualNetworkSubnetResourceId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{VirtualNetworkSubnetResourceId.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); + if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) + { + builder.Append(" provisioningState: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ProvisioningState.Value.ToString()}'"); + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -267,6 +463,8 @@ BinaryData IPersistableModel.Write(ModelReaderWr { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryAgentPoolData)} does not support '{options.Format}' format."); } @@ -283,6 +481,8 @@ ContainerRegistryAgentPoolData IPersistableModel using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerRegistryAgentPoolData(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerRegistryAgentPoolData)} does not support '{options.Format}' format."); } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryAgentPoolData.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryAgentPoolData.cs index 66bbcadd566c6..b6eb31cc6c348 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryAgentPoolData.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryAgentPoolData.cs @@ -87,14 +87,19 @@ internal ContainerRegistryAgentPoolData() } /// The count of agent machine. + [WirePath("properties.count")] public int? Count { get; set; } /// The Tier of agent machine. + [WirePath("properties.tier")] public string Tier { get; set; } /// The OS of agent machine. + [WirePath("properties.os")] public ContainerRegistryOS? OS { get; set; } /// The Virtual Network Subnet Resource Id of the agent machine. + [WirePath("properties.virtualNetworkSubnetResourceId")] public ResourceIdentifier VirtualNetworkSubnetResourceId { get; set; } /// The provisioning state of this agent pool. + [WirePath("properties.provisioningState")] public ContainerRegistryProvisioningState? ProvisioningState { get; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryData.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryData.Serialization.cs index 73c471194be19..ad1a9fb4f4209 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryData.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryData.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry.Models; using Azure.ResourceManager.Models; @@ -448,6 +451,385 @@ internal static ContainerRegistryData DeserializeContainerRegistryData(JsonEleme serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); + builder.Append(" location: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Location.ToString()}'"); + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tags), out propertyOverride); + if (Optional.IsCollectionDefined(Tags) || hasPropertyOverride) + { + if (Tags.Any() || hasPropertyOverride) + { + builder.Append(" tags: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("{"); + foreach (var item in Tags) + { + builder.Append($" '{item.Key}': "); + if (item.Value == null) + { + builder.Append("null"); + continue; + } + if (item.Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{item.Value}'''"); + } + else + { + builder.AppendLine($"'{item.Value}'"); + } + } + builder.AppendLine(" }"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Sku), out propertyOverride); + if (Optional.IsDefined(Sku) || hasPropertyOverride) + { + builder.Append(" sku: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, Sku, options, 2, false, " sku: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Identity), out propertyOverride); + if (Optional.IsDefined(Identity) || hasPropertyOverride) + { + builder.Append(" identity: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, Identity, options, 2, false, " identity: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LoginServer), out propertyOverride); + if (Optional.IsDefined(LoginServer) || hasPropertyOverride) + { + builder.Append(" loginServer: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (LoginServer.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{LoginServer}'''"); + } + else + { + builder.AppendLine($"'{LoginServer}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); + if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) + { + builder.Append(" creationDate: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); + if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) + { + builder.Append(" provisioningState: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ProvisioningState.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); + if (Optional.IsDefined(Status) || hasPropertyOverride) + { + builder.Append(" status: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, Status, options, 4, false, " status: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsAdminUserEnabled), out propertyOverride); + if (Optional.IsDefined(IsAdminUserEnabled) || hasPropertyOverride) + { + builder.Append(" adminUserEnabled: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsAdminUserEnabled.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NetworkRuleSet), out propertyOverride); + if (Optional.IsDefined(NetworkRuleSet) || hasPropertyOverride) + { + builder.Append(" networkRuleSet: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, NetworkRuleSet, options, 4, false, " networkRuleSet: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Policies), out propertyOverride); + if (Optional.IsDefined(Policies) || hasPropertyOverride) + { + builder.Append(" policies: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, Policies, options, 4, false, " policies: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Encryption), out propertyOverride); + if (Optional.IsDefined(Encryption) || hasPropertyOverride) + { + builder.Append(" encryption: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, Encryption, options, 4, false, " encryption: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsDataEndpointEnabled), out propertyOverride); + if (Optional.IsDefined(IsDataEndpointEnabled) || hasPropertyOverride) + { + builder.Append(" dataEndpointEnabled: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsDataEndpointEnabled.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DataEndpointHostNames), out propertyOverride); + if (Optional.IsCollectionDefined(DataEndpointHostNames) || hasPropertyOverride) + { + if (DataEndpointHostNames.Any() || hasPropertyOverride) + { + builder.Append(" dataEndpointHostNames: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in DataEndpointHostNames) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrivateEndpointConnections), out propertyOverride); + if (Optional.IsCollectionDefined(PrivateEndpointConnections) || hasPropertyOverride) + { + if (PrivateEndpointConnections.Any() || hasPropertyOverride) + { + builder.Append(" privateEndpointConnections: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in PrivateEndpointConnections) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 6, true, " privateEndpointConnections: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PublicNetworkAccess), out propertyOverride); + if (Optional.IsDefined(PublicNetworkAccess) || hasPropertyOverride) + { + builder.Append(" publicNetworkAccess: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{PublicNetworkAccess.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NetworkRuleBypassOptions), out propertyOverride); + if (Optional.IsDefined(NetworkRuleBypassOptions) || hasPropertyOverride) + { + builder.Append(" networkRuleBypassOptions: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{NetworkRuleBypassOptions.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ZoneRedundancy), out propertyOverride); + if (Optional.IsDefined(ZoneRedundancy) || hasPropertyOverride) + { + builder.Append(" zoneRedundancy: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ZoneRedundancy.Value.ToString()}'"); + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -456,6 +838,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptio { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryData)} does not support '{options.Format}' format."); } @@ -472,6 +856,8 @@ ContainerRegistryData IPersistableModel.Create(BinaryData using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerRegistryData(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerRegistryData)} does not support '{options.Format}' format."); } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryData.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryData.cs index 598072e86b5e0..59a4052182abb 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryData.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryData.cs @@ -115,36 +115,52 @@ internal ContainerRegistryData() } /// The SKU of the container registry. + [WirePath("sku")] public ContainerRegistrySku Sku { get; set; } /// The identity of the container registry. + [WirePath("identity")] public ManagedServiceIdentity Identity { get; set; } /// The URL that can be used to log into the container registry. + [WirePath("properties.loginServer")] public string LoginServer { get; } /// The creation date of the container registry in ISO8601 format. + [WirePath("properties.creationDate")] public DateTimeOffset? CreatedOn { get; } /// The provisioning state of the container registry at the time the operation was called. + [WirePath("properties.provisioningState")] public ContainerRegistryProvisioningState? ProvisioningState { get; } /// The status of the container registry at the time the operation was called. + [WirePath("properties.status")] public ContainerRegistryResourceStatus Status { get; } /// The value that indicates whether the admin user is enabled. + [WirePath("properties.adminUserEnabled")] public bool? IsAdminUserEnabled { get; set; } /// The network rule set for a container registry. + [WirePath("properties.networkRuleSet")] public ContainerRegistryNetworkRuleSet NetworkRuleSet { get; set; } /// The policies for a container registry. + [WirePath("properties.policies")] public ContainerRegistryPolicies Policies { get; set; } /// The encryption settings of container registry. + [WirePath("properties.encryption")] public ContainerRegistryEncryption Encryption { get; set; } /// Enable a single data endpoint per region for serving data. + [WirePath("properties.dataEndpointEnabled")] public bool? IsDataEndpointEnabled { get; set; } /// List of host names that will serve data when dataEndpointEnabled is true. + [WirePath("properties.dataEndpointHostNames")] public IReadOnlyList DataEndpointHostNames { get; } /// List of private endpoint connections for a container registry. + [WirePath("properties.privateEndpointConnections")] public IReadOnlyList PrivateEndpointConnections { get; } /// Whether or not public network access is allowed for the container registry. + [WirePath("properties.publicNetworkAccess")] public ContainerRegistryPublicNetworkAccess? PublicNetworkAccess { get; set; } /// Whether to allow trusted Azure services to access a network restricted registry. + [WirePath("properties.networkRuleBypassOptions")] public ContainerRegistryNetworkRuleBypassOption? NetworkRuleBypassOptions { get; set; } /// Whether or not zone redundancy is enabled for this container registry. + [WirePath("properties.zoneRedundancy")] public ContainerRegistryZoneRedundancy? ZoneRedundancy { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryPrivateEndpointConnectionData.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryPrivateEndpointConnectionData.Serialization.cs index d13f6f698fec9..42d03e54492d8 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryPrivateEndpointConnectionData.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryPrivateEndpointConnectionData.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry.Models; using Azure.ResourceManager.Models; using Azure.ResourceManager.Resources.Models; @@ -196,6 +198,116 @@ internal static ContainerRegistryPrivateEndpointConnectionData DeserializeContai serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrivateEndpoint), out propertyOverride); + if (Optional.IsDefined(PrivateEndpoint) || hasPropertyOverride) + { + builder.Append(" privateEndpoint: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, PrivateEndpoint, options, 4, false, " privateEndpoint: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ConnectionState), out propertyOverride); + if (Optional.IsDefined(ConnectionState) || hasPropertyOverride) + { + builder.Append(" privateLinkServiceConnectionState: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, ConnectionState, options, 4, false, " privateLinkServiceConnectionState: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); + if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) + { + builder.Append(" provisioningState: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ProvisioningState.Value.ToString()}'"); + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -204,6 +316,8 @@ BinaryData IPersistableModel.Wri { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryPrivateEndpointConnectionData)} does not support '{options.Format}' format."); } @@ -220,6 +334,8 @@ ContainerRegistryPrivateEndpointConnectionData IPersistableModel The resource of private endpoint. internal WritableSubResource PrivateEndpoint { get; set; } /// Gets or sets Id. + [WirePath("properties.privateEndpoint.id")] public ResourceIdentifier PrivateEndpointId { get => PrivateEndpoint is null ? default : PrivateEndpoint.Id; @@ -89,8 +90,10 @@ public ResourceIdentifier PrivateEndpointId } /// A collection of information about the state of the connection between service consumer and provider. + [WirePath("properties.privateLinkServiceConnectionState")] public ContainerRegistryPrivateLinkServiceConnectionState ConnectionState { get; set; } /// The provisioning state of private endpoint connection resource. + [WirePath("properties.provisioningState")] public ContainerRegistryProvisioningState? ProvisioningState { get; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryPrivateLinkResourceData.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryPrivateLinkResourceData.Serialization.cs index 1dfd134fd3286..b7e852b864cfc 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryPrivateLinkResourceData.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryPrivateLinkResourceData.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.Models; namespace Azure.ResourceManager.ContainerRegistry @@ -210,6 +213,166 @@ internal static ContainerRegistryPrivateLinkResourceData DeserializeContainerReg serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(GroupId), out propertyOverride); + if (Optional.IsDefined(GroupId) || hasPropertyOverride) + { + builder.Append(" groupId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (GroupId.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{GroupId}'''"); + } + else + { + builder.AppendLine($"'{GroupId}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RequiredMembers), out propertyOverride); + if (Optional.IsCollectionDefined(RequiredMembers) || hasPropertyOverride) + { + if (RequiredMembers.Any() || hasPropertyOverride) + { + builder.Append(" requiredMembers: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in RequiredMembers) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RequiredZoneNames), out propertyOverride); + if (Optional.IsCollectionDefined(RequiredZoneNames) || hasPropertyOverride) + { + if (RequiredZoneNames.Any() || hasPropertyOverride) + { + builder.Append(" requiredZoneNames: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in RequiredZoneNames) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -218,6 +381,8 @@ BinaryData IPersistableModel.Write(Mod { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryPrivateLinkResourceData)} does not support '{options.Format}' format."); } @@ -234,6 +399,8 @@ ContainerRegistryPrivateLinkResourceData IPersistableModel The private link resource group id. + [WirePath("properties.groupId")] public string GroupId { get; } /// The private link resource required member names. + [WirePath("properties.requiredMembers")] public IReadOnlyList RequiredMembers { get; } /// The private link resource Private link DNS zone name. + [WirePath("properties.requiredZoneNames")] public IReadOnlyList RequiredZoneNames { get; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryReplicationData.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryReplicationData.Serialization.cs index 40651c6345cbe..fdec672fca5e2 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryReplicationData.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryReplicationData.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry.Models; using Azure.ResourceManager.Models; @@ -247,6 +250,178 @@ internal static ContainerRegistryReplicationData DeserializeContainerRegistryRep serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); + builder.Append(" location: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Location.ToString()}'"); + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tags), out propertyOverride); + if (Optional.IsCollectionDefined(Tags) || hasPropertyOverride) + { + if (Tags.Any() || hasPropertyOverride) + { + builder.Append(" tags: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("{"); + foreach (var item in Tags) + { + builder.Append($" '{item.Key}': "); + if (item.Value == null) + { + builder.Append("null"); + continue; + } + if (item.Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{item.Value}'''"); + } + else + { + builder.AppendLine($"'{item.Value}'"); + } + } + builder.AppendLine(" }"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); + if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) + { + builder.Append(" provisioningState: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ProvisioningState.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); + if (Optional.IsDefined(Status) || hasPropertyOverride) + { + builder.Append(" status: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, Status, options, 4, false, " status: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsRegionEndpointEnabled), out propertyOverride); + if (Optional.IsDefined(IsRegionEndpointEnabled) || hasPropertyOverride) + { + builder.Append(" regionEndpointEnabled: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsRegionEndpointEnabled.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ZoneRedundancy), out propertyOverride); + if (Optional.IsDefined(ZoneRedundancy) || hasPropertyOverride) + { + builder.Append(" zoneRedundancy: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ZoneRedundancy.Value.ToString()}'"); + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -255,6 +430,8 @@ BinaryData IPersistableModel.Write(ModelReader { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryReplicationData)} does not support '{options.Format}' format."); } @@ -271,6 +448,8 @@ ContainerRegistryReplicationData IPersistableModel The provisioning state of the replication at the time the operation was called. + [WirePath("properties.provisioningState")] public ContainerRegistryProvisioningState? ProvisioningState { get; } /// The status of the replication at the time the operation was called. + [WirePath("properties.status")] public ContainerRegistryResourceStatus Status { get; } /// Specifies whether the replication's regional endpoint is enabled. Requests will not be routed to a replication whose regional endpoint is disabled, however its data will continue to be synced with other replications. + [WirePath("properties.regionEndpointEnabled")] public bool? IsRegionEndpointEnabled { get; set; } /// Whether or not zone redundancy is enabled for this container registry replication. + [WirePath("properties.zoneRedundancy")] public ContainerRegistryZoneRedundancy? ZoneRedundancy { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryRunData.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryRunData.Serialization.cs index 10ccc4ed13860..28cdb39c97573 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryRunData.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryRunData.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry.Models; using Azure.ResourceManager.Models; @@ -495,6 +498,464 @@ internal static ContainerRegistryRunData DeserializeContainerRegistryRunData(Jso serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RunId), out propertyOverride); + if (Optional.IsDefined(RunId) || hasPropertyOverride) + { + builder.Append(" runId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (RunId.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{RunId}'''"); + } + else + { + builder.AppendLine($"'{RunId}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); + if (Optional.IsDefined(Status) || hasPropertyOverride) + { + builder.Append(" status: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Status.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastUpdatedOn), out propertyOverride); + if (Optional.IsDefined(LastUpdatedOn) || hasPropertyOverride) + { + builder.Append(" lastUpdatedTime: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(LastUpdatedOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RunType), out propertyOverride); + if (Optional.IsDefined(RunType) || hasPropertyOverride) + { + builder.Append(" runType: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{RunType.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AgentPoolName), out propertyOverride); + if (Optional.IsDefined(AgentPoolName) || hasPropertyOverride) + { + builder.Append(" agentPoolName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (AgentPoolName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{AgentPoolName}'''"); + } + else + { + builder.AppendLine($"'{AgentPoolName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); + if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) + { + builder.Append(" createTime: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartOn), out propertyOverride); + if (Optional.IsDefined(StartOn) || hasPropertyOverride) + { + builder.Append(" startTime: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(StartOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FinishOn), out propertyOverride); + if (Optional.IsDefined(FinishOn) || hasPropertyOverride) + { + builder.Append(" finishTime: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(FinishOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(OutputImages), out propertyOverride); + if (Optional.IsCollectionDefined(OutputImages) || hasPropertyOverride) + { + if (OutputImages.Any() || hasPropertyOverride) + { + builder.Append(" outputImages: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in OutputImages) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 6, true, " outputImages: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Task), out propertyOverride); + if (Optional.IsDefined(Task) || hasPropertyOverride) + { + builder.Append(" task: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Task.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Task}'''"); + } + else + { + builder.AppendLine($"'{Task}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ImageUpdateTrigger), out propertyOverride); + if (Optional.IsDefined(ImageUpdateTrigger) || hasPropertyOverride) + { + builder.Append(" imageUpdateTrigger: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, ImageUpdateTrigger, options, 4, false, " imageUpdateTrigger: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SourceTrigger), out propertyOverride); + if (Optional.IsDefined(SourceTrigger) || hasPropertyOverride) + { + builder.Append(" sourceTrigger: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, SourceTrigger, options, 4, false, " sourceTrigger: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TimerTrigger), out propertyOverride); + if (Optional.IsDefined(TimerTrigger) || hasPropertyOverride) + { + builder.Append(" timerTrigger: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, TimerTrigger, options, 4, false, " timerTrigger: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Platform), out propertyOverride); + if (Optional.IsDefined(Platform) || hasPropertyOverride) + { + builder.Append(" platform: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, Platform, options, 4, false, " platform: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AgentConfiguration), out propertyOverride); + if (Optional.IsDefined(AgentConfiguration) || hasPropertyOverride) + { + builder.Append(" agentConfiguration: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, AgentConfiguration, options, 4, false, " agentConfiguration: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SourceRegistryAuth), out propertyOverride); + if (Optional.IsDefined(SourceRegistryAuth) || hasPropertyOverride) + { + builder.Append(" sourceRegistryAuth: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (SourceRegistryAuth.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{SourceRegistryAuth}'''"); + } + else + { + builder.AppendLine($"'{SourceRegistryAuth}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CustomRegistries), out propertyOverride); + if (Optional.IsCollectionDefined(CustomRegistries) || hasPropertyOverride) + { + if (CustomRegistries.Any() || hasPropertyOverride) + { + builder.Append(" customRegistries: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in CustomRegistries) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RunErrorMessage), out propertyOverride); + if (Optional.IsDefined(RunErrorMessage) || hasPropertyOverride) + { + builder.Append(" runErrorMessage: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (RunErrorMessage.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{RunErrorMessage}'''"); + } + else + { + builder.AppendLine($"'{RunErrorMessage}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(UpdateTriggerToken), out propertyOverride); + if (Optional.IsDefined(UpdateTriggerToken) || hasPropertyOverride) + { + builder.Append(" updateTriggerToken: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (UpdateTriggerToken.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{UpdateTriggerToken}'''"); + } + else + { + builder.AppendLine($"'{UpdateTriggerToken}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LogArtifact), out propertyOverride); + if (Optional.IsDefined(LogArtifact) || hasPropertyOverride) + { + builder.Append(" logArtifact: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, LogArtifact, options, 4, false, " logArtifact: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); + if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) + { + builder.Append(" provisioningState: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ProvisioningState.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsArchiveEnabled), out propertyOverride); + if (Optional.IsDefined(IsArchiveEnabled) || hasPropertyOverride) + { + builder.Append(" isArchiveEnabled: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsArchiveEnabled.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -503,6 +964,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOp { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryRunData)} does not support '{options.Format}' format."); } @@ -519,6 +982,8 @@ ContainerRegistryRunData IPersistableModel.Create(Bina using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerRegistryRunData(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerRegistryRunData)} does not support '{options.Format}' format."); } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryRunData.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryRunData.cs index a2b6ac66f16fc..0512362765342 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryRunData.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryRunData.cs @@ -114,36 +114,51 @@ internal ContainerRegistryRunData(ResourceIdentifier id, string name, ResourceTy } /// The unique identifier for the run. + [WirePath("properties.runId")] public string RunId { get; set; } /// The current status of the run. + [WirePath("properties.status")] public ContainerRegistryRunStatus? Status { get; set; } /// The last updated time for the run. + [WirePath("properties.lastUpdatedTime")] public DateTimeOffset? LastUpdatedOn { get; set; } /// The type of run. + [WirePath("properties.runType")] public ContainerRegistryRunType? RunType { get; set; } /// The dedicated agent pool for the run. + [WirePath("properties.agentPoolName")] public string AgentPoolName { get; set; } /// The time the run was scheduled. + [WirePath("properties.createTime")] public DateTimeOffset? CreatedOn { get; set; } /// The time the run started. + [WirePath("properties.startTime")] public DateTimeOffset? StartOn { get; set; } /// The time the run finished. + [WirePath("properties.finishTime")] public DateTimeOffset? FinishOn { get; set; } /// The list of all images that were generated from the run. This is applicable if the run generates base image dependencies. + [WirePath("properties.outputImages")] public IList OutputImages { get; } /// The task against which run was scheduled. + [WirePath("properties.task")] public string Task { get; set; } /// The image update trigger that caused the run. This is applicable if the task has base image trigger configured. + [WirePath("properties.imageUpdateTrigger")] public ContainerRegistryImageUpdateTrigger ImageUpdateTrigger { get; set; } /// The source trigger that caused the run. + [WirePath("properties.sourceTrigger")] public ContainerRegistrySourceTriggerDescriptor SourceTrigger { get; set; } /// The timer trigger that caused the run. + [WirePath("properties.timerTrigger")] public ContainerRegistryTimerTriggerDescriptor TimerTrigger { get; set; } /// The platform properties against which the run will happen. + [WirePath("properties.platform")] public ContainerRegistryPlatformProperties Platform { get; set; } /// The machine configuration of the run agent. internal ContainerRegistryAgentProperties AgentConfiguration { get; set; } /// The CPU configuration in terms of number of cores required for the run. + [WirePath("properties.agentConfiguration.cpu")] public int? AgentCpu { get => AgentConfiguration is null ? default : AgentConfiguration.Cpu; @@ -156,18 +171,25 @@ public int? AgentCpu } /// The scope of the credentials that were used to login to the source registry during this run. + [WirePath("properties.sourceRegistryAuth")] public string SourceRegistryAuth { get; set; } /// The list of custom registries that were logged in during this run. + [WirePath("properties.customRegistries")] public IList CustomRegistries { get; } /// The error message received from backend systems after the run is scheduled. + [WirePath("properties.runErrorMessage")] public string RunErrorMessage { get; } /// The update trigger token passed for the Run. + [WirePath("properties.updateTriggerToken")] public string UpdateTriggerToken { get; set; } /// The image description for the log artifact. + [WirePath("properties.logArtifact")] public ContainerRegistryImageDescriptor LogArtifact { get; } /// The provisioning state of a run. + [WirePath("properties.provisioningState")] public ContainerRegistryProvisioningState? ProvisioningState { get; set; } /// The value that indicates whether archiving is enabled or not. + [WirePath("properties.isArchiveEnabled")] public bool? IsArchiveEnabled { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryTaskData.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryTaskData.Serialization.cs index 5982ee15bf647..4c55a0f7fe7ab 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryTaskData.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryTaskData.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry.Models; using Azure.ResourceManager.Models; @@ -383,6 +386,321 @@ internal static ContainerRegistryTaskData DeserializeContainerRegistryTaskData(J serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); + builder.Append(" location: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Location.ToString()}'"); + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tags), out propertyOverride); + if (Optional.IsCollectionDefined(Tags) || hasPropertyOverride) + { + if (Tags.Any() || hasPropertyOverride) + { + builder.Append(" tags: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("{"); + foreach (var item in Tags) + { + builder.Append($" '{item.Key}': "); + if (item.Value == null) + { + builder.Append("null"); + continue; + } + if (item.Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{item.Value}'''"); + } + else + { + builder.AppendLine($"'{item.Value}'"); + } + } + builder.AppendLine(" }"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Identity), out propertyOverride); + if (Optional.IsDefined(Identity) || hasPropertyOverride) + { + builder.Append(" identity: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, Identity, options, 2, false, " identity: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); + if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) + { + builder.Append(" provisioningState: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ProvisioningState.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); + if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) + { + builder.Append(" creationDate: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); + if (Optional.IsDefined(Status) || hasPropertyOverride) + { + builder.Append(" status: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Status.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Platform), out propertyOverride); + if (Optional.IsDefined(Platform) || hasPropertyOverride) + { + builder.Append(" platform: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, Platform, options, 4, false, " platform: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AgentConfiguration), out propertyOverride); + if (Optional.IsDefined(AgentConfiguration) || hasPropertyOverride) + { + builder.Append(" agentConfiguration: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, AgentConfiguration, options, 4, false, " agentConfiguration: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AgentPoolName), out propertyOverride); + if (Optional.IsDefined(AgentPoolName) || hasPropertyOverride) + { + builder.Append(" agentPoolName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (AgentPoolName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{AgentPoolName}'''"); + } + else + { + builder.AppendLine($"'{AgentPoolName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TimeoutInSeconds), out propertyOverride); + if (Optional.IsDefined(TimeoutInSeconds) || hasPropertyOverride) + { + builder.Append(" timeout: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{TimeoutInSeconds.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Step), out propertyOverride); + if (Optional.IsDefined(Step) || hasPropertyOverride) + { + builder.Append(" step: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, Step, options, 4, false, " step: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Trigger), out propertyOverride); + if (Optional.IsDefined(Trigger) || hasPropertyOverride) + { + builder.Append(" trigger: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, Trigger, options, 4, false, " trigger: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Credentials), out propertyOverride); + if (Optional.IsDefined(Credentials) || hasPropertyOverride) + { + builder.Append(" credentials: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, Credentials, options, 4, false, " credentials: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LogTemplate), out propertyOverride); + if (Optional.IsDefined(LogTemplate) || hasPropertyOverride) + { + builder.Append(" logTemplate: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (LogTemplate.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{LogTemplate}'''"); + } + else + { + builder.AppendLine($"'{LogTemplate}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsSystemTask), out propertyOverride); + if (Optional.IsDefined(IsSystemTask) || hasPropertyOverride) + { + builder.Append(" isSystemTask: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsSystemTask.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -391,6 +709,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterO { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryTaskData)} does not support '{options.Format}' format."); } @@ -407,6 +727,8 @@ ContainerRegistryTaskData IPersistableModel.Create(Bi using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerRegistryTaskData(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerRegistryTaskData)} does not support '{options.Format}' format."); } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryTaskData.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryTaskData.cs index 43adb58d16525..6aebf27b67336 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryTaskData.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryTaskData.cs @@ -107,18 +107,24 @@ internal ContainerRegistryTaskData() } /// Identity for the resource. + [WirePath("identity")] public ManagedServiceIdentity Identity { get; set; } /// The provisioning state of the task. + [WirePath("properties.provisioningState")] public ContainerRegistryProvisioningState? ProvisioningState { get; } /// The creation date of task. + [WirePath("properties.creationDate")] public DateTimeOffset? CreatedOn { get; } /// The current status of task. + [WirePath("properties.status")] public ContainerRegistryTaskStatus? Status { get; set; } /// The platform properties against which the run has to happen. + [WirePath("properties.platform")] public ContainerRegistryPlatformProperties Platform { get; set; } /// The machine configuration of the run agent. internal ContainerRegistryAgentProperties AgentConfiguration { get; set; } /// The CPU configuration in terms of number of cores required for the run. + [WirePath("properties.agentConfiguration.cpu")] public int? AgentCpu { get => AgentConfiguration is null ? default : AgentConfiguration.Cpu; @@ -131,22 +137,29 @@ public int? AgentCpu } /// The dedicated agent pool for the task. + [WirePath("properties.agentPoolName")] public string AgentPoolName { get; set; } /// Run timeout in seconds. + [WirePath("properties.timeout")] public int? TimeoutInSeconds { get; set; } /// /// The properties of a task step. /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. /// The available derived classes include , and . /// + [WirePath("properties.step")] public ContainerRegistryTaskStepProperties Step { get; set; } /// The properties that describe all triggers for the task. + [WirePath("properties.trigger")] public ContainerRegistryTriggerProperties Trigger { get; set; } /// The properties that describes a set of credentials that will be used when this run is invoked. + [WirePath("properties.credentials")] public ContainerRegistryCredentials Credentials { get; set; } /// The template that describes the repository and tag information for run log artifact. + [WirePath("properties.logTemplate")] public string LogTemplate { get; set; } /// The value of this property indicates whether the task resource is system task or not. + [WirePath("properties.isSystemTask")] public bool? IsSystemTask { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryTaskRunData.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryTaskRunData.Serialization.cs index aaff6ce8a4076..4ea2f4991cd51 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryTaskRunData.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryTaskRunData.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry.Models; using Azure.ResourceManager.Models; @@ -239,6 +241,166 @@ internal static ContainerRegistryTaskRunData DeserializeContainerRegistryTaskRun serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); + if (Optional.IsDefined(Location) || hasPropertyOverride) + { + builder.Append(" location: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Location.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Identity), out propertyOverride); + if (Optional.IsDefined(Identity) || hasPropertyOverride) + { + builder.Append(" identity: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, Identity, options, 2, false, " identity: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); + if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) + { + builder.Append(" provisioningState: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ProvisioningState.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RunRequest), out propertyOverride); + if (Optional.IsDefined(RunRequest) || hasPropertyOverride) + { + builder.Append(" runRequest: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, RunRequest, options, 4, false, " runRequest: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RunResult), out propertyOverride); + if (Optional.IsDefined(RunResult) || hasPropertyOverride) + { + builder.Append(" runResult: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, RunResult, options, 4, false, " runResult: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ForceUpdateTag), out propertyOverride); + if (Optional.IsDefined(ForceUpdateTag) || hasPropertyOverride) + { + builder.Append(" forceUpdateTag: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ForceUpdateTag.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ForceUpdateTag}'''"); + } + else + { + builder.AppendLine($"'{ForceUpdateTag}'"); + } + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -247,6 +409,8 @@ BinaryData IPersistableModel.Write(ModelReaderWrit { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryTaskRunData)} does not support '{options.Format}' format."); } @@ -263,6 +427,8 @@ ContainerRegistryTaskRunData IPersistableModel.Cre using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerRegistryTaskRunData(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerRegistryTaskRunData)} does not support '{options.Format}' format."); } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryTaskRunData.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryTaskRunData.cs index 879f73217faf3..d948eb7ebebb7 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryTaskRunData.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryTaskRunData.cs @@ -85,20 +85,26 @@ internal ContainerRegistryTaskRunData(ResourceIdentifier id, string name, Resour } /// Identity for the resource. + [WirePath("identity")] public ManagedServiceIdentity Identity { get; set; } /// The location of the resource. + [WirePath("location")] public AzureLocation? Location { get; set; } /// The provisioning state of this task run. + [WirePath("properties.provisioningState")] public ContainerRegistryProvisioningState? ProvisioningState { get; } /// /// The request (parameters) for the run /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. /// The available derived classes include , , and . /// + [WirePath("properties.runRequest")] public ContainerRegistryRunContent RunRequest { get; set; } /// The result of this task run. + [WirePath("properties.runResult")] public ContainerRegistryRunData RunResult { get; } /// How the run should be forced to rerun even if the run request configuration has not changed. + [WirePath("properties.forceUpdateTag")] public string ForceUpdateTag { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryTokenData.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryTokenData.Serialization.cs index 7658fa715fed2..9671ab853d032 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryTokenData.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryTokenData.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry.Models; using Azure.ResourceManager.Models; @@ -227,6 +229,145 @@ internal static ContainerRegistryTokenData DeserializeContainerRegistryTokenData serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); + if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) + { + builder.Append(" creationDate: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); + if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) + { + builder.Append(" provisioningState: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ProvisioningState.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ScopeMapId), out propertyOverride); + if (Optional.IsDefined(ScopeMapId) || hasPropertyOverride) + { + builder.Append(" scopeMapId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ScopeMapId.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Credentials), out propertyOverride); + if (Optional.IsDefined(Credentials) || hasPropertyOverride) + { + builder.Append(" credentials: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, Credentials, options, 4, false, " credentials: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); + if (Optional.IsDefined(Status) || hasPropertyOverride) + { + builder.Append(" status: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Status.Value.ToString()}'"); + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -235,6 +376,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriter { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryTokenData)} does not support '{options.Format}' format."); } @@ -251,6 +394,8 @@ ContainerRegistryTokenData IPersistableModel.Create( using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerRegistryTokenData(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerRegistryTokenData)} does not support '{options.Format}' format."); } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryTokenData.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryTokenData.cs index a7a7e5f8ab11e..b73205780ad08 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryTokenData.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryTokenData.cs @@ -78,14 +78,19 @@ internal ContainerRegistryTokenData(ResourceIdentifier id, string name, Resource } /// The creation date of scope map. + [WirePath("properties.creationDate")] public DateTimeOffset? CreatedOn { get; } /// Provisioning state of the resource. + [WirePath("properties.provisioningState")] public ContainerRegistryProvisioningState? ProvisioningState { get; } /// The resource ID of the scope map to which the token will be associated with. + [WirePath("properties.scopeMapId")] public ResourceIdentifier ScopeMapId { get; set; } /// The credentials that can be used for authenticating the token. + [WirePath("properties.credentials")] public ContainerRegistryTokenCredentials Credentials { get; set; } /// The status of the token example enabled or disabled. + [WirePath("properties.status")] public ContainerRegistryTokenStatus? Status { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryWebhookData.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryWebhookData.Serialization.cs index b5f8c97599cdd..5ceebfda6a6c6 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryWebhookData.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryWebhookData.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry.Models; using Azure.ResourceManager.Models; @@ -253,6 +256,193 @@ internal static ContainerRegistryWebhookData DeserializeContainerRegistryWebhook serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); + builder.Append(" location: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Location.ToString()}'"); + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tags), out propertyOverride); + if (Optional.IsCollectionDefined(Tags) || hasPropertyOverride) + { + if (Tags.Any() || hasPropertyOverride) + { + builder.Append(" tags: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("{"); + foreach (var item in Tags) + { + builder.Append($" '{item.Key}': "); + if (item.Value == null) + { + builder.Append("null"); + continue; + } + if (item.Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{item.Value}'''"); + } + else + { + builder.AppendLine($"'{item.Value}'"); + } + } + builder.AppendLine(" }"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); + if (Optional.IsDefined(Status) || hasPropertyOverride) + { + builder.Append(" status: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Status.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Scope), out propertyOverride); + if (Optional.IsDefined(Scope) || hasPropertyOverride) + { + builder.Append(" scope: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Scope.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Scope}'''"); + } + else + { + builder.AppendLine($"'{Scope}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Actions), out propertyOverride); + if (Optional.IsCollectionDefined(Actions) || hasPropertyOverride) + { + if (Actions.Any() || hasPropertyOverride) + { + builder.Append(" actions: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Actions) + { + builder.AppendLine($" '{item.ToString()}'"); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); + if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) + { + builder.Append(" provisioningState: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ProvisioningState.Value.ToString()}'"); + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -261,6 +451,8 @@ BinaryData IPersistableModel.Write(ModelReaderWrit { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryWebhookData)} does not support '{options.Format}' format."); } @@ -277,6 +469,8 @@ ContainerRegistryWebhookData IPersistableModel.Cre using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerRegistryWebhookData(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerRegistryWebhookData)} does not support '{options.Format}' format."); } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryWebhookData.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryWebhookData.cs index cb3b19de8d8ae..ab8b18b18d827 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryWebhookData.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ContainerRegistryWebhookData.cs @@ -85,12 +85,16 @@ internal ContainerRegistryWebhookData() } /// The status of the webhook at the time the operation was called. + [WirePath("properties.status")] public ContainerRegistryWebhookStatus? Status { get; set; } /// The scope of repositories where the event can be triggered. For example, 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' only. 'foo' is equivalent to 'foo:latest'. Empty means all events. + [WirePath("properties.scope")] public string Scope { get; set; } /// The list of actions that trigger the webhook to post notifications. + [WirePath("properties.actions")] public IList Actions { get; } /// The provisioning state of the webhook at the time the operation was called. + [WirePath("properties.provisioningState")] public ContainerRegistryProvisioningState? ProvisioningState { get; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Internal/BicepSerializationHelpers.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Internal/BicepSerializationHelpers.cs new file mode 100644 index 0000000000000..c639947ac6f79 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Internal/BicepSerializationHelpers.cs @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text; + +namespace Azure.ResourceManager.ContainerRegistry +{ + internal static class BicepSerializationHelpers + { + public static void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Internal/ChangeTrackingDictionary.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Internal/ChangeTrackingDictionary.cs new file mode 100644 index 0000000000000..c38caa8fba2d4 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/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.ContainerRegistry +{ + 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/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Internal/Optional.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Internal/Optional.cs index ebd5803051ae7..b87e7ac95d42d 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Internal/Optional.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Internal/Optional.cs @@ -7,7 +7,6 @@ using System.Collections.Generic; using System.Text.Json; -using Azure.Core; namespace Azure.ResourceManager.ContainerRegistry { diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Internal/Utf8JsonRequestContent.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Internal/Utf8JsonRequestContent.cs new file mode 100644 index 0000000000000..614bc1a91a54c --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/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.ContainerRegistry +{ + 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/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Internal/WirePathAttribute.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Internal/WirePathAttribute.cs new file mode 100644 index 0000000000000..eacd59e0c7022 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Internal/WirePathAttribute.cs @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.ContainerRegistry +{ + [AttributeUsage(AttributeTargets.Property)] + internal class WirePathAttribute : Attribute + { + private string _wirePath; + + public WirePathAttribute(string wirePath) + { + _wirePath = wirePath; + } + + public override string ToString() + { + return _wirePath; + } + } +} diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryAgentPoolListResult.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryAgentPoolListResult.Serialization.cs index db3b73fbec550..99040eee98dd9 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryAgentPoolListResult.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryAgentPoolListResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -114,6 +117,65 @@ internal static ContainerRegistryAgentPoolListResult DeserializeContainerRegistr return new ContainerRegistryAgentPoolListResult(value ?? new ChangeTrackingList(), nextLink, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (Optional.IsDefined(NextLink) || hasPropertyOverride) + { + builder.Append(" nextLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -122,6 +184,8 @@ BinaryData IPersistableModel.Write(ModelRe { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryAgentPoolListResult)} does not support '{options.Format}' format."); } @@ -138,6 +202,8 @@ ContainerRegistryAgentPoolListResult IPersistableModel tags, int? } /// The ARM resource tags. + [WirePath("tags")] public IDictionary Tags { get; } /// The count of agent machine. + [WirePath("properties.count")] public int? Count { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryAgentPoolQueueStatus.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryAgentPoolQueueStatus.Serialization.cs index c492c55e911ae..0f6fd378de6ca 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryAgentPoolQueueStatus.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryAgentPoolQueueStatus.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -93,6 +95,35 @@ internal static ContainerRegistryAgentPoolQueueStatus DeserializeContainerRegist return new ContainerRegistryAgentPoolQueueStatus(count, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Count), out propertyOverride); + if (Optional.IsDefined(Count) || hasPropertyOverride) + { + builder.Append(" count: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{Count.Value}"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -101,6 +132,8 @@ BinaryData IPersistableModel.Write(ModelR { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryAgentPoolQueueStatus)} does not support '{options.Format}' format."); } @@ -117,6 +150,8 @@ ContainerRegistryAgentPoolQueueStatus IPersistableModel The number of pending runs in the queue. + [WirePath("count")] public int? Count { get; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryAgentProperties.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryAgentProperties.Serialization.cs index 5b9cb03304c9d..33e4fc80d1b68 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryAgentProperties.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryAgentProperties.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -93,6 +95,35 @@ internal static ContainerRegistryAgentProperties DeserializeContainerRegistryAge return new ContainerRegistryAgentProperties(cpu, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Cpu), out propertyOverride); + if (Optional.IsDefined(Cpu) || hasPropertyOverride) + { + builder.Append(" cpu: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{Cpu.Value}"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -101,6 +132,8 @@ BinaryData IPersistableModel.Write(ModelReader { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryAgentProperties)} does not support '{options.Format}' format."); } @@ -117,6 +150,8 @@ ContainerRegistryAgentProperties IPersistableModel The CPU configuration in terms of number of cores required for the run. + [WirePath("cpu")] public int? Cpu { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryBaseImageDependency.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryBaseImageDependency.Serialization.cs index 652eba50f2403..05e365fe2a8c3 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryBaseImageDependency.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryBaseImageDependency.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -143,6 +145,123 @@ internal static ContainerRegistryBaseImageDependency DeserializeContainerRegistr serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DependencyType), out propertyOverride); + if (Optional.IsDefined(DependencyType) || hasPropertyOverride) + { + builder.Append(" type: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{DependencyType.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Registry), out propertyOverride); + if (Optional.IsDefined(Registry) || hasPropertyOverride) + { + builder.Append(" registry: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Registry.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Registry}'''"); + } + else + { + builder.AppendLine($"'{Registry}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Repository), out propertyOverride); + if (Optional.IsDefined(Repository) || hasPropertyOverride) + { + builder.Append(" repository: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Repository.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Repository}'''"); + } + else + { + builder.AppendLine($"'{Repository}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tag), out propertyOverride); + if (Optional.IsDefined(Tag) || hasPropertyOverride) + { + builder.Append(" tag: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Tag.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Tag}'''"); + } + else + { + builder.AppendLine($"'{Tag}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Digest), out propertyOverride); + if (Optional.IsDefined(Digest) || hasPropertyOverride) + { + builder.Append(" digest: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Digest.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Digest}'''"); + } + else + { + builder.AppendLine($"'{Digest}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -151,6 +270,8 @@ BinaryData IPersistableModel.Write(ModelRe { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryBaseImageDependency)} does not support '{options.Format}' format."); } @@ -167,6 +288,8 @@ ContainerRegistryBaseImageDependency IPersistableModel The type of the base image dependency. + [WirePath("type")] public ContainerRegistryBaseImageDependencyType? DependencyType { get; } /// The registry login server. + [WirePath("registry")] public string Registry { get; } /// The repository name. + [WirePath("repository")] public string Repository { get; } /// The tag name. + [WirePath("tag")] public string Tag { get; } /// The sha256-based digest of the image manifest. + [WirePath("digest")] public string Digest { get; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryBaseImageTrigger.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryBaseImageTrigger.Serialization.cs index 92cd84d0ddf1b..fe693c403aa7a 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryBaseImageTrigger.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryBaseImageTrigger.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -141,6 +143,104 @@ internal static ContainerRegistryBaseImageTrigger DeserializeContainerRegistryBa serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BaseImageTriggerType), out propertyOverride); + builder.Append(" baseImageTriggerType: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{BaseImageTriggerType.ToString()}'"); + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(UpdateTriggerEndpoint), out propertyOverride); + if (Optional.IsDefined(UpdateTriggerEndpoint) || hasPropertyOverride) + { + builder.Append(" updateTriggerEndpoint: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (UpdateTriggerEndpoint.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{UpdateTriggerEndpoint}'''"); + } + else + { + builder.AppendLine($"'{UpdateTriggerEndpoint}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(UpdateTriggerPayloadType), out propertyOverride); + if (Optional.IsDefined(UpdateTriggerPayloadType) || hasPropertyOverride) + { + builder.Append(" updateTriggerPayloadType: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{UpdateTriggerPayloadType.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); + if (Optional.IsDefined(Status) || hasPropertyOverride) + { + builder.Append(" status: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Status.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -149,6 +249,8 @@ BinaryData IPersistableModel.Write(ModelReade { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryBaseImageTrigger)} does not support '{options.Format}' format."); } @@ -165,6 +267,8 @@ ContainerRegistryBaseImageTrigger IPersistableModel The type of the auto trigger for base image dependency updates. + [WirePath("baseImageTriggerType")] public ContainerRegistryBaseImageTriggerType BaseImageTriggerType { get; set; } /// The endpoint URL for receiving update triggers. + [WirePath("updateTriggerEndpoint")] public string UpdateTriggerEndpoint { get; set; } /// Type of Payload body for Base image update triggers. + [WirePath("updateTriggerPayloadType")] public ContainerRegistryUpdateTriggerPayloadType? UpdateTriggerPayloadType { get; set; } /// The current status of trigger. + [WirePath("status")] public ContainerRegistryTriggerStatus? Status { get; set; } /// The name of the trigger. + [WirePath("name")] public string Name { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryBaseImageTriggerUpdateContent.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryBaseImageTriggerUpdateContent.cs index 5762bb9792d9c..917e59f4b9c6d 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryBaseImageTriggerUpdateContent.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryBaseImageTriggerUpdateContent.cs @@ -79,14 +79,19 @@ internal ContainerRegistryBaseImageTriggerUpdateContent() } /// The type of the auto trigger for base image dependency updates. + [WirePath("baseImageTriggerType")] public ContainerRegistryBaseImageTriggerType? BaseImageTriggerType { get; set; } /// The endpoint URL for receiving update triggers. + [WirePath("updateTriggerEndpoint")] public string UpdateTriggerEndpoint { get; set; } /// Type of Payload body for Base image update triggers. + [WirePath("updateTriggerPayloadType")] public ContainerRegistryUpdateTriggerPayloadType? UpdateTriggerPayloadType { get; set; } /// The current status of trigger. + [WirePath("status")] public ContainerRegistryTriggerStatus? Status { get; set; } /// The name of the trigger. + [WirePath("name")] public string Name { get; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryCredentialRegenerateContent.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryCredentialRegenerateContent.cs index 54acf4e5283e7..b31768e3cfea1 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryCredentialRegenerateContent.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryCredentialRegenerateContent.cs @@ -67,6 +67,7 @@ internal ContainerRegistryCredentialRegenerateContent() } /// Specifies name of the password which should be regenerated -- password or password2. + [WirePath("name")] public ContainerRegistryPasswordName Name { get; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryCredentials.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryCredentials.Serialization.cs index 468fb7df6f0d1..cac1ba6b39ec5 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryCredentials.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryCredentials.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -119,6 +122,58 @@ internal static ContainerRegistryCredentials DeserializeContainerRegistryCredent return new ContainerRegistryCredentials(sourceRegistry, customRegistries ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SourceRegistry), out propertyOverride); + if (Optional.IsDefined(SourceRegistry) || hasPropertyOverride) + { + builder.Append(" sourceRegistry: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, SourceRegistry, options, 2, false, " sourceRegistry: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CustomRegistries), out propertyOverride); + if (Optional.IsCollectionDefined(CustomRegistries) || hasPropertyOverride) + { + if (CustomRegistries.Any() || hasPropertyOverride) + { + builder.Append(" customRegistries: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("{"); + foreach (var item in CustomRegistries) + { + builder.Append($" '{item.Key}': "); + BicepSerializationHelpers.AppendChildObject(builder, item.Value, options, 4, false, " customRegistries: "); + } + builder.AppendLine(" }"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -127,6 +182,8 @@ BinaryData IPersistableModel.Write(ModelReaderWrit { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryCredentials)} does not support '{options.Format}' format."); } @@ -143,6 +200,8 @@ ContainerRegistryCredentials IPersistableModel.Cre using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerRegistryCredentials(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerRegistryCredentials)} does not support '{options.Format}' format."); } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryCredentials.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryCredentials.cs index 8093c97bdc454..e7b50a388b90e 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryCredentials.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryCredentials.cs @@ -7,7 +7,7 @@ using System; using System.Collections.Generic; -using Azure.Core; +using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models { @@ -74,6 +74,7 @@ internal ContainerRegistryCredentials(SourceRegistryCredentials sourceRegistry, /// will be generated using the given scope. These credentials will be used to login to /// the source registry during the run. /// + [WirePath("sourceRegistry.loginMode")] public SourceRegistryLoginMode? SourceRegistryLoginMode { get => SourceRegistry is null ? default : SourceRegistry.LoginMode; @@ -90,6 +91,7 @@ public SourceRegistryLoginMode? SourceRegistryLoginMode /// for the dictionary item will be the registry login server (myregistry.azurecr.io) and /// the value of the item will be the registry credentials for accessing the registry. /// + [WirePath("customRegistries")] public IDictionary CustomRegistries { get; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryDockerBuildContent.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryDockerBuildContent.Serialization.cs index 615c4a2192be4..6ca0cfc40c3d3 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryDockerBuildContent.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryDockerBuildContent.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -302,6 +305,311 @@ internal static ContainerRegistryDockerBuildContent DeserializeContainerRegistry credentials); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ImageNames), out propertyOverride); + if (Optional.IsCollectionDefined(ImageNames) || hasPropertyOverride) + { + if (ImageNames.Any() || hasPropertyOverride) + { + builder.Append(" imageNames: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in ImageNames) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsPushEnabled), out propertyOverride); + if (Optional.IsDefined(IsPushEnabled) || hasPropertyOverride) + { + builder.Append(" isPushEnabled: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsPushEnabled.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NoCache), out propertyOverride); + if (Optional.IsDefined(NoCache) || hasPropertyOverride) + { + builder.Append(" noCache: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = NoCache.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DockerFilePath), out propertyOverride); + if (Optional.IsDefined(DockerFilePath) || hasPropertyOverride) + { + builder.Append(" dockerFilePath: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (DockerFilePath.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{DockerFilePath}'''"); + } + else + { + builder.AppendLine($"'{DockerFilePath}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Target), out propertyOverride); + if (Optional.IsDefined(Target) || hasPropertyOverride) + { + builder.Append(" target: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Target.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Target}'''"); + } + else + { + builder.AppendLine($"'{Target}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Arguments), out propertyOverride); + if (Optional.IsCollectionDefined(Arguments) || hasPropertyOverride) + { + if (Arguments.Any() || hasPropertyOverride) + { + builder.Append(" arguments: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Arguments) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " arguments: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TimeoutInSeconds), out propertyOverride); + if (Optional.IsDefined(TimeoutInSeconds) || hasPropertyOverride) + { + builder.Append(" timeout: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{TimeoutInSeconds.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Platform), out propertyOverride); + if (Optional.IsDefined(Platform) || hasPropertyOverride) + { + builder.Append(" platform: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, Platform, options, 2, false, " platform: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AgentConfiguration), out propertyOverride); + if (Optional.IsDefined(AgentConfiguration) || hasPropertyOverride) + { + builder.Append(" agentConfiguration: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, AgentConfiguration, options, 2, false, " agentConfiguration: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SourceLocation), out propertyOverride); + if (Optional.IsDefined(SourceLocation) || hasPropertyOverride) + { + builder.Append(" sourceLocation: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (SourceLocation.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{SourceLocation}'''"); + } + else + { + builder.AppendLine($"'{SourceLocation}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Credentials), out propertyOverride); + if (Optional.IsDefined(Credentials) || hasPropertyOverride) + { + builder.Append(" credentials: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, Credentials, options, 2, false, " credentials: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RunRequestType), out propertyOverride); + if (Optional.IsDefined(RunRequestType) || hasPropertyOverride) + { + builder.Append(" type: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (RunRequestType.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{RunRequestType}'''"); + } + else + { + builder.AppendLine($"'{RunRequestType}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsArchiveEnabled), out propertyOverride); + if (Optional.IsDefined(IsArchiveEnabled) || hasPropertyOverride) + { + builder.Append(" isArchiveEnabled: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsArchiveEnabled.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AgentPoolName), out propertyOverride); + if (Optional.IsDefined(AgentPoolName) || hasPropertyOverride) + { + builder.Append(" agentPoolName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (AgentPoolName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{AgentPoolName}'''"); + } + else + { + builder.AppendLine($"'{AgentPoolName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LogTemplate), out propertyOverride); + if (Optional.IsDefined(LogTemplate) || hasPropertyOverride) + { + builder.Append(" logTemplate: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (LogTemplate.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{LogTemplate}'''"); + } + else + { + builder.AppendLine($"'{LogTemplate}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -310,6 +618,8 @@ BinaryData IPersistableModel.Write(ModelRea { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryDockerBuildContent)} does not support '{options.Format}' format."); } @@ -326,6 +636,8 @@ ContainerRegistryDockerBuildContent IPersistableModel The fully qualified image names including the repository and tag. + [WirePath("imageNames")] public IList ImageNames { get; } /// The value of this property indicates whether the image built should be pushed to the registry or not. + [WirePath("isPushEnabled")] public bool? IsPushEnabled { get; set; } /// The value of this property indicates whether the image cache is enabled or not. + [WirePath("noCache")] public bool? NoCache { get; set; } /// The Docker file path relative to the source location. + [WirePath("dockerFilePath")] public string DockerFilePath { get; set; } /// The name of the target build stage for the docker build. + [WirePath("target")] public string Target { get; set; } /// The collection of override arguments to be used when executing the run. + [WirePath("arguments")] public IList Arguments { get; } /// Run timeout in seconds. + [WirePath("timeout")] public int? TimeoutInSeconds { get; set; } /// The platform properties against which the run has to happen. + [WirePath("platform")] public ContainerRegistryPlatformProperties Platform { get; set; } /// The machine configuration of the run agent. internal ContainerRegistryAgentProperties AgentConfiguration { get; set; } /// The CPU configuration in terms of number of cores required for the run. + [WirePath("agentConfiguration.cpu")] public int? AgentCpu { get => AgentConfiguration is null ? default : AgentConfiguration.Cpu; @@ -105,8 +114,10 @@ public int? AgentCpu /// The URL(absolute or relative) of the source context. It can be an URL to a tar or git repository. /// If it is relative URL, the relative path should be obtained from calling listBuildSourceUploadUrl API. /// + [WirePath("sourceLocation")] public string SourceLocation { get; set; } /// The properties that describes a set of credentials that will be used when this run is invoked. + [WirePath("credentials")] public ContainerRegistryCredentials Credentials { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryDockerBuildStep.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryDockerBuildStep.Serialization.cs index 8e11eb0c38104..0f1eb8f8355b1 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryDockerBuildStep.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryDockerBuildStep.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -243,6 +246,229 @@ internal static ContainerRegistryDockerBuildStep DeserializeContainerRegistryDoc arguments ?? new ChangeTrackingList()); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ImageNames), out propertyOverride); + if (Optional.IsCollectionDefined(ImageNames) || hasPropertyOverride) + { + if (ImageNames.Any() || hasPropertyOverride) + { + builder.Append(" imageNames: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in ImageNames) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsPushEnabled), out propertyOverride); + if (Optional.IsDefined(IsPushEnabled) || hasPropertyOverride) + { + builder.Append(" isPushEnabled: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsPushEnabled.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NoCache), out propertyOverride); + if (Optional.IsDefined(NoCache) || hasPropertyOverride) + { + builder.Append(" noCache: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = NoCache.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DockerFilePath), out propertyOverride); + if (Optional.IsDefined(DockerFilePath) || hasPropertyOverride) + { + builder.Append(" dockerFilePath: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (DockerFilePath.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{DockerFilePath}'''"); + } + else + { + builder.AppendLine($"'{DockerFilePath}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Target), out propertyOverride); + if (Optional.IsDefined(Target) || hasPropertyOverride) + { + builder.Append(" target: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Target.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Target}'''"); + } + else + { + builder.AppendLine($"'{Target}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Arguments), out propertyOverride); + if (Optional.IsCollectionDefined(Arguments) || hasPropertyOverride) + { + if (Arguments.Any() || hasPropertyOverride) + { + builder.Append(" arguments: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Arguments) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " arguments: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ContainerRegistryTaskStepType), out propertyOverride); + builder.Append(" type: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ContainerRegistryTaskStepType.ToString()}'"); + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BaseImageDependencies), out propertyOverride); + if (Optional.IsCollectionDefined(BaseImageDependencies) || hasPropertyOverride) + { + if (BaseImageDependencies.Any() || hasPropertyOverride) + { + builder.Append(" baseImageDependencies: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in BaseImageDependencies) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " baseImageDependencies: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ContextPath), out propertyOverride); + if (Optional.IsDefined(ContextPath) || hasPropertyOverride) + { + builder.Append(" contextPath: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ContextPath.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ContextPath}'''"); + } + else + { + builder.AppendLine($"'{ContextPath}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ContextAccessToken), out propertyOverride); + if (Optional.IsDefined(ContextAccessToken) || hasPropertyOverride) + { + builder.Append(" contextAccessToken: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ContextAccessToken.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ContextAccessToken}'''"); + } + else + { + builder.AppendLine($"'{ContextAccessToken}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -251,6 +477,8 @@ BinaryData IPersistableModel.Write(ModelReader { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryDockerBuildStep)} does not support '{options.Format}' format."); } @@ -267,6 +495,8 @@ ContainerRegistryDockerBuildStep IPersistableModel The fully qualified image names including the repository and tag. + [WirePath("imageNames")] public IList ImageNames { get; } /// The value of this property indicates whether the image built should be pushed to the registry or not. + [WirePath("isPushEnabled")] public bool? IsPushEnabled { get; set; } /// The value of this property indicates whether the image cache is enabled or not. + [WirePath("noCache")] public bool? NoCache { get; set; } /// The Docker file path relative to the source context. + [WirePath("dockerFilePath")] public string DockerFilePath { get; set; } /// The name of the target build stage for the docker build. + [WirePath("target")] public string Target { get; set; } /// The collection of override arguments to be used when executing this build step. + [WirePath("arguments")] public IList Arguments { get; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryDockerBuildStepUpdateContent.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryDockerBuildStepUpdateContent.cs index b6599fc5aa6b9..42554bde2f0ab 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryDockerBuildStepUpdateContent.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryDockerBuildStepUpdateContent.cs @@ -45,16 +45,22 @@ internal ContainerRegistryDockerBuildStepUpdateContent(ContainerRegistryTaskStep } /// The fully qualified image names including the repository and tag. + [WirePath("imageNames")] public IList ImageNames { get; } /// The value of this property indicates whether the image built should be pushed to the registry or not. + [WirePath("isPushEnabled")] public bool? IsPushEnabled { get; set; } /// The value of this property indicates whether the image cache is enabled or not. + [WirePath("noCache")] public bool? NoCache { get; set; } /// The Docker file path relative to the source context. + [WirePath("dockerFilePath")] public string DockerFilePath { get; set; } /// The collection of override arguments to be used when executing this build step. + [WirePath("arguments")] public IList Arguments { get; } /// The name of the target build stage for the docker build. + [WirePath("target")] public string Target { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryEncodedTaskRunContent.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryEncodedTaskRunContent.Serialization.cs index 6d80d5b628b43..8ce1d7b1e0125 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryEncodedTaskRunContent.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryEncodedTaskRunContent.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -244,6 +247,246 @@ internal static ContainerRegistryEncodedTaskRunContent DeserializeContainerRegis credentials); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EncodedTaskContent), out propertyOverride); + if (Optional.IsDefined(EncodedTaskContent) || hasPropertyOverride) + { + builder.Append(" encodedTaskContent: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (EncodedTaskContent.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{EncodedTaskContent}'''"); + } + else + { + builder.AppendLine($"'{EncodedTaskContent}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EncodedValuesContent), out propertyOverride); + if (Optional.IsDefined(EncodedValuesContent) || hasPropertyOverride) + { + builder.Append(" encodedValuesContent: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (EncodedValuesContent.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{EncodedValuesContent}'''"); + } + else + { + builder.AppendLine($"'{EncodedValuesContent}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Values), out propertyOverride); + if (Optional.IsCollectionDefined(Values) || hasPropertyOverride) + { + if (Values.Any() || hasPropertyOverride) + { + builder.Append(" values: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Values) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " values: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TimeoutInSeconds), out propertyOverride); + if (Optional.IsDefined(TimeoutInSeconds) || hasPropertyOverride) + { + builder.Append(" timeout: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{TimeoutInSeconds.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Platform), out propertyOverride); + if (Optional.IsDefined(Platform) || hasPropertyOverride) + { + builder.Append(" platform: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, Platform, options, 2, false, " platform: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AgentConfiguration), out propertyOverride); + if (Optional.IsDefined(AgentConfiguration) || hasPropertyOverride) + { + builder.Append(" agentConfiguration: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, AgentConfiguration, options, 2, false, " agentConfiguration: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SourceLocation), out propertyOverride); + if (Optional.IsDefined(SourceLocation) || hasPropertyOverride) + { + builder.Append(" sourceLocation: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (SourceLocation.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{SourceLocation}'''"); + } + else + { + builder.AppendLine($"'{SourceLocation}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Credentials), out propertyOverride); + if (Optional.IsDefined(Credentials) || hasPropertyOverride) + { + builder.Append(" credentials: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, Credentials, options, 2, false, " credentials: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RunRequestType), out propertyOverride); + if (Optional.IsDefined(RunRequestType) || hasPropertyOverride) + { + builder.Append(" type: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (RunRequestType.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{RunRequestType}'''"); + } + else + { + builder.AppendLine($"'{RunRequestType}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsArchiveEnabled), out propertyOverride); + if (Optional.IsDefined(IsArchiveEnabled) || hasPropertyOverride) + { + builder.Append(" isArchiveEnabled: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsArchiveEnabled.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AgentPoolName), out propertyOverride); + if (Optional.IsDefined(AgentPoolName) || hasPropertyOverride) + { + builder.Append(" agentPoolName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (AgentPoolName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{AgentPoolName}'''"); + } + else + { + builder.AppendLine($"'{AgentPoolName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LogTemplate), out propertyOverride); + if (Optional.IsDefined(LogTemplate) || hasPropertyOverride) + { + builder.Append(" logTemplate: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (LogTemplate.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{LogTemplate}'''"); + } + else + { + builder.AppendLine($"'{LogTemplate}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -252,6 +495,8 @@ BinaryData IPersistableModel.Write(Model { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryEncodedTaskRunContent)} does not support '{options.Format}' format."); } @@ -268,6 +513,8 @@ ContainerRegistryEncodedTaskRunContent IPersistableModel Base64 encoded value of the template/definition file content. + [WirePath("encodedTaskContent")] public string EncodedTaskContent { get; set; } /// Base64 encoded value of the parameters/values file content. + [WirePath("encodedValuesContent")] public string EncodedValuesContent { get; set; } /// The collection of overridable values that can be passed when running a task. + [WirePath("values")] public IList Values { get; } /// Run timeout in seconds. + [WirePath("timeout")] public int? TimeoutInSeconds { get; set; } /// The platform properties against which the run has to happen. + [WirePath("platform")] public ContainerRegistryPlatformProperties Platform { get; set; } /// The machine configuration of the run agent. internal ContainerRegistryAgentProperties AgentConfiguration { get; set; } /// The CPU configuration in terms of number of cores required for the run. + [WirePath("agentConfiguration.cpu")] public int? AgentCpu { get => AgentConfiguration is null ? default : AgentConfiguration.Cpu; @@ -92,8 +98,10 @@ public int? AgentCpu /// The URL(absolute or relative) of the source context. It can be an URL to a tar or git repository. /// If it is relative URL, the relative path should be obtained from calling listBuildSourceUploadUrl API. /// + [WirePath("sourceLocation")] public string SourceLocation { get; set; } /// The properties that describes a set of credentials that will be used when this run is invoked. + [WirePath("credentials")] public ContainerRegistryCredentials Credentials { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryEncodedTaskStep.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryEncodedTaskStep.Serialization.cs index f5703a929d61a..2de58ce8f801b 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryEncodedTaskStep.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryEncodedTaskStep.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -185,6 +188,164 @@ internal static ContainerRegistryEncodedTaskStep DeserializeContainerRegistryEnc values ?? new ChangeTrackingList()); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EncodedTaskContent), out propertyOverride); + if (Optional.IsDefined(EncodedTaskContent) || hasPropertyOverride) + { + builder.Append(" encodedTaskContent: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (EncodedTaskContent.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{EncodedTaskContent}'''"); + } + else + { + builder.AppendLine($"'{EncodedTaskContent}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EncodedValuesContent), out propertyOverride); + if (Optional.IsDefined(EncodedValuesContent) || hasPropertyOverride) + { + builder.Append(" encodedValuesContent: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (EncodedValuesContent.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{EncodedValuesContent}'''"); + } + else + { + builder.AppendLine($"'{EncodedValuesContent}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Values), out propertyOverride); + if (Optional.IsCollectionDefined(Values) || hasPropertyOverride) + { + if (Values.Any() || hasPropertyOverride) + { + builder.Append(" values: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Values) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " values: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ContainerRegistryTaskStepType), out propertyOverride); + builder.Append(" type: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ContainerRegistryTaskStepType.ToString()}'"); + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BaseImageDependencies), out propertyOverride); + if (Optional.IsCollectionDefined(BaseImageDependencies) || hasPropertyOverride) + { + if (BaseImageDependencies.Any() || hasPropertyOverride) + { + builder.Append(" baseImageDependencies: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in BaseImageDependencies) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " baseImageDependencies: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ContextPath), out propertyOverride); + if (Optional.IsDefined(ContextPath) || hasPropertyOverride) + { + builder.Append(" contextPath: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ContextPath.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ContextPath}'''"); + } + else + { + builder.AppendLine($"'{ContextPath}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ContextAccessToken), out propertyOverride); + if (Optional.IsDefined(ContextAccessToken) || hasPropertyOverride) + { + builder.Append(" contextAccessToken: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ContextAccessToken.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ContextAccessToken}'''"); + } + else + { + builder.AppendLine($"'{ContextAccessToken}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -193,6 +354,8 @@ BinaryData IPersistableModel.Write(ModelReader { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryEncodedTaskStep)} does not support '{options.Format}' format."); } @@ -209,6 +372,8 @@ ContainerRegistryEncodedTaskStep IPersistableModel Base64 encoded value of the template/definition file content. + [WirePath("encodedTaskContent")] public string EncodedTaskContent { get; set; } /// Base64 encoded value of the parameters/values file content. + [WirePath("encodedValuesContent")] public string EncodedValuesContent { get; set; } /// The collection of overridable values that can be passed when running a task. + [WirePath("values")] public IList Values { get; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryEncodedTaskStepUpdateContent.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryEncodedTaskStepUpdateContent.cs index b0eb061f83e94..e6c37a61fc041 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryEncodedTaskStepUpdateContent.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryEncodedTaskStepUpdateContent.cs @@ -38,10 +38,13 @@ internal ContainerRegistryEncodedTaskStepUpdateContent(ContainerRegistryTaskStep } /// Base64 encoded value of the template/definition file content. + [WirePath("encodedTaskContent")] public string EncodedTaskContent { get; set; } /// Base64 encoded value of the parameters/values file content. + [WirePath("encodedValuesContent")] public string EncodedValuesContent { get; set; } /// The collection of overridable values that can be passed when running a task. + [WirePath("values")] public IList Values { get; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryEncryption.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryEncryption.Serialization.cs index 59fa073942c48..76552dbe04b58 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryEncryption.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryEncryption.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -108,6 +110,49 @@ internal static ContainerRegistryEncryption DeserializeContainerRegistryEncrypti return new ContainerRegistryEncryption(status, keyVaultProperties, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); + if (Optional.IsDefined(Status) || hasPropertyOverride) + { + builder.Append(" status: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Status.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyVaultProperties), out propertyOverride); + if (Optional.IsDefined(KeyVaultProperties) || hasPropertyOverride) + { + builder.Append(" keyVaultProperties: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, KeyVaultProperties, options, 2, false, " keyVaultProperties: "); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -116,6 +161,8 @@ BinaryData IPersistableModel.Write(ModelReaderWrite { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryEncryption)} does not support '{options.Format}' format."); } @@ -132,6 +179,8 @@ ContainerRegistryEncryption IPersistableModel.Creat using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerRegistryEncryption(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerRegistryEncryption)} does not support '{options.Format}' format."); } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryEncryption.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryEncryption.cs index ef4db11be58f8..54993f444342a 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryEncryption.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryEncryption.cs @@ -62,8 +62,10 @@ internal ContainerRegistryEncryption(ContainerRegistryEncryptionStatus? status, } /// Indicates whether or not the encryption is enabled for container registry. + [WirePath("status")] public ContainerRegistryEncryptionStatus? Status { get; set; } /// Key vault properties. + [WirePath("keyVaultProperties")] public ContainerRegistryKeyVaultProperties KeyVaultProperties { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryExportPolicy.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryExportPolicy.Serialization.cs index 77f577f8062f1..53e5b38a688d8 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryExportPolicy.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryExportPolicy.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -93,6 +95,35 @@ internal static ContainerRegistryExportPolicy DeserializeContainerRegistryExport return new ContainerRegistryExportPolicy(status, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); + if (Optional.IsDefined(Status) || hasPropertyOverride) + { + builder.Append(" status: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Status.Value.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -101,6 +132,8 @@ BinaryData IPersistableModel.Write(ModelReaderWri { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryExportPolicy)} does not support '{options.Format}' format."); } @@ -117,6 +150,8 @@ ContainerRegistryExportPolicy IPersistableModel.C using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerRegistryExportPolicy(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerRegistryExportPolicy)} does not support '{options.Format}' format."); } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryExportPolicy.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryExportPolicy.cs index d005ca0a7db31..c271823dc0675 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryExportPolicy.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryExportPolicy.cs @@ -60,6 +60,7 @@ internal ContainerRegistryExportPolicy(ContainerRegistryExportPolicyStatus? stat } /// The value that indicates whether the policy is enabled or not. + [WirePath("status")] public ContainerRegistryExportPolicyStatus? Status { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryFileTaskRunContent.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryFileTaskRunContent.Serialization.cs index 5f37bc3f4b9e8..3b11ee7d00046 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryFileTaskRunContent.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryFileTaskRunContent.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -244,6 +247,246 @@ internal static ContainerRegistryFileTaskRunContent DeserializeContainerRegistry credentials); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TaskFilePath), out propertyOverride); + if (Optional.IsDefined(TaskFilePath) || hasPropertyOverride) + { + builder.Append(" taskFilePath: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (TaskFilePath.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{TaskFilePath}'''"); + } + else + { + builder.AppendLine($"'{TaskFilePath}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ValuesFilePath), out propertyOverride); + if (Optional.IsDefined(ValuesFilePath) || hasPropertyOverride) + { + builder.Append(" valuesFilePath: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ValuesFilePath.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ValuesFilePath}'''"); + } + else + { + builder.AppendLine($"'{ValuesFilePath}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Values), out propertyOverride); + if (Optional.IsCollectionDefined(Values) || hasPropertyOverride) + { + if (Values.Any() || hasPropertyOverride) + { + builder.Append(" values: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Values) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " values: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TimeoutInSeconds), out propertyOverride); + if (Optional.IsDefined(TimeoutInSeconds) || hasPropertyOverride) + { + builder.Append(" timeout: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{TimeoutInSeconds.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Platform), out propertyOverride); + if (Optional.IsDefined(Platform) || hasPropertyOverride) + { + builder.Append(" platform: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, Platform, options, 2, false, " platform: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AgentConfiguration), out propertyOverride); + if (Optional.IsDefined(AgentConfiguration) || hasPropertyOverride) + { + builder.Append(" agentConfiguration: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, AgentConfiguration, options, 2, false, " agentConfiguration: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SourceLocation), out propertyOverride); + if (Optional.IsDefined(SourceLocation) || hasPropertyOverride) + { + builder.Append(" sourceLocation: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (SourceLocation.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{SourceLocation}'''"); + } + else + { + builder.AppendLine($"'{SourceLocation}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Credentials), out propertyOverride); + if (Optional.IsDefined(Credentials) || hasPropertyOverride) + { + builder.Append(" credentials: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, Credentials, options, 2, false, " credentials: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RunRequestType), out propertyOverride); + if (Optional.IsDefined(RunRequestType) || hasPropertyOverride) + { + builder.Append(" type: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (RunRequestType.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{RunRequestType}'''"); + } + else + { + builder.AppendLine($"'{RunRequestType}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsArchiveEnabled), out propertyOverride); + if (Optional.IsDefined(IsArchiveEnabled) || hasPropertyOverride) + { + builder.Append(" isArchiveEnabled: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsArchiveEnabled.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AgentPoolName), out propertyOverride); + if (Optional.IsDefined(AgentPoolName) || hasPropertyOverride) + { + builder.Append(" agentPoolName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (AgentPoolName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{AgentPoolName}'''"); + } + else + { + builder.AppendLine($"'{AgentPoolName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LogTemplate), out propertyOverride); + if (Optional.IsDefined(LogTemplate) || hasPropertyOverride) + { + builder.Append(" logTemplate: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (LogTemplate.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{LogTemplate}'''"); + } + else + { + builder.AppendLine($"'{LogTemplate}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -252,6 +495,8 @@ BinaryData IPersistableModel.Write(ModelRea { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryFileTaskRunContent)} does not support '{options.Format}' format."); } @@ -268,6 +513,8 @@ ContainerRegistryFileTaskRunContent IPersistableModel The template/definition file path relative to the source. + [WirePath("taskFilePath")] public string TaskFilePath { get; set; } /// The values/parameters file path relative to the source. + [WirePath("valuesFilePath")] public string ValuesFilePath { get; set; } /// The collection of overridable values that can be passed when running a task. + [WirePath("values")] public IList Values { get; } /// Run timeout in seconds. + [WirePath("timeout")] public int? TimeoutInSeconds { get; set; } /// The platform properties against which the run has to happen. + [WirePath("platform")] public ContainerRegistryPlatformProperties Platform { get; set; } /// The machine configuration of the run agent. internal ContainerRegistryAgentProperties AgentConfiguration { get; set; } /// The CPU configuration in terms of number of cores required for the run. + [WirePath("agentConfiguration.cpu")] public int? AgentCpu { get => AgentConfiguration is null ? default : AgentConfiguration.Cpu; @@ -92,8 +98,10 @@ public int? AgentCpu /// The URL(absolute or relative) of the source context. It can be an URL to a tar or git repository. /// If it is relative URL, the relative path should be obtained from calling listBuildSourceUploadUrl API. /// + [WirePath("sourceLocation")] public string SourceLocation { get; set; } /// The properties that describes a set of credentials that will be used when this run is invoked. + [WirePath("credentials")] public ContainerRegistryCredentials Credentials { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryFileTaskStep.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryFileTaskStep.Serialization.cs index d5f7e10423203..7093394bffb7a 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryFileTaskStep.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryFileTaskStep.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -185,6 +188,164 @@ internal static ContainerRegistryFileTaskStep DeserializeContainerRegistryFileTa values ?? new ChangeTrackingList()); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TaskFilePath), out propertyOverride); + if (Optional.IsDefined(TaskFilePath) || hasPropertyOverride) + { + builder.Append(" taskFilePath: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (TaskFilePath.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{TaskFilePath}'''"); + } + else + { + builder.AppendLine($"'{TaskFilePath}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ValuesFilePath), out propertyOverride); + if (Optional.IsDefined(ValuesFilePath) || hasPropertyOverride) + { + builder.Append(" valuesFilePath: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ValuesFilePath.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ValuesFilePath}'''"); + } + else + { + builder.AppendLine($"'{ValuesFilePath}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Values), out propertyOverride); + if (Optional.IsCollectionDefined(Values) || hasPropertyOverride) + { + if (Values.Any() || hasPropertyOverride) + { + builder.Append(" values: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Values) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " values: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ContainerRegistryTaskStepType), out propertyOverride); + builder.Append(" type: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ContainerRegistryTaskStepType.ToString()}'"); + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BaseImageDependencies), out propertyOverride); + if (Optional.IsCollectionDefined(BaseImageDependencies) || hasPropertyOverride) + { + if (BaseImageDependencies.Any() || hasPropertyOverride) + { + builder.Append(" baseImageDependencies: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in BaseImageDependencies) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " baseImageDependencies: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ContextPath), out propertyOverride); + if (Optional.IsDefined(ContextPath) || hasPropertyOverride) + { + builder.Append(" contextPath: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ContextPath.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ContextPath}'''"); + } + else + { + builder.AppendLine($"'{ContextPath}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ContextAccessToken), out propertyOverride); + if (Optional.IsDefined(ContextAccessToken) || hasPropertyOverride) + { + builder.Append(" contextAccessToken: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ContextAccessToken.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ContextAccessToken}'''"); + } + else + { + builder.AppendLine($"'{ContextAccessToken}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -193,6 +354,8 @@ BinaryData IPersistableModel.Write(ModelReaderWri { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryFileTaskStep)} does not support '{options.Format}' format."); } @@ -209,6 +372,8 @@ ContainerRegistryFileTaskStep IPersistableModel.C using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerRegistryFileTaskStep(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerRegistryFileTaskStep)} does not support '{options.Format}' format."); } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryFileTaskStep.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryFileTaskStep.cs index 7feb1ac3275c0..2568319a4f592 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryFileTaskStep.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryFileTaskStep.cs @@ -49,10 +49,13 @@ internal ContainerRegistryFileTaskStep() } /// The task template/definition file path relative to the source context. + [WirePath("taskFilePath")] public string TaskFilePath { get; set; } /// The task values/parameters file path relative to the source context. + [WirePath("valuesFilePath")] public string ValuesFilePath { get; set; } /// The collection of overridable values that can be passed when running a task. + [WirePath("values")] public IList Values { get; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryFileTaskStepUpdateContent.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryFileTaskStepUpdateContent.cs index d0a1358e3db96..ac8299d032623 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryFileTaskStepUpdateContent.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryFileTaskStepUpdateContent.cs @@ -38,10 +38,13 @@ internal ContainerRegistryFileTaskStepUpdateContent(ContainerRegistryTaskStepTyp } /// The task template/definition file path relative to the source context. + [WirePath("taskFilePath")] public string TaskFilePath { get; set; } /// The values/parameters file path relative to the source context. + [WirePath("valuesFilePath")] public string ValuesFilePath { get; set; } /// The collection of overridable values that can be passed when running a task. + [WirePath("values")] public IList Values { get; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryGenerateCredentialsContent.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryGenerateCredentialsContent.cs index 2e60a2a2fa287..25c62feee823e 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryGenerateCredentialsContent.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryGenerateCredentialsContent.cs @@ -65,10 +65,13 @@ internal ContainerRegistryGenerateCredentialsContent(ResourceIdentifier tokenId, } /// The resource ID of the token for which credentials have to be generated. + [WirePath("tokenId")] public ResourceIdentifier TokenId { get; set; } /// The expiry date of the generated credentials after which the credentials become invalid. + [WirePath("expiry")] public DateTimeOffset? ExpireOn { get; set; } /// Specifies name of the password which should be regenerated if any -- password1 or password2. + [WirePath("name")] public ContainerRegistryTokenPasswordName? Name { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryGenerateCredentialsResult.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryGenerateCredentialsResult.Serialization.cs index bd008b4246304..960072fdb28d0 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryGenerateCredentialsResult.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryGenerateCredentialsResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -114,6 +117,65 @@ internal static ContainerRegistryGenerateCredentialsResult DeserializeContainerR return new ContainerRegistryGenerateCredentialsResult(username, passwords ?? new ChangeTrackingList(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Username), out propertyOverride); + if (Optional.IsDefined(Username) || hasPropertyOverride) + { + builder.Append(" username: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Username.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Username}'''"); + } + else + { + builder.AppendLine($"'{Username}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Passwords), out propertyOverride); + if (Optional.IsCollectionDefined(Passwords) || hasPropertyOverride) + { + if (Passwords.Any() || hasPropertyOverride) + { + builder.Append(" passwords: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Passwords) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " passwords: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -122,6 +184,8 @@ BinaryData IPersistableModel.Write(M { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryGenerateCredentialsResult)} does not support '{options.Format}' format."); } @@ -138,6 +202,8 @@ ContainerRegistryGenerateCredentialsResult IPersistableModel The username for a container registry. + [WirePath("username")] public string Username { get; } /// The list of passwords for a container registry. + [WirePath("passwords")] public IReadOnlyList Passwords { get; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryIPRule.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryIPRule.Serialization.cs index 8b5d679614ea6..0d4a4318ad301 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryIPRule.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryIPRule.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -101,6 +103,57 @@ internal static ContainerRegistryIPRule DeserializeContainerRegistryIPRule(JsonE return new ContainerRegistryIPRule(action, value, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Action), out propertyOverride); + if (Optional.IsDefined(Action) || hasPropertyOverride) + { + builder.Append(" action: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Action.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IPAddressOrRange), out propertyOverride); + if (Optional.IsDefined(IPAddressOrRange) || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (IPAddressOrRange.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{IPAddressOrRange}'''"); + } + else + { + builder.AppendLine($"'{IPAddressOrRange}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -109,6 +162,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpt { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryIPRule)} does not support '{options.Format}' format."); } @@ -125,6 +180,8 @@ ContainerRegistryIPRule IPersistableModel.Create(Binary using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerRegistryIPRule(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerRegistryIPRule)} does not support '{options.Format}' format."); } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryIPRule.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryIPRule.cs index 434049b6f97da..8e36e6b528874 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryIPRule.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryIPRule.cs @@ -73,8 +73,10 @@ internal ContainerRegistryIPRule() } /// The action of IP ACL rule. + [WirePath("action")] public ContainerRegistryIPRuleAction? Action { get; set; } /// Specifies the IP or IP range in CIDR format. Only IPV4 address is allowed. + [WirePath("value")] public string IPAddressOrRange { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryImageDescriptor.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryImageDescriptor.Serialization.cs index 527eb6d693d4c..45b104ea2508f 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryImageDescriptor.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryImageDescriptor.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -122,6 +124,109 @@ internal static ContainerRegistryImageDescriptor DeserializeContainerRegistryIma return new ContainerRegistryImageDescriptor(registry, repository, tag, digest, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Registry), out propertyOverride); + if (Optional.IsDefined(Registry) || hasPropertyOverride) + { + builder.Append(" registry: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Registry.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Registry}'''"); + } + else + { + builder.AppendLine($"'{Registry}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Repository), out propertyOverride); + if (Optional.IsDefined(Repository) || hasPropertyOverride) + { + builder.Append(" repository: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Repository.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Repository}'''"); + } + else + { + builder.AppendLine($"'{Repository}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tag), out propertyOverride); + if (Optional.IsDefined(Tag) || hasPropertyOverride) + { + builder.Append(" tag: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Tag.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Tag}'''"); + } + else + { + builder.AppendLine($"'{Tag}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Digest), out propertyOverride); + if (Optional.IsDefined(Digest) || hasPropertyOverride) + { + builder.Append(" digest: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Digest.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Digest}'''"); + } + else + { + builder.AppendLine($"'{Digest}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -130,6 +235,8 @@ BinaryData IPersistableModel.Write(ModelReader { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryImageDescriptor)} does not support '{options.Format}' format."); } @@ -146,6 +253,8 @@ ContainerRegistryImageDescriptor IPersistableModel The registry login server. + [WirePath("registry")] public string Registry { get; set; } /// The repository name. + [WirePath("repository")] public string Repository { get; set; } /// The tag name. + [WirePath("tag")] public string Tag { get; set; } /// The sha256-based digest of the image manifest. + [WirePath("digest")] public string Digest { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryImageUpdateTrigger.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryImageUpdateTrigger.Serialization.cs index ce57b32ad755f..d3d60ba5112ad 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryImageUpdateTrigger.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryImageUpdateTrigger.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -133,6 +136,72 @@ internal static ContainerRegistryImageUpdateTrigger DeserializeContainerRegistry return new ContainerRegistryImageUpdateTrigger(id, timestamp, images ?? new ChangeTrackingList(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Timestamp), out propertyOverride); + if (Optional.IsDefined(Timestamp) || hasPropertyOverride) + { + builder.Append(" timestamp: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(Timestamp.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Images), out propertyOverride); + if (Optional.IsCollectionDefined(Images) || hasPropertyOverride) + { + if (Images.Any() || hasPropertyOverride) + { + builder.Append(" images: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Images) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " images: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -141,6 +210,8 @@ BinaryData IPersistableModel.Write(ModelRea { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryImageUpdateTrigger)} does not support '{options.Format}' format."); } @@ -157,6 +228,8 @@ ContainerRegistryImageUpdateTrigger IPersistableModel The unique ID of the trigger. + [WirePath("id")] public Guid? Id { get; set; } /// The timestamp when the image update happened. + [WirePath("timestamp")] public DateTimeOffset? Timestamp { get; set; } /// The list of image updates that caused the build. + [WirePath("images")] public IList Images { get; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryImportImageContent.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryImportImageContent.cs index d9477cb097f09..448b2e61214f9 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryImportImageContent.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryImportImageContent.cs @@ -79,12 +79,16 @@ internal ContainerRegistryImportImageContent() } /// The source of the image. + [WirePath("source")] public ContainerRegistryImportSource Source { get; } /// List of strings of the form repo[:tag]. When tag is omitted the source will be used (or 'latest' if source tag is also omitted). + [WirePath("targetTags")] public IList TargetTags { get; } /// List of strings of repository names to do a manifest only copy. No tag will be created. + [WirePath("untaggedTargetRepositories")] public IList UntaggedTargetRepositories { get; } /// When Force, any existing target tags will be overwritten. When NoForce, any existing target tags will fail the operation before any copying begins. + [WirePath("mode")] public ContainerRegistryImportMode? Mode { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryImportSource.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryImportSource.cs index 9f44509c6cc17..b30fa7a2d0a61 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryImportSource.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryImportSource.cs @@ -88,10 +88,13 @@ internal ContainerRegistryImportSource() } /// The resource identifier of the source Azure Container Registry. + [WirePath("resourceId")] public ResourceIdentifier ResourceId { get; set; } /// The address of the source registry (e.g. 'mcr.microsoft.com'). + [WirePath("registryUri")] public string RegistryAddress { get; set; } /// Credentials used when importing from a registry uri. + [WirePath("credentials")] public ContainerRegistryImportSourceCredentials Credentials { get; set; } /// /// Repository name of the source image. @@ -99,6 +102,7 @@ internal ContainerRegistryImportSource() /// Specify an image by tag ('hello-world:latest'). /// Specify an image by sha256-based manifest digest ('hello-world@sha256:abc123'). /// + [WirePath("sourceImage")] public string SourceImage { get; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryImportSourceCredentials.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryImportSourceCredentials.cs index ea7ed2b002f6a..54f1ec0a2cf91 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryImportSourceCredentials.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryImportSourceCredentials.cs @@ -73,8 +73,10 @@ internal ContainerRegistryImportSourceCredentials() } /// The username to authenticate with the source registry. + [WirePath("username")] public string Username { get; set; } /// The password used to authenticate with the source registry. + [WirePath("password")] public string Password { get; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryKeyVaultProperties.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryKeyVaultProperties.Serialization.cs index 932e860b36fbf..e29146817a513 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryKeyVaultProperties.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryKeyVaultProperties.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -147,6 +149,117 @@ internal static ContainerRegistryKeyVaultProperties DeserializeContainerRegistry serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyIdentifier), out propertyOverride); + if (Optional.IsDefined(KeyIdentifier) || hasPropertyOverride) + { + builder.Append(" keyIdentifier: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (KeyIdentifier.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{KeyIdentifier}'''"); + } + else + { + builder.AppendLine($"'{KeyIdentifier}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(VersionedKeyIdentifier), out propertyOverride); + if (Optional.IsDefined(VersionedKeyIdentifier) || hasPropertyOverride) + { + builder.Append(" versionedKeyIdentifier: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (VersionedKeyIdentifier.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{VersionedKeyIdentifier}'''"); + } + else + { + builder.AppendLine($"'{VersionedKeyIdentifier}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Identity), out propertyOverride); + if (Optional.IsDefined(Identity) || hasPropertyOverride) + { + builder.Append(" identity: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Identity.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Identity}'''"); + } + else + { + builder.AppendLine($"'{Identity}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsKeyRotationEnabled), out propertyOverride); + if (Optional.IsDefined(IsKeyRotationEnabled) || hasPropertyOverride) + { + builder.Append(" keyRotationEnabled: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsKeyRotationEnabled.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastKeyRotationTimestamp), out propertyOverride); + if (Optional.IsDefined(LastKeyRotationTimestamp) || hasPropertyOverride) + { + builder.Append(" lastKeyRotationTimestamp: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(LastKeyRotationTimestamp.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -155,6 +268,8 @@ BinaryData IPersistableModel.Write(ModelRea { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryKeyVaultProperties)} does not support '{options.Format}' format."); } @@ -171,6 +286,8 @@ ContainerRegistryKeyVaultProperties IPersistableModel Key vault uri to access the encryption key. + [WirePath("keyIdentifier")] public string KeyIdentifier { get; set; } /// The fully qualified key identifier that includes the version of the key that is actually used for encryption. + [WirePath("versionedKeyIdentifier")] public string VersionedKeyIdentifier { get; } /// The client id of the identity which will be used to access key vault. + [WirePath("identity")] public string Identity { get; set; } /// Auto key rotation status for a CMK enabled registry. + [WirePath("keyRotationEnabled")] public bool? IsKeyRotationEnabled { get; } /// Timestamp of the last successful key rotation. + [WirePath("lastKeyRotationTimestamp")] public DateTimeOffset? LastKeyRotationTimestamp { get; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryListCredentialsResult.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryListCredentialsResult.Serialization.cs index d05f11eeffcb3..3054948db51d7 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryListCredentialsResult.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryListCredentialsResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -114,6 +117,65 @@ internal static ContainerRegistryListCredentialsResult DeserializeContainerRegis return new ContainerRegistryListCredentialsResult(username, passwords ?? new ChangeTrackingList(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Username), out propertyOverride); + if (Optional.IsDefined(Username) || hasPropertyOverride) + { + builder.Append(" username: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Username.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Username}'''"); + } + else + { + builder.AppendLine($"'{Username}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Passwords), out propertyOverride); + if (Optional.IsCollectionDefined(Passwords) || hasPropertyOverride) + { + if (Passwords.Any() || hasPropertyOverride) + { + builder.Append(" passwords: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Passwords) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " passwords: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -122,6 +184,8 @@ BinaryData IPersistableModel.Write(Model { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryListCredentialsResult)} does not support '{options.Format}' format."); } @@ -138,6 +202,8 @@ ContainerRegistryListCredentialsResult IPersistableModel The username for a container registry. + [WirePath("username")] public string Username { get; } /// The list of passwords for a container registry. + [WirePath("passwords")] public IReadOnlyList Passwords { get; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryListResult.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryListResult.Serialization.cs index d322f735e4fbb..e1eabf4b6a984 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryListResult.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryListResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -114,6 +117,65 @@ internal static ContainerRegistryListResult DeserializeContainerRegistryListResu return new ContainerRegistryListResult(value ?? new ChangeTrackingList(), nextLink, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (Optional.IsDefined(NextLink) || hasPropertyOverride) + { + builder.Append(" nextLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -122,6 +184,8 @@ BinaryData IPersistableModel.Write(ModelReaderWrite { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryListResult)} does not support '{options.Format}' format."); } @@ -138,6 +202,8 @@ ContainerRegistryListResult IPersistableModel.Creat using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerRegistryListResult(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerRegistryListResult)} does not support '{options.Format}' format."); } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryNameAvailabilityContent.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryNameAvailabilityContent.cs index 9d9ee4fb505df..50183eef4769c 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryNameAvailabilityContent.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryNameAvailabilityContent.cs @@ -74,8 +74,10 @@ internal ContainerRegistryNameAvailabilityContent() } /// The name of the container registry. + [WirePath("name")] public string Name { get; } /// The resource type of the container registry. This field must be set to 'Microsoft.ContainerRegistry/registries'. + [WirePath("type")] public ContainerRegistryResourceType ResourceType { get; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryNameAvailableResult.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryNameAvailableResult.Serialization.cs index e652ba3fdf259..6b451b2b8e37d 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryNameAvailableResult.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryNameAvailableResult.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -115,6 +117,80 @@ internal static ContainerRegistryNameAvailableResult DeserializeContainerRegistr return new ContainerRegistryNameAvailableResult(nameAvailable, reason, message, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsNameAvailable), out propertyOverride); + if (Optional.IsDefined(IsNameAvailable) || hasPropertyOverride) + { + builder.Append(" nameAvailable: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsNameAvailable.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Reason), out propertyOverride); + if (Optional.IsDefined(Reason) || hasPropertyOverride) + { + builder.Append(" reason: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Reason.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Reason}'''"); + } + else + { + builder.AppendLine($"'{Reason}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Message), out propertyOverride); + if (Optional.IsDefined(Message) || hasPropertyOverride) + { + builder.Append(" message: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Message.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Message}'''"); + } + else + { + builder.AppendLine($"'{Message}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -123,6 +199,8 @@ BinaryData IPersistableModel.Write(ModelRe { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryNameAvailableResult)} does not support '{options.Format}' format."); } @@ -139,6 +217,8 @@ ContainerRegistryNameAvailableResult IPersistableModel The value that indicates whether the name is available. + [WirePath("nameAvailable")] public bool? IsNameAvailable { get; } /// If any, the reason that the name is not available. + [WirePath("reason")] public string Reason { get; } /// If any, the error message that provides more detail for the reason that the name is not available. + [WirePath("message")] public string Message { get; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryNetworkRuleSet.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryNetworkRuleSet.Serialization.cs index 64547d8da8ff9..6febe2f0ae697 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryNetworkRuleSet.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryNetworkRuleSet.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -111,6 +114,54 @@ internal static ContainerRegistryNetworkRuleSet DeserializeContainerRegistryNetw return new ContainerRegistryNetworkRuleSet(defaultAction, ipRules ?? new ChangeTrackingList(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DefaultAction), out propertyOverride); + builder.Append(" defaultAction: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{DefaultAction.ToString()}'"); + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IPRules), out propertyOverride); + if (Optional.IsCollectionDefined(IPRules) || hasPropertyOverride) + { + if (IPRules.Any() || hasPropertyOverride) + { + builder.Append(" ipRules: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in IPRules) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " ipRules: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -119,6 +170,8 @@ BinaryData IPersistableModel.Write(ModelReaderW { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryNetworkRuleSet)} does not support '{options.Format}' format."); } @@ -135,6 +188,8 @@ ContainerRegistryNetworkRuleSet IPersistableModel The default action of allow or deny when no other rules match. + [WirePath("defaultAction")] public ContainerRegistryNetworkRuleDefaultAction DefaultAction { get; set; } /// The IP ACL rules. + [WirePath("ipRules")] public IList IPRules { get; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryOverrideTaskStepProperties.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryOverrideTaskStepProperties.Serialization.cs index e3d06b35e1b3d..44586913d93cd 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryOverrideTaskStepProperties.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryOverrideTaskStepProperties.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -179,6 +182,153 @@ internal static ContainerRegistryOverrideTaskStepProperties DeserializeContainer serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ContextPath), out propertyOverride); + if (Optional.IsDefined(ContextPath) || hasPropertyOverride) + { + builder.Append(" contextPath: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ContextPath.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ContextPath}'''"); + } + else + { + builder.AppendLine($"'{ContextPath}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(File), out propertyOverride); + if (Optional.IsDefined(File) || hasPropertyOverride) + { + builder.Append(" file: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (File.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{File}'''"); + } + else + { + builder.AppendLine($"'{File}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Arguments), out propertyOverride); + if (Optional.IsCollectionDefined(Arguments) || hasPropertyOverride) + { + if (Arguments.Any() || hasPropertyOverride) + { + builder.Append(" arguments: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Arguments) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " arguments: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Target), out propertyOverride); + if (Optional.IsDefined(Target) || hasPropertyOverride) + { + builder.Append(" target: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Target.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Target}'''"); + } + else + { + builder.AppendLine($"'{Target}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Values), out propertyOverride); + if (Optional.IsCollectionDefined(Values) || hasPropertyOverride) + { + if (Values.Any() || hasPropertyOverride) + { + builder.Append(" values: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Values) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " values: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(UpdateTriggerToken), out propertyOverride); + if (Optional.IsDefined(UpdateTriggerToken) || hasPropertyOverride) + { + builder.Append(" updateTriggerToken: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (UpdateTriggerToken.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{UpdateTriggerToken}'''"); + } + else + { + builder.AppendLine($"'{UpdateTriggerToken}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -187,6 +337,8 @@ BinaryData IPersistableModel.Write( { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryOverrideTaskStepProperties)} does not support '{options.Format}' format."); } @@ -203,6 +355,8 @@ ContainerRegistryOverrideTaskStepProperties IPersistableModel The source context against which run has to be queued. + [WirePath("contextPath")] public string ContextPath { get; set; } /// The file against which run has to be queued. + [WirePath("file")] public string File { get; set; } /// /// Gets or sets the collection of override arguments to be used when /// executing a build step. /// + [WirePath("arguments")] public IList Arguments { get; } /// The name of the target build stage for the docker build. + [WirePath("target")] public string Target { get; set; } /// The collection of overridable values that can be passed when running a Task. + [WirePath("values")] public IList Values { get; } /// Base64 encoded update trigger token that will be attached with the base image trigger webhook. + [WirePath("updateTriggerToken")] public string UpdateTriggerToken { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryPassword.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryPassword.Serialization.cs index 7859bd1a4a686..ac14004bb0120 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryPassword.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryPassword.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -104,6 +106,57 @@ internal static ContainerRegistryPassword DeserializeContainerRegistryPassword(J return new ContainerRegistryPassword(name, value, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Name.Value.ToSerialString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsDefined(Value) || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Value}'''"); + } + else + { + builder.AppendLine($"'{Value}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -112,6 +165,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterO { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryPassword)} does not support '{options.Format}' format."); } @@ -128,6 +183,8 @@ ContainerRegistryPassword IPersistableModel.Create(Bi using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerRegistryPassword(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerRegistryPassword)} does not support '{options.Format}' format."); } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryPassword.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryPassword.cs index f19510bd5418f..65415e6dd08b4 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryPassword.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryPassword.cs @@ -62,8 +62,10 @@ internal ContainerRegistryPassword(ContainerRegistryPasswordName? name, string v } /// The password name. + [WirePath("name")] public ContainerRegistryPasswordName? Name { get; } /// The password value. + [WirePath("value")] public string Value { get; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryPatch.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryPatch.cs index e9a5c89801455..fb76d9b98cfad 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryPatch.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryPatch.cs @@ -7,7 +7,7 @@ using System; using System.Collections.Generic; -using Azure.Core; +using Azure.ResourceManager.ContainerRegistry; using Azure.ResourceManager.Models; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -81,24 +81,34 @@ internal ContainerRegistryPatch(ManagedServiceIdentity identity, IDictionary The identity of the container registry. + [WirePath("identity")] public ManagedServiceIdentity Identity { get; set; } /// The tags for the container registry. + [WirePath("tags")] public IDictionary Tags { get; } /// The SKU of the container registry. + [WirePath("sku")] public ContainerRegistrySku Sku { get; set; } /// The value that indicates whether the admin user is enabled. + [WirePath("properties.adminUserEnabled")] public bool? IsAdminUserEnabled { get; set; } /// The network rule set for a container registry. + [WirePath("properties.networkRuleSet")] public ContainerRegistryNetworkRuleSet NetworkRuleSet { get; set; } /// The policies for a container registry. + [WirePath("properties.policies")] public ContainerRegistryPolicies Policies { get; set; } /// The encryption settings of container registry. + [WirePath("properties.encryption")] public ContainerRegistryEncryption Encryption { get; set; } /// Enable a single data endpoint per region for serving data. + [WirePath("properties.dataEndpointEnabled")] public bool? IsDataEndpointEnabled { get; set; } /// Whether or not public network access is allowed for the container registry. + [WirePath("properties.publicNetworkAccess")] public ContainerRegistryPublicNetworkAccess? PublicNetworkAccess { get; set; } /// Whether to allow trusted Azure services to access a network restricted registry. + [WirePath("properties.networkRuleBypassOptions")] public ContainerRegistryNetworkRuleBypassOption? NetworkRuleBypassOptions { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryPlatformProperties.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryPlatformProperties.Serialization.cs index e6ee39b2580af..333648c17ce1a 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryPlatformProperties.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryPlatformProperties.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -116,6 +118,60 @@ internal static ContainerRegistryPlatformProperties DeserializeContainerRegistry return new ContainerRegistryPlatformProperties(os, architecture, variant, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(OS), out propertyOverride); + builder.Append(" os: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{OS.ToString()}'"); + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Architecture), out propertyOverride); + if (Optional.IsDefined(Architecture) || hasPropertyOverride) + { + builder.Append(" architecture: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Architecture.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Variant), out propertyOverride); + if (Optional.IsDefined(Variant) || hasPropertyOverride) + { + builder.Append(" variant: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Variant.Value.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -124,6 +180,8 @@ BinaryData IPersistableModel.Write(ModelRea { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryPlatformProperties)} does not support '{options.Format}' format."); } @@ -140,6 +198,8 @@ ContainerRegistryPlatformProperties IPersistableModel The operating system type required for the run. + [WirePath("os")] public ContainerRegistryOS OS { get; set; } /// The OS architecture. + [WirePath("architecture")] public ContainerRegistryOSArchitecture? Architecture { get; set; } /// Variant of the CPU. + [WirePath("variant")] public ContainerRegistryCpuVariant? Variant { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryPlatformUpdateContent.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryPlatformUpdateContent.cs index 5012c221e7349..ae70473095ecc 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryPlatformUpdateContent.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryPlatformUpdateContent.cs @@ -64,10 +64,13 @@ internal ContainerRegistryPlatformUpdateContent(ContainerRegistryOS? os, Contain } /// The operating system type required for the run. + [WirePath("os")] public ContainerRegistryOS? OS { get; set; } /// The OS architecture. + [WirePath("architecture")] public ContainerRegistryOSArchitecture? Architecture { get; set; } /// Variant of the CPU. + [WirePath("variant")] public ContainerRegistryCpuVariant? Variant { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryPolicies.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryPolicies.Serialization.cs index c728d13dd3090..09d6af1a0113a 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryPolicies.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryPolicies.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -138,6 +140,77 @@ internal static ContainerRegistryPolicies DeserializeContainerRegistryPolicies(J return new ContainerRegistryPolicies(quarantinePolicy, trustPolicy, retentionPolicy, exportPolicy, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(QuarantinePolicy), out propertyOverride); + if (Optional.IsDefined(QuarantinePolicy) || hasPropertyOverride) + { + builder.Append(" quarantinePolicy: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, QuarantinePolicy, options, 2, false, " quarantinePolicy: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TrustPolicy), out propertyOverride); + if (Optional.IsDefined(TrustPolicy) || hasPropertyOverride) + { + builder.Append(" trustPolicy: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, TrustPolicy, options, 2, false, " trustPolicy: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RetentionPolicy), out propertyOverride); + if (Optional.IsDefined(RetentionPolicy) || hasPropertyOverride) + { + builder.Append(" retentionPolicy: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, RetentionPolicy, options, 2, false, " retentionPolicy: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExportPolicy), out propertyOverride); + if (Optional.IsDefined(ExportPolicy) || hasPropertyOverride) + { + builder.Append(" exportPolicy: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, ExportPolicy, options, 2, false, " exportPolicy: "); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -146,6 +219,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterO { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryPolicies)} does not support '{options.Format}' format."); } @@ -162,6 +237,8 @@ ContainerRegistryPolicies IPersistableModel.Create(Bi using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerRegistryPolicies(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerRegistryPolicies)} does not support '{options.Format}' format."); } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryPolicies.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryPolicies.cs index c894e299fcecf..910ce521d849d 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryPolicies.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryPolicies.cs @@ -68,6 +68,7 @@ internal ContainerRegistryPolicies(ContainerRegistryQuarantinePolicy quarantineP /// The quarantine policy for a container registry. internal ContainerRegistryQuarantinePolicy QuarantinePolicy { get; set; } /// The value that indicates whether the policy is enabled or not. + [WirePath("quarantinePolicy.status")] public ContainerRegistryPolicyStatus? QuarantineStatus { get => QuarantinePolicy is null ? default : QuarantinePolicy.Status; @@ -80,12 +81,15 @@ public ContainerRegistryPolicyStatus? QuarantineStatus } /// The content trust policy for a container registry. + [WirePath("trustPolicy")] public ContainerRegistryTrustPolicy TrustPolicy { get; set; } /// The retention policy for a container registry. + [WirePath("retentionPolicy")] public ContainerRegistryRetentionPolicy RetentionPolicy { get; set; } /// The export policy for a container registry. internal ContainerRegistryExportPolicy ExportPolicy { get; set; } /// The value that indicates whether the policy is enabled or not. + [WirePath("exportPolicy.status")] public ContainerRegistryExportPolicyStatus? ExportStatus { get => ExportPolicy is null ? default : ExportPolicy.Status; diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryPrivateEndpointConnectionListResult.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryPrivateEndpointConnectionListResult.Serialization.cs index 819d86c83a537..4c01e4897d0c0 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryPrivateEndpointConnectionListResult.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryPrivateEndpointConnectionListResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -114,6 +117,65 @@ internal static ContainerRegistryPrivateEndpointConnectionListResult Deserialize return new ContainerRegistryPrivateEndpointConnectionListResult(value ?? new ChangeTrackingList(), nextLink, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (Optional.IsDefined(NextLink) || hasPropertyOverride) + { + builder.Append(" nextLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -122,6 +184,8 @@ BinaryData IPersistableModel(), nextLink, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (Optional.IsDefined(NextLink) || hasPropertyOverride) + { + builder.Append(" nextLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -122,6 +184,8 @@ BinaryData IPersistableModel.Wri { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryPrivateLinkResourceListResult)} does not support '{options.Format}' format."); } @@ -138,6 +202,8 @@ ContainerRegistryPrivateLinkResourceListResult IPersistableModel propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); + if (Optional.IsDefined(Status) || hasPropertyOverride) + { + builder.Append(" status: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Status.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); + if (Optional.IsDefined(Description) || hasPropertyOverride) + { + builder.Append(" description: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Description.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Description}'''"); + } + else + { + builder.AppendLine($"'{Description}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ActionsRequired), out propertyOverride); + if (Optional.IsDefined(ActionsRequired) || hasPropertyOverride) + { + builder.Append(" actionsRequired: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ActionsRequired.Value.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -127,6 +194,8 @@ BinaryData IPersistableModel { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryPrivateLinkServiceConnectionState)} does not support '{options.Format}' format."); } @@ -143,6 +212,8 @@ ContainerRegistryPrivateLinkServiceConnectionState IPersistableModel The private link service connection status. + [WirePath("status")] public ContainerRegistryPrivateLinkServiceConnectionStatus? Status { get; set; } /// The description for connection status. For example if connection is rejected it can indicate reason for rejection. + [WirePath("description")] public string Description { get; set; } /// A message indicating if changes on the service provider require any updates on the consumer. + [WirePath("actionsRequired")] public ActionsRequiredForPrivateLinkServiceConsumer? ActionsRequired { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryQuarantinePolicy.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryQuarantinePolicy.Serialization.cs index baeaf3d5603fa..d8654d8a0f33c 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryQuarantinePolicy.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryQuarantinePolicy.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -93,6 +95,35 @@ internal static ContainerRegistryQuarantinePolicy DeserializeContainerRegistryQu return new ContainerRegistryQuarantinePolicy(status, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); + if (Optional.IsDefined(Status) || hasPropertyOverride) + { + builder.Append(" status: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Status.Value.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -101,6 +132,8 @@ BinaryData IPersistableModel.Write(ModelReade { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryQuarantinePolicy)} does not support '{options.Format}' format."); } @@ -117,6 +150,8 @@ ContainerRegistryQuarantinePolicy IPersistableModel The value that indicates whether the policy is enabled or not. + [WirePath("status")] public ContainerRegistryPolicyStatus? Status { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryReplicationListResult.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryReplicationListResult.Serialization.cs index f6b4bbe10bb41..5e8f1a25b44d3 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryReplicationListResult.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryReplicationListResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -114,6 +117,65 @@ internal static ContainerRegistryReplicationListResult DeserializeContainerRegis return new ContainerRegistryReplicationListResult(value ?? new ChangeTrackingList(), nextLink, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (Optional.IsDefined(NextLink) || hasPropertyOverride) + { + builder.Append(" nextLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -122,6 +184,8 @@ BinaryData IPersistableModel.Write(Model { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryReplicationListResult)} does not support '{options.Format}' format."); } @@ -138,6 +202,8 @@ ContainerRegistryReplicationListResult IPersistableModel tags, boo } /// The tags for the replication. + [WirePath("tags")] public IDictionary Tags { get; } /// Specifies whether the replication's regional endpoint is enabled. Requests will not be routed to a replication whose regional endpoint is disabled, however its data will continue to be synced with other replications. + [WirePath("properties.regionEndpointEnabled")] public bool? IsRegionEndpointEnabled { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryResourceStatus.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryResourceStatus.Serialization.cs index b7ecc8d561372..b8b393ae47774 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryResourceStatus.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryResourceStatus.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -115,6 +117,80 @@ internal static ContainerRegistryResourceStatus DeserializeContainerRegistryReso return new ContainerRegistryResourceStatus(displayStatus, message, timestamp, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisplayStatus), out propertyOverride); + if (Optional.IsDefined(DisplayStatus) || hasPropertyOverride) + { + builder.Append(" displayStatus: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (DisplayStatus.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{DisplayStatus}'''"); + } + else + { + builder.AppendLine($"'{DisplayStatus}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Message), out propertyOverride); + if (Optional.IsDefined(Message) || hasPropertyOverride) + { + builder.Append(" message: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Message.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Message}'''"); + } + else + { + builder.AppendLine($"'{Message}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Timestamp), out propertyOverride); + if (Optional.IsDefined(Timestamp) || hasPropertyOverride) + { + builder.Append(" timestamp: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(Timestamp.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -123,6 +199,8 @@ BinaryData IPersistableModel.Write(ModelReaderW { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryResourceStatus)} does not support '{options.Format}' format."); } @@ -139,6 +217,8 @@ ContainerRegistryResourceStatus IPersistableModel The short label for the status. + [WirePath("displayStatus")] public string DisplayStatus { get; } /// The detailed message for the status, including alerts and error messages. + [WirePath("message")] public string Message { get; } /// The timestamp when the status was changed to the current value. + [WirePath("timestamp")] public DateTimeOffset? Timestamp { get; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryRetentionPolicy.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryRetentionPolicy.Serialization.cs index c7e5f4b1de0bd..2f1b2a3a0473e 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryRetentionPolicy.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryRetentionPolicy.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -123,6 +125,64 @@ internal static ContainerRegistryRetentionPolicy DeserializeContainerRegistryRet return new ContainerRegistryRetentionPolicy(days, lastUpdatedTime, status, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Days), out propertyOverride); + if (Optional.IsDefined(Days) || hasPropertyOverride) + { + builder.Append(" days: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{Days.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastUpdatedOn), out propertyOverride); + if (Optional.IsDefined(LastUpdatedOn) || hasPropertyOverride) + { + builder.Append(" lastUpdatedTime: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(LastUpdatedOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); + if (Optional.IsDefined(Status) || hasPropertyOverride) + { + builder.Append(" status: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Status.Value.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -131,6 +191,8 @@ BinaryData IPersistableModel.Write(ModelReader { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryRetentionPolicy)} does not support '{options.Format}' format."); } @@ -147,6 +209,8 @@ ContainerRegistryRetentionPolicy IPersistableModel The number of days to retain an untagged manifest after which it gets purged. + [WirePath("days")] public int? Days { get; set; } /// The timestamp when the policy was last updated. + [WirePath("lastUpdatedTime")] public DateTimeOffset? LastUpdatedOn { get; } /// The value that indicates whether the policy is enabled or not. + [WirePath("status")] public ContainerRegistryPolicyStatus? Status { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryRunArgument.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryRunArgument.Serialization.cs index 41ac2747def72..b9a5a47a9d195 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryRunArgument.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryRunArgument.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -109,6 +111,80 @@ internal static ContainerRegistryRunArgument DeserializeContainerRegistryRunArgu return new ContainerRegistryRunArgument(name, value, isSecret, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsDefined(Value) || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Value}'''"); + } + else + { + builder.AppendLine($"'{Value}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsSecret), out propertyOverride); + if (Optional.IsDefined(IsSecret) || hasPropertyOverride) + { + builder.Append(" isSecret: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsSecret.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -117,6 +193,8 @@ BinaryData IPersistableModel.Write(ModelReaderWrit { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryRunArgument)} does not support '{options.Format}' format."); } @@ -133,6 +211,8 @@ ContainerRegistryRunArgument IPersistableModel.Cre using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerRegistryRunArgument(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerRegistryRunArgument)} does not support '{options.Format}' format."); } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryRunArgument.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryRunArgument.cs index 92587e17b74c2..57eee2058dd2b 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryRunArgument.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryRunArgument.cs @@ -78,10 +78,13 @@ internal ContainerRegistryRunArgument() } /// The name of the argument. + [WirePath("name")] public string Name { get; set; } /// The value of the argument. + [WirePath("value")] public string Value { get; set; } /// Flag to indicate whether the argument represents a secret and want to be removed from build logs. + [WirePath("isSecret")] public bool? IsSecret { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryRunContent.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryRunContent.Serialization.cs index 68424ac04f60b..94802a73b41c7 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryRunContent.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryRunContent.Serialization.cs @@ -7,8 +7,11 @@ using System; using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -95,6 +98,102 @@ internal static ContainerRegistryRunContent DeserializeContainerRegistryRunConte return UnknownRunRequest.DeserializeUnknownRunRequest(element, options); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RunRequestType), out propertyOverride); + if (Optional.IsDefined(RunRequestType) || hasPropertyOverride) + { + builder.Append(" type: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (RunRequestType.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{RunRequestType}'''"); + } + else + { + builder.AppendLine($"'{RunRequestType}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsArchiveEnabled), out propertyOverride); + if (Optional.IsDefined(IsArchiveEnabled) || hasPropertyOverride) + { + builder.Append(" isArchiveEnabled: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsArchiveEnabled.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AgentPoolName), out propertyOverride); + if (Optional.IsDefined(AgentPoolName) || hasPropertyOverride) + { + builder.Append(" agentPoolName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (AgentPoolName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{AgentPoolName}'''"); + } + else + { + builder.AppendLine($"'{AgentPoolName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LogTemplate), out propertyOverride); + if (Optional.IsDefined(LogTemplate) || hasPropertyOverride) + { + builder.Append(" logTemplate: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (LogTemplate.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{LogTemplate}'''"); + } + else + { + builder.AppendLine($"'{LogTemplate}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -103,6 +202,8 @@ BinaryData IPersistableModel.Write(ModelReaderWrite { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryRunContent)} does not support '{options.Format}' format."); } @@ -119,6 +220,8 @@ ContainerRegistryRunContent IPersistableModel.Creat using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerRegistryRunContent(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerRegistryRunContent)} does not support '{options.Format}' format."); } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryRunContent.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryRunContent.cs index 15df5521617a5..f74f68b3c355b 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryRunContent.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryRunContent.cs @@ -72,10 +72,13 @@ internal ContainerRegistryRunContent(string runRequestType, bool? isArchiveEnabl /// The type of the run request. internal string RunRequestType { get; set; } /// The value that indicates whether archiving is enabled for the run or not. + [WirePath("isArchiveEnabled")] public bool? IsArchiveEnabled { get; set; } /// The dedicated agent pool for the run. + [WirePath("agentPoolName")] public string AgentPoolName { get; set; } /// The template that describes the repository and tag information for run log artifact. + [WirePath("logTemplate")] public string LogTemplate { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryRunGetLogResult.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryRunGetLogResult.Serialization.cs index 85dcfb4ce36c5..56a61878a2bfb 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryRunGetLogResult.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryRunGetLogResult.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -100,6 +102,65 @@ internal static ContainerRegistryRunGetLogResult DeserializeContainerRegistryRun return new ContainerRegistryRunGetLogResult(logLink, logArtifactLink, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LogLink), out propertyOverride); + if (Optional.IsDefined(LogLink) || hasPropertyOverride) + { + builder.Append(" logLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (LogLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{LogLink}'''"); + } + else + { + builder.AppendLine($"'{LogLink}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LogArtifactLink), out propertyOverride); + if (Optional.IsDefined(LogArtifactLink) || hasPropertyOverride) + { + builder.Append(" logArtifactLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (LogArtifactLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{LogArtifactLink}'''"); + } + else + { + builder.AppendLine($"'{LogArtifactLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -108,6 +169,8 @@ BinaryData IPersistableModel.Write(ModelReader { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryRunGetLogResult)} does not support '{options.Format}' format."); } @@ -124,6 +187,8 @@ ContainerRegistryRunGetLogResult IPersistableModel The link to logs for a run on a azure container registry. + [WirePath("logLink")] public string LogLink { get; } /// The link to logs in registry for a run on a azure container registry. + [WirePath("logArtifactLink")] public string LogArtifactLink { get; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryRunListResult.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryRunListResult.Serialization.cs index e0ce263897433..92a39020c410a 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryRunListResult.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryRunListResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -114,6 +117,65 @@ internal static ContainerRegistryRunListResult DeserializeContainerRegistryRunLi return new ContainerRegistryRunListResult(value ?? new ChangeTrackingList(), nextLink, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (Optional.IsDefined(NextLink) || hasPropertyOverride) + { + builder.Append(" nextLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -122,6 +184,8 @@ BinaryData IPersistableModel.Write(ModelReaderWr { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryRunListResult)} does not support '{options.Format}' format."); } @@ -138,6 +202,8 @@ ContainerRegistryRunListResult IPersistableModel using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerRegistryRunListResult(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerRegistryRunListResult)} does not support '{options.Format}' format."); } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryRunPatch.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryRunPatch.cs index a53841143e65c..2da3e23f2a546 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryRunPatch.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryRunPatch.cs @@ -60,6 +60,7 @@ internal ContainerRegistryRunPatch(bool? isArchiveEnabled, IDictionary The value that indicates whether archiving is enabled or not. + [WirePath("isArchiveEnabled")] public bool? IsArchiveEnabled { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistrySecretObject.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistrySecretObject.Serialization.cs index 40ab92462c026..da21cc6d4bc56 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistrySecretObject.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistrySecretObject.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -104,6 +106,57 @@ internal static ContainerRegistrySecretObject DeserializeContainerRegistrySecret return new ContainerRegistrySecretObject(value, type, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsDefined(Value) || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Value}'''"); + } + else + { + builder.AppendLine($"'{Value}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ObjectType), out propertyOverride); + if (Optional.IsDefined(ObjectType) || hasPropertyOverride) + { + builder.Append(" type: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ObjectType.Value.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -112,6 +165,8 @@ BinaryData IPersistableModel.Write(ModelReaderWri { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistrySecretObject)} does not support '{options.Format}' format."); } @@ -128,6 +183,8 @@ ContainerRegistrySecretObject IPersistableModel.C using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerRegistrySecretObject(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerRegistrySecretObject)} does not support '{options.Format}' format."); } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistrySecretObject.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistrySecretObject.cs index b9a6e588e83dd..bf701b6cd9879 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistrySecretObject.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistrySecretObject.cs @@ -73,11 +73,13 @@ internal ContainerRegistrySecretObject(string value, ContainerRegistrySecretObje /// based on the type of the secret object. If the type is Opaque, the value will be /// used as is without any modification. /// + [WirePath("value")] public string Value { get; set; } /// /// The type of the secret object which determines how the value of the secret object has to be /// interpreted. /// + [WirePath("type")] public ContainerRegistrySecretObjectType? ObjectType { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistrySku.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistrySku.Serialization.cs index 85b79c9d99127..6ef3c56d48a3a 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistrySku.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistrySku.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -101,6 +103,46 @@ internal static ContainerRegistrySku DeserializeContainerRegistrySku(JsonElement return new ContainerRegistrySku(name, tier, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Name.ToString()}'"); + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tier), out propertyOverride); + if (Optional.IsDefined(Tier) || hasPropertyOverride) + { + builder.Append(" tier: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Tier.Value.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -109,6 +151,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOption { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistrySku)} does not support '{options.Format}' format."); } @@ -125,6 +169,8 @@ ContainerRegistrySku IPersistableModel.Create(BinaryData d using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerRegistrySku(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerRegistrySku)} does not support '{options.Format}' format."); } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistrySku.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistrySku.cs index fa37950ae1111..4fc4c8e48c91e 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistrySku.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistrySku.cs @@ -69,8 +69,10 @@ internal ContainerRegistrySku() } /// The SKU name of the container registry. Required for registry creation. + [WirePath("name")] public ContainerRegistrySkuName Name { get; set; } /// The SKU tier based on the SKU name. + [WirePath("tier")] public ContainerRegistrySkuTier? Tier { get; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistrySourceTrigger.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistrySourceTrigger.Serialization.cs index 54782f1302758..9a42116565e1a 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistrySourceTrigger.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistrySourceTrigger.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -127,6 +130,93 @@ internal static ContainerRegistrySourceTrigger DeserializeContainerRegistrySourc return new ContainerRegistrySourceTrigger(sourceRepository, sourceTriggerEvents, status, name, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SourceRepository), out propertyOverride); + if (Optional.IsDefined(SourceRepository) || hasPropertyOverride) + { + builder.Append(" sourceRepository: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, SourceRepository, options, 2, false, " sourceRepository: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SourceTriggerEvents), out propertyOverride); + if (Optional.IsCollectionDefined(SourceTriggerEvents) || hasPropertyOverride) + { + if (SourceTriggerEvents.Any() || hasPropertyOverride) + { + builder.Append(" sourceTriggerEvents: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in SourceTriggerEvents) + { + builder.AppendLine($" '{item.ToString()}'"); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); + if (Optional.IsDefined(Status) || hasPropertyOverride) + { + builder.Append(" status: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Status.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -135,6 +225,8 @@ BinaryData IPersistableModel.Write(ModelReaderWr { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistrySourceTrigger)} does not support '{options.Format}' format."); } @@ -151,6 +243,8 @@ ContainerRegistrySourceTrigger IPersistableModel using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerRegistrySourceTrigger(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerRegistrySourceTrigger)} does not support '{options.Format}' format."); } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistrySourceTrigger.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistrySourceTrigger.cs index ad01226a18ce8..32caf12474da1 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistrySourceTrigger.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistrySourceTrigger.cs @@ -84,12 +84,16 @@ internal ContainerRegistrySourceTrigger() } /// The properties that describes the source(code) for the task. + [WirePath("sourceRepository")] public SourceCodeRepoProperties SourceRepository { get; set; } /// The source event corresponding to the trigger. + [WirePath("sourceTriggerEvents")] public IList SourceTriggerEvents { get; } /// The current status of trigger. + [WirePath("status")] public ContainerRegistryTriggerStatus? Status { get; set; } /// The name of the trigger. + [WirePath("name")] public string Name { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistrySourceTriggerDescriptor.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistrySourceTriggerDescriptor.Serialization.cs index 3a5528f0e7219..cf6d3dd787795 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistrySourceTriggerDescriptor.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistrySourceTriggerDescriptor.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -171,6 +173,159 @@ internal static ContainerRegistrySourceTriggerDescriptor DeserializeContainerReg serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EventType), out propertyOverride); + if (Optional.IsDefined(EventType) || hasPropertyOverride) + { + builder.Append(" eventType: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (EventType.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{EventType}'''"); + } + else + { + builder.AppendLine($"'{EventType}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CommitId), out propertyOverride); + if (Optional.IsDefined(CommitId) || hasPropertyOverride) + { + builder.Append(" commitId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (CommitId.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{CommitId}'''"); + } + else + { + builder.AppendLine($"'{CommitId}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PullRequestId), out propertyOverride); + if (Optional.IsDefined(PullRequestId) || hasPropertyOverride) + { + builder.Append(" pullRequestId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (PullRequestId.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{PullRequestId}'''"); + } + else + { + builder.AppendLine($"'{PullRequestId}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RepositoryUri), out propertyOverride); + if (Optional.IsDefined(RepositoryUri) || hasPropertyOverride) + { + builder.Append(" repositoryUrl: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{RepositoryUri.AbsoluteUri}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BranchName), out propertyOverride); + if (Optional.IsDefined(BranchName) || hasPropertyOverride) + { + builder.Append(" branchName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (BranchName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{BranchName}'''"); + } + else + { + builder.AppendLine($"'{BranchName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProviderType), out propertyOverride); + if (Optional.IsDefined(ProviderType) || hasPropertyOverride) + { + builder.Append(" providerType: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ProviderType.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ProviderType}'''"); + } + else + { + builder.AppendLine($"'{ProviderType}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -179,6 +334,8 @@ BinaryData IPersistableModel.Write(Mod { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistrySourceTriggerDescriptor)} does not support '{options.Format}' format."); } @@ -195,6 +352,8 @@ ContainerRegistrySourceTriggerDescriptor IPersistableModel The unique ID of the trigger. + [WirePath("id")] public Guid? Id { get; set; } /// The event type of the trigger. + [WirePath("eventType")] public string EventType { get; set; } /// The unique ID that identifies a commit. + [WirePath("commitId")] public string CommitId { get; set; } /// The unique ID that identifies pull request. + [WirePath("pullRequestId")] public string PullRequestId { get; set; } /// The repository URL. + [WirePath("repositoryUrl")] public Uri RepositoryUri { get; set; } /// The branch name in the repository. + [WirePath("branchName")] public string BranchName { get; set; } /// The source control provider type. + [WirePath("providerType")] public string ProviderType { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistrySourceTriggerUpdateContent.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistrySourceTriggerUpdateContent.cs index dc4cff5068a4e..dcc9437abcdbe 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistrySourceTriggerUpdateContent.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistrySourceTriggerUpdateContent.cs @@ -78,12 +78,16 @@ internal ContainerRegistrySourceTriggerUpdateContent() } /// The properties that describes the source(code) for the task. + [WirePath("sourceRepository")] public SourceCodeRepoUpdateContent SourceRepository { get; set; } /// The source event corresponding to the trigger. + [WirePath("sourceTriggerEvents")] public IList SourceTriggerEvents { get; } /// The current status of trigger. + [WirePath("status")] public ContainerRegistryTriggerStatus? Status { get; set; } /// The name of the trigger. + [WirePath("name")] public string Name { get; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTaskListResult.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTaskListResult.Serialization.cs index 76ad30b56058f..7a8b08bf6e046 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTaskListResult.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTaskListResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -114,6 +117,65 @@ internal static ContainerRegistryTaskListResult DeserializeContainerRegistryTask return new ContainerRegistryTaskListResult(value ?? new ChangeTrackingList(), nextLink, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (Optional.IsDefined(NextLink) || hasPropertyOverride) + { + builder.Append(" nextLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -122,6 +184,8 @@ BinaryData IPersistableModel.Write(ModelReaderW { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryTaskListResult)} does not support '{options.Format}' format."); } @@ -138,6 +202,8 @@ ContainerRegistryTaskListResult IPersistableModel propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsDefined(Value) || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Value}'''"); + } + else + { + builder.AppendLine($"'{Value}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsSecret), out propertyOverride); + if (Optional.IsDefined(IsSecret) || hasPropertyOverride) + { + builder.Append(" isSecret: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsSecret.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -117,6 +193,8 @@ BinaryData IPersistableModel.Write(ModelR { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryTaskOverridableValue)} does not support '{options.Format}' format."); } @@ -133,6 +211,8 @@ ContainerRegistryTaskOverridableValue IPersistableModel The name of the overridable value. + [WirePath("name")] public string Name { get; set; } /// The overridable value. + [WirePath("value")] public string Value { get; set; } /// Flag to indicate whether the value represents a secret or not. + [WirePath("isSecret")] public bool? IsSecret { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTaskPatch.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTaskPatch.cs index f6240bb6d90ba..817f0b20a21bd 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTaskPatch.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTaskPatch.cs @@ -7,7 +7,7 @@ using System; using System.Collections.Generic; -using Azure.Core; +using Azure.ResourceManager.ContainerRegistry; using Azure.ResourceManager.Models; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -87,16 +87,21 @@ internal ContainerRegistryTaskPatch(ManagedServiceIdentity identity, IDictionary } /// Identity for the resource. + [WirePath("identity")] public ManagedServiceIdentity Identity { get; set; } /// The ARM resource tags. + [WirePath("tags")] public IDictionary Tags { get; } /// The current status of task. + [WirePath("properties.status")] public ContainerRegistryTaskStatus? Status { get; set; } /// The platform properties against which the run has to happen. + [WirePath("properties.platform")] public ContainerRegistryPlatformUpdateContent Platform { get; set; } /// The machine configuration of the run agent. internal ContainerRegistryAgentProperties AgentConfiguration { get; set; } /// The CPU configuration in terms of number of cores required for the run. + [WirePath("properties.agentConfiguration.cpu")] public int? AgentCpu { get => AgentConfiguration is null ? default : AgentConfiguration.Cpu; @@ -109,20 +114,26 @@ public int? AgentCpu } /// The dedicated agent pool for the task. + [WirePath("properties.agentPoolName")] public string AgentPoolName { get; set; } /// Run timeout in seconds. + [WirePath("properties.timeout")] public int? TimeoutInSeconds { get; set; } /// /// The properties for updating a task step. /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. /// The available derived classes include , and . /// + [WirePath("properties.step")] public ContainerRegistryTaskStepUpdateContent Step { get; set; } /// The properties for updating trigger properties. + [WirePath("properties.trigger")] public ContainerRegistryTriggerUpdateContent Trigger { get; set; } /// The parameters that describes a set of credentials that will be used when this run is invoked. + [WirePath("properties.credentials")] public ContainerRegistryCredentials Credentials { get; set; } /// The template that describes the repository and tag information for run log artifact. + [WirePath("properties.logTemplate")] public string LogTemplate { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTaskRunContent.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTaskRunContent.Serialization.cs index dc501494c31c1..17abae5b8de7d 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTaskRunContent.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTaskRunContent.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -153,6 +155,130 @@ internal static ContainerRegistryTaskRunContent DeserializeContainerRegistryTask overrideTaskStepProperties); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TaskId), out propertyOverride); + if (Optional.IsDefined(TaskId) || hasPropertyOverride) + { + builder.Append(" taskId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{TaskId.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(OverrideTaskStepProperties), out propertyOverride); + if (Optional.IsDefined(OverrideTaskStepProperties) || hasPropertyOverride) + { + builder.Append(" overrideTaskStepProperties: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, OverrideTaskStepProperties, options, 2, false, " overrideTaskStepProperties: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RunRequestType), out propertyOverride); + if (Optional.IsDefined(RunRequestType) || hasPropertyOverride) + { + builder.Append(" type: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (RunRequestType.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{RunRequestType}'''"); + } + else + { + builder.AppendLine($"'{RunRequestType}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsArchiveEnabled), out propertyOverride); + if (Optional.IsDefined(IsArchiveEnabled) || hasPropertyOverride) + { + builder.Append(" isArchiveEnabled: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsArchiveEnabled.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AgentPoolName), out propertyOverride); + if (Optional.IsDefined(AgentPoolName) || hasPropertyOverride) + { + builder.Append(" agentPoolName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (AgentPoolName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{AgentPoolName}'''"); + } + else + { + builder.AppendLine($"'{AgentPoolName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LogTemplate), out propertyOverride); + if (Optional.IsDefined(LogTemplate) || hasPropertyOverride) + { + builder.Append(" logTemplate: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (LogTemplate.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{LogTemplate}'''"); + } + else + { + builder.AppendLine($"'{LogTemplate}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -161,6 +287,8 @@ BinaryData IPersistableModel.Write(ModelReaderW { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryTaskRunContent)} does not support '{options.Format}' format."); } @@ -177,6 +305,8 @@ ContainerRegistryTaskRunContent IPersistableModel The resource ID of task against which run has to be queued. + [WirePath("taskId")] public ResourceIdentifier TaskId { get; set; } /// Set of overridable parameters that can be passed when running a Task. + [WirePath("overrideTaskStepProperties")] public ContainerRegistryOverrideTaskStepProperties OverrideTaskStepProperties { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTaskRunListResult.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTaskRunListResult.Serialization.cs index dbe54339a5f87..6bc0c1db02636 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTaskRunListResult.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTaskRunListResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -114,6 +117,65 @@ internal static ContainerRegistryTaskRunListResult DeserializeContainerRegistryT return new ContainerRegistryTaskRunListResult(value ?? new ChangeTrackingList(), nextLink, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (Optional.IsDefined(NextLink) || hasPropertyOverride) + { + builder.Append(" nextLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -122,6 +184,8 @@ BinaryData IPersistableModel.Write(ModelRead { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryTaskRunListResult)} does not support '{options.Format}' format."); } @@ -138,6 +202,8 @@ ContainerRegistryTaskRunListResult IPersistableModel Identity for the resource. + [WirePath("identity")] public ManagedServiceIdentity Identity { get; set; } /// The location of the resource. + [WirePath("location")] public AzureLocation? Location { get; set; } /// The ARM resource tags. + [WirePath("tags")] public IDictionary Tags { get; } /// /// The request (parameters) for the new run /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. /// The available derived classes include , , and . /// + [WirePath("properties.runRequest")] public ContainerRegistryRunContent RunRequest { get; set; } /// How the run should be forced to rerun even if the run request configuration has not changed. + [WirePath("properties.forceUpdateTag")] public string ForceUpdateTag { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTaskStepProperties.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTaskStepProperties.Serialization.cs index 159d6d85ddc2b..a7910fc96ff3d 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTaskStepProperties.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTaskStepProperties.Serialization.cs @@ -7,8 +7,12 @@ using System; using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -99,6 +103,98 @@ internal static ContainerRegistryTaskStepProperties DeserializeContainerRegistry return UnknownTaskStepProperties.DeserializeUnknownTaskStepProperties(element, options); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ContainerRegistryTaskStepType), out propertyOverride); + builder.Append(" type: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ContainerRegistryTaskStepType.ToString()}'"); + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BaseImageDependencies), out propertyOverride); + if (Optional.IsCollectionDefined(BaseImageDependencies) || hasPropertyOverride) + { + if (BaseImageDependencies.Any() || hasPropertyOverride) + { + builder.Append(" baseImageDependencies: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in BaseImageDependencies) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " baseImageDependencies: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ContextPath), out propertyOverride); + if (Optional.IsDefined(ContextPath) || hasPropertyOverride) + { + builder.Append(" contextPath: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ContextPath.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ContextPath}'''"); + } + else + { + builder.AppendLine($"'{ContextPath}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ContextAccessToken), out propertyOverride); + if (Optional.IsDefined(ContextAccessToken) || hasPropertyOverride) + { + builder.Append(" contextAccessToken: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ContextAccessToken.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ContextAccessToken}'''"); + } + else + { + builder.AppendLine($"'{ContextAccessToken}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -107,6 +203,8 @@ BinaryData IPersistableModel.Write(ModelRea { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryTaskStepProperties)} does not support '{options.Format}' format."); } @@ -123,6 +221,8 @@ ContainerRegistryTaskStepProperties IPersistableModel The type of the step. internal ContainerRegistryTaskStepType ContainerRegistryTaskStepType { get; set; } /// List of base image dependencies for a step. + [WirePath("baseImageDependencies")] public IReadOnlyList BaseImageDependencies { get; } /// The URL(absolute or relative) of the source context for the task step. + [WirePath("contextPath")] public string ContextPath { get; set; } /// The token (git PAT or SAS token of storage account blob) associated with the context for a step. + [WirePath("contextAccessToken")] public string ContextAccessToken { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTaskStepUpdateContent.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTaskStepUpdateContent.cs index 649a07c3ecd26..a39dcd809cc85 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTaskStepUpdateContent.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTaskStepUpdateContent.cs @@ -70,8 +70,10 @@ internal ContainerRegistryTaskStepUpdateContent(ContainerRegistryTaskStepType st /// The type of the step. internal ContainerRegistryTaskStepType StepType { get; set; } /// The URL(absolute or relative) of the source context for the task step. + [WirePath("contextPath")] public string ContextPath { get; set; } /// The token (git PAT or SAS token of storage account blob) associated with the context for a step. + [WirePath("contextAccessToken")] public string ContextAccessToken { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTimerTrigger.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTimerTrigger.Serialization.cs index ad7a5448eddeb..57c048c3077a2 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTimerTrigger.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTimerTrigger.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -109,6 +111,79 @@ internal static ContainerRegistryTimerTrigger DeserializeContainerRegistryTimerT return new ContainerRegistryTimerTrigger(schedule, status, name, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Schedule), out propertyOverride); + if (Optional.IsDefined(Schedule) || hasPropertyOverride) + { + builder.Append(" schedule: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Schedule.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Schedule}'''"); + } + else + { + builder.AppendLine($"'{Schedule}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); + if (Optional.IsDefined(Status) || hasPropertyOverride) + { + builder.Append(" status: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Status.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -117,6 +192,8 @@ BinaryData IPersistableModel.Write(ModelReaderWri { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryTimerTrigger)} does not support '{options.Format}' format."); } @@ -133,6 +210,8 @@ ContainerRegistryTimerTrigger IPersistableModel.C using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerRegistryTimerTrigger(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerRegistryTimerTrigger)} does not support '{options.Format}' format."); } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTimerTrigger.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTimerTrigger.cs index b42f284d53996..0e2e1a5871013 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTimerTrigger.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTimerTrigger.cs @@ -78,10 +78,13 @@ internal ContainerRegistryTimerTrigger() } /// The CRON expression for the task schedule. + [WirePath("schedule")] public string Schedule { get; set; } /// The current status of trigger. + [WirePath("status")] public ContainerRegistryTriggerStatus? Status { get; set; } /// The name of the trigger. + [WirePath("name")] public string Name { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTimerTriggerDescriptor.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTimerTriggerDescriptor.Serialization.cs index 13ba90ca4e00f..0c664c8cf83ff 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTimerTriggerDescriptor.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTimerTriggerDescriptor.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -100,6 +102,65 @@ internal static ContainerRegistryTimerTriggerDescriptor DeserializeContainerRegi return new ContainerRegistryTimerTriggerDescriptor(timerTriggerName, scheduleOccurrence, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TimerTriggerName), out propertyOverride); + if (Optional.IsDefined(TimerTriggerName) || hasPropertyOverride) + { + builder.Append(" timerTriggerName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (TimerTriggerName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{TimerTriggerName}'''"); + } + else + { + builder.AppendLine($"'{TimerTriggerName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ScheduleOccurrence), out propertyOverride); + if (Optional.IsDefined(ScheduleOccurrence) || hasPropertyOverride) + { + builder.Append(" scheduleOccurrence: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ScheduleOccurrence.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ScheduleOccurrence}'''"); + } + else + { + builder.AppendLine($"'{ScheduleOccurrence}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -108,6 +169,8 @@ BinaryData IPersistableModel.Write(Mode { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryTimerTriggerDescriptor)} does not support '{options.Format}' format."); } @@ -124,6 +187,8 @@ ContainerRegistryTimerTriggerDescriptor IPersistableModel The timer trigger name that caused the run. + [WirePath("timerTriggerName")] public string TimerTriggerName { get; set; } /// The occurrence that triggered the run. + [WirePath("scheduleOccurrence")] public string ScheduleOccurrence { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTimerTriggerUpdateContent.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTimerTriggerUpdateContent.cs index c570948693566..4dfab5a191507 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTimerTriggerUpdateContent.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTimerTriggerUpdateContent.cs @@ -75,10 +75,13 @@ internal ContainerRegistryTimerTriggerUpdateContent() } /// The CRON expression for the task schedule. + [WirePath("schedule")] public string Schedule { get; set; } /// The current status of trigger. + [WirePath("status")] public ContainerRegistryTriggerStatus? Status { get; set; } /// The name of the trigger. + [WirePath("name")] public string Name { get; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTokenCertificate.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTokenCertificate.Serialization.cs index 67521f6d86664..8b74a0200ac47 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTokenCertificate.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTokenCertificate.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -130,6 +132,94 @@ internal static ContainerRegistryTokenCertificate DeserializeContainerRegistryTo return new ContainerRegistryTokenCertificate(name, expiry, thumbprint, encodedPemCertificate, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Name.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExpireOn), out propertyOverride); + if (Optional.IsDefined(ExpireOn) || hasPropertyOverride) + { + builder.Append(" expiry: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(ExpireOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Thumbprint), out propertyOverride); + if (Optional.IsDefined(Thumbprint) || hasPropertyOverride) + { + builder.Append(" thumbprint: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Thumbprint.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Thumbprint}'''"); + } + else + { + builder.AppendLine($"'{Thumbprint}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EncodedPemCertificate), out propertyOverride); + if (Optional.IsDefined(EncodedPemCertificate) || hasPropertyOverride) + { + builder.Append(" encodedPemCertificate: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (EncodedPemCertificate.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{EncodedPemCertificate}'''"); + } + else + { + builder.AppendLine($"'{EncodedPemCertificate}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -138,6 +228,8 @@ BinaryData IPersistableModel.Write(ModelReade { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryTokenCertificate)} does not support '{options.Format}' format."); } @@ -154,6 +246,8 @@ ContainerRegistryTokenCertificate IPersistableModel Gets or sets the name. + [WirePath("name")] public ContainerRegistryTokenCertificateName? Name { get; set; } /// The expiry datetime of the certificate. + [WirePath("expiry")] public DateTimeOffset? ExpireOn { get; set; } /// The thumbprint of the certificate. + [WirePath("thumbprint")] public string Thumbprint { get; set; } /// Base 64 encoded string of the public certificate1 in PEM format that will be used for authenticating the token. + [WirePath("encodedPemCertificate")] public string EncodedPemCertificate { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTokenCredentials.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTokenCredentials.Serialization.cs index ab6483cd028a3..6b29a518981c1 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTokenCredentials.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTokenCredentials.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -128,6 +131,65 @@ internal static ContainerRegistryTokenCredentials DeserializeContainerRegistryTo return new ContainerRegistryTokenCredentials(certificates ?? new ChangeTrackingList(), passwords ?? new ChangeTrackingList(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Certificates), out propertyOverride); + if (Optional.IsCollectionDefined(Certificates) || hasPropertyOverride) + { + if (Certificates.Any() || hasPropertyOverride) + { + builder.Append(" certificates: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Certificates) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " certificates: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Passwords), out propertyOverride); + if (Optional.IsCollectionDefined(Passwords) || hasPropertyOverride) + { + if (Passwords.Any() || hasPropertyOverride) + { + builder.Append(" passwords: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Passwords) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " passwords: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -136,6 +198,8 @@ BinaryData IPersistableModel.Write(ModelReade { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryTokenCredentials)} does not support '{options.Format}' format."); } @@ -152,6 +216,8 @@ ContainerRegistryTokenCredentials IPersistableModel Gets the certificates. + [WirePath("certificates")] public IList Certificates { get; } /// Gets the passwords. + [WirePath("passwords")] public IList Passwords { get; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTokenListResult.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTokenListResult.Serialization.cs index b7c8ad96e3591..2353ad50db189 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTokenListResult.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTokenListResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -114,6 +117,65 @@ internal static ContainerRegistryTokenListResult DeserializeContainerRegistryTok return new ContainerRegistryTokenListResult(value ?? new ChangeTrackingList(), nextLink, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (Optional.IsDefined(NextLink) || hasPropertyOverride) + { + builder.Append(" nextLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -122,6 +184,8 @@ BinaryData IPersistableModel.Write(ModelReader { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryTokenListResult)} does not support '{options.Format}' format."); } @@ -138,6 +202,8 @@ ContainerRegistryTokenListResult IPersistableModel propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); + if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) + { + builder.Append(" creationTime: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExpireOn), out propertyOverride); + if (Optional.IsDefined(ExpireOn) || hasPropertyOverride) + { + builder.Append(" expiry: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(ExpireOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Name.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsDefined(Value) || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Value}'''"); + } + else + { + builder.AppendLine($"'{Value}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -142,6 +225,8 @@ BinaryData IPersistableModel.Write(ModelReaderWr { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryTokenPassword)} does not support '{options.Format}' format."); } @@ -158,6 +243,8 @@ ContainerRegistryTokenPassword IPersistableModel using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerRegistryTokenPassword(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerRegistryTokenPassword)} does not support '{options.Format}' format."); } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTokenPassword.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTokenPassword.cs index 75af0c4550b3d..feed8fd7fb36d 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTokenPassword.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTokenPassword.cs @@ -66,12 +66,16 @@ internal ContainerRegistryTokenPassword(DateTimeOffset? createdOn, DateTimeOffse } /// The creation datetime of the password. + [WirePath("creationTime")] public DateTimeOffset? CreatedOn { get; set; } /// The expiry datetime of the password. + [WirePath("expiry")] public DateTimeOffset? ExpireOn { get; set; } /// The password name "password1" or "password2". + [WirePath("name")] public ContainerRegistryTokenPasswordName? Name { get; set; } /// The password value. + [WirePath("value")] public string Value { get; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTokenPatch.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTokenPatch.cs index 02f66b1674382..2b9c1761159f1 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTokenPatch.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTokenPatch.cs @@ -65,10 +65,13 @@ internal ContainerRegistryTokenPatch(ResourceIdentifier scopeMapId, ContainerReg } /// The resource ID of the scope map to which the token will be associated with. + [WirePath("properties.scopeMapId")] public ResourceIdentifier ScopeMapId { get; set; } /// The status of the token example enabled or disabled. + [WirePath("properties.status")] public ContainerRegistryTokenStatus? Status { get; set; } /// The credentials that can be used for authenticating the token. + [WirePath("properties.credentials")] public ContainerRegistryTokenCredentials Credentials { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTriggerProperties.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTriggerProperties.Serialization.cs index 911a2fa6ca0e0..c4832538079f8 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTriggerProperties.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTriggerProperties.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -143,6 +146,79 @@ internal static ContainerRegistryTriggerProperties DeserializeContainerRegistryT return new ContainerRegistryTriggerProperties(timerTriggers ?? new ChangeTrackingList(), sourceTriggers ?? new ChangeTrackingList(), baseImageTrigger, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TimerTriggers), out propertyOverride); + if (Optional.IsCollectionDefined(TimerTriggers) || hasPropertyOverride) + { + if (TimerTriggers.Any() || hasPropertyOverride) + { + builder.Append(" timerTriggers: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in TimerTriggers) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " timerTriggers: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SourceTriggers), out propertyOverride); + if (Optional.IsCollectionDefined(SourceTriggers) || hasPropertyOverride) + { + if (SourceTriggers.Any() || hasPropertyOverride) + { + builder.Append(" sourceTriggers: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in SourceTriggers) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " sourceTriggers: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BaseImageTrigger), out propertyOverride); + if (Optional.IsDefined(BaseImageTrigger) || hasPropertyOverride) + { + builder.Append(" baseImageTrigger: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, BaseImageTrigger, options, 2, false, " baseImageTrigger: "); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -151,6 +227,8 @@ BinaryData IPersistableModel.Write(ModelRead { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryTriggerProperties)} does not support '{options.Format}' format."); } @@ -167,6 +245,8 @@ ContainerRegistryTriggerProperties IPersistableModel } /// The collection of timer triggers. + [WirePath("timerTriggers")] public IList TimerTriggers { get; } /// The collection of triggers based on source code repository. + [WirePath("sourceTriggers")] public IList SourceTriggers { get; } /// The trigger based on base image dependencies. + [WirePath("baseImageTrigger")] public ContainerRegistryBaseImageTrigger BaseImageTrigger { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTriggerUpdateContent.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTriggerUpdateContent.cs index f23e415b70d39..886600b507cd1 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTriggerUpdateContent.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTriggerUpdateContent.cs @@ -67,10 +67,13 @@ internal ContainerRegistryTriggerUpdateContent(IList The collection of timer triggers. + [WirePath("timerTriggers")] public IList TimerTriggers { get; } /// The collection of triggers based on source code repository. + [WirePath("sourceTriggers")] public IList SourceTriggers { get; } /// The trigger based on base image dependencies. + [WirePath("baseImageTrigger")] public ContainerRegistryBaseImageTriggerUpdateContent BaseImageTrigger { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTrustPolicy.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTrustPolicy.Serialization.cs index 2ab217fa86395..0b9a1d009de8d 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTrustPolicy.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTrustPolicy.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -108,6 +110,49 @@ internal static ContainerRegistryTrustPolicy DeserializeContainerRegistryTrustPo return new ContainerRegistryTrustPolicy(type, status, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PolicyType), out propertyOverride); + if (Optional.IsDefined(PolicyType) || hasPropertyOverride) + { + builder.Append(" type: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{PolicyType.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); + if (Optional.IsDefined(Status) || hasPropertyOverride) + { + builder.Append(" status: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Status.Value.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -116,6 +161,8 @@ BinaryData IPersistableModel.Write(ModelReaderWrit { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryTrustPolicy)} does not support '{options.Format}' format."); } @@ -132,6 +179,8 @@ ContainerRegistryTrustPolicy IPersistableModel.Cre using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerRegistryTrustPolicy(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerRegistryTrustPolicy)} does not support '{options.Format}' format."); } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTrustPolicy.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTrustPolicy.cs index 90f938f2c1029..b292962de1c5e 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTrustPolicy.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryTrustPolicy.cs @@ -62,8 +62,10 @@ internal ContainerRegistryTrustPolicy(ContainerRegistryTrustPolicyType? policyTy } /// The type of trust policy. + [WirePath("type")] public ContainerRegistryTrustPolicyType? PolicyType { get; set; } /// The value that indicates whether the policy is enabled or not. + [WirePath("status")] public ContainerRegistryPolicyStatus? Status { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryUsage.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryUsage.Serialization.cs index 49c02babd82c8..b9d76f297be42 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryUsage.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryUsage.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -134,6 +136,85 @@ internal static ContainerRegistryUsage DeserializeContainerRegistryUsage(JsonEle return new ContainerRegistryUsage(name, limit, currentValue, unit, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Limit), out propertyOverride); + if (Optional.IsDefined(Limit) || hasPropertyOverride) + { + builder.Append(" limit: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Limit.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CurrentValue), out propertyOverride); + if (Optional.IsDefined(CurrentValue) || hasPropertyOverride) + { + builder.Append(" currentValue: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{CurrentValue.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Unit), out propertyOverride); + if (Optional.IsDefined(Unit) || hasPropertyOverride) + { + builder.Append(" unit: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Unit.Value.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -142,6 +223,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpti { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryUsage)} does not support '{options.Format}' format."); } @@ -158,6 +241,8 @@ ContainerRegistryUsage IPersistableModel.Create(BinaryDa using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerRegistryUsage(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerRegistryUsage)} does not support '{options.Format}' format."); } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryUsage.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryUsage.cs index 8b5fcdf15a3d8..0a4c356984e58 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryUsage.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryUsage.cs @@ -66,12 +66,16 @@ internal ContainerRegistryUsage(string name, long? limit, long? currentValue, Co } /// The name of the usage. + [WirePath("name")] public string Name { get; } /// The limit of the usage. + [WirePath("limit")] public long? Limit { get; } /// The current value of the usage. + [WirePath("currentValue")] public long? CurrentValue { get; } /// The unit of measurement. + [WirePath("unit")] public ContainerRegistryUsageUnit? Unit { get; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryUsageListResult.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryUsageListResult.Serialization.cs index 4c4ae29b366b5..371ff51952bb5 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryUsageListResult.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryUsageListResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -103,6 +106,43 @@ internal static ContainerRegistryUsageListResult DeserializeContainerRegistryUsa return new ContainerRegistryUsageListResult(value ?? new ChangeTrackingList(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -111,6 +151,8 @@ BinaryData IPersistableModel.Write(ModelReader { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryUsageListResult)} does not support '{options.Format}' format."); } @@ -127,6 +169,8 @@ ContainerRegistryUsageListResult IPersistableModel } /// The list of container registry quota usages. + [WirePath("value")] public IReadOnlyList Value { get; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookCallbackConfig.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookCallbackConfig.Serialization.cs index f690b3525b1d4..c9f75d682b784 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookCallbackConfig.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookCallbackConfig.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -112,6 +115,71 @@ internal static ContainerRegistryWebhookCallbackConfig DeserializeContainerRegis return new ContainerRegistryWebhookCallbackConfig(serviceUri, customHeaders ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ServiceUri), out propertyOverride); + if (Optional.IsDefined(ServiceUri) || hasPropertyOverride) + { + builder.Append(" serviceUri: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ServiceUri.AbsoluteUri}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CustomHeaders), out propertyOverride); + if (Optional.IsCollectionDefined(CustomHeaders) || hasPropertyOverride) + { + if (CustomHeaders.Any() || hasPropertyOverride) + { + builder.Append(" customHeaders: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("{"); + foreach (var item in CustomHeaders) + { + builder.Append($" '{item.Key}': "); + if (item.Value == null) + { + builder.Append("null"); + continue; + } + if (item.Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{item.Value}'''"); + } + else + { + builder.AppendLine($"'{item.Value}'"); + } + } + builder.AppendLine(" }"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -120,6 +188,8 @@ BinaryData IPersistableModel.Write(Model { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryWebhookCallbackConfig)} does not support '{options.Format}' format."); } @@ -136,6 +206,8 @@ ContainerRegistryWebhookCallbackConfig IPersistableModel The service URI for the webhook to post notifications. + [WirePath("serviceUri")] public Uri ServiceUri { get; } /// Custom headers that will be added to the webhook notifications. + [WirePath("customHeaders")] public IReadOnlyDictionary CustomHeaders { get; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookCreateOrUpdateContent.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookCreateOrUpdateContent.cs index 8be9229eff134..e096c0259f4dd 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookCreateOrUpdateContent.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookCreateOrUpdateContent.cs @@ -84,18 +84,25 @@ internal ContainerRegistryWebhookCreateOrUpdateContent() } /// The tags for the webhook. + [WirePath("tags")] public IDictionary Tags { get; } /// The location of the webhook. This cannot be changed after the resource is created. + [WirePath("location")] public AzureLocation Location { get; } /// The service URI for the webhook to post notifications. + [WirePath("properties.serviceUri")] public Uri ServiceUri { get; set; } /// Custom headers that will be added to the webhook notifications. + [WirePath("properties.customHeaders")] public IDictionary CustomHeaders { get; } /// The status of the webhook at the time the operation was called. + [WirePath("properties.status")] public ContainerRegistryWebhookStatus? Status { get; set; } /// The scope of repositories where the event can be triggered. For example, 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' only. 'foo' is equivalent to 'foo:latest'. Empty means all events. + [WirePath("properties.scope")] public string Scope { get; set; } /// The list of actions that trigger the webhook to post notifications. + [WirePath("properties.actions")] public IList Actions { get; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookEvent.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookEvent.Serialization.cs index 2a31661f26a4b..4f6a34ac12f0e 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookEvent.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookEvent.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -123,6 +125,63 @@ internal static ContainerRegistryWebhookEvent DeserializeContainerRegistryWebhoo return new ContainerRegistryWebhookEvent(id, serializedAdditionalRawData, eventRequestMessage, eventResponseMessage); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EventRequestMessage), out propertyOverride); + if (Optional.IsDefined(EventRequestMessage) || hasPropertyOverride) + { + builder.Append(" eventRequestMessage: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, EventRequestMessage, options, 2, false, " eventRequestMessage: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EventResponseMessage), out propertyOverride); + if (Optional.IsDefined(EventResponseMessage) || hasPropertyOverride) + { + builder.Append(" eventResponseMessage: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, EventResponseMessage, options, 2, false, " eventResponseMessage: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.Value.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -131,6 +190,8 @@ BinaryData IPersistableModel.Write(ModelReaderWri { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryWebhookEvent)} does not support '{options.Format}' format."); } @@ -147,6 +208,8 @@ ContainerRegistryWebhookEvent IPersistableModel.C using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerRegistryWebhookEvent(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerRegistryWebhookEvent)} does not support '{options.Format}' format."); } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookEvent.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookEvent.cs index 3650c2bd584a9..c87a100121646 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookEvent.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookEvent.cs @@ -30,8 +30,10 @@ internal ContainerRegistryWebhookEvent(Guid? id, IDictionary } /// The event request message sent to the service URI. + [WirePath("eventRequestMessage")] public ContainerRegistryWebhookEventRequestMessage EventRequestMessage { get; } /// The event response message received from the service URI. + [WirePath("eventResponseMessage")] public ContainerRegistryWebhookEventResponseMessage EventResponseMessage { get; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookEventActor.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookEventActor.Serialization.cs index 47b410c37c4f1..13a14e7c8b648 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookEventActor.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookEventActor.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -89,6 +91,43 @@ internal static ContainerRegistryWebhookEventActor DeserializeContainerRegistryW return new ContainerRegistryWebhookEventActor(name, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -97,6 +136,8 @@ BinaryData IPersistableModel.Write(ModelRead { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryWebhookEventActor)} does not support '{options.Format}' format."); } @@ -113,6 +154,8 @@ ContainerRegistryWebhookEventActor IPersistableModel The subject or username associated with the request context that generated the event. + [WirePath("name")] public string Name { get; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookEventContent.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookEventContent.Serialization.cs index 3a584bb227f72..1b56205d6f412 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookEventContent.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookEventContent.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -187,6 +189,128 @@ internal static ContainerRegistryWebhookEventContent DeserializeContainerRegistr serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Timestamp), out propertyOverride); + if (Optional.IsDefined(Timestamp) || hasPropertyOverride) + { + builder.Append(" timestamp: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(Timestamp.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Action), out propertyOverride); + if (Optional.IsDefined(Action) || hasPropertyOverride) + { + builder.Append(" action: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Action.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Action}'''"); + } + else + { + builder.AppendLine($"'{Action}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Target), out propertyOverride); + if (Optional.IsDefined(Target) || hasPropertyOverride) + { + builder.Append(" target: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, Target, options, 2, false, " target: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Request), out propertyOverride); + if (Optional.IsDefined(Request) || hasPropertyOverride) + { + builder.Append(" request: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, Request, options, 2, false, " request: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Actor), out propertyOverride); + if (Optional.IsDefined(Actor) || hasPropertyOverride) + { + builder.Append(" actor: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, Actor, options, 2, false, " actor: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Source), out propertyOverride); + if (Optional.IsDefined(Source) || hasPropertyOverride) + { + builder.Append(" source: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, Source, options, 2, false, " source: "); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -195,6 +319,8 @@ BinaryData IPersistableModel.Write(ModelRe { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryWebhookEventContent)} does not support '{options.Format}' format."); } @@ -211,6 +337,8 @@ ContainerRegistryWebhookEventContent IPersistableModel The event ID. + [WirePath("id")] public Guid? Id { get; } /// The time at which the event occurred. + [WirePath("timestamp")] public DateTimeOffset? Timestamp { get; } /// The action that encompasses the provided event. + [WirePath("action")] public string Action { get; } /// The target of the event. + [WirePath("target")] public ContainerRegistryWebhookEventTarget Target { get; } /// The request that generated the event. + [WirePath("request")] public ContainerRegistryWebhookEventRequestContent Request { get; } /// The agent that initiated the event. For most situations, this could be from the authorization context of the request. internal ContainerRegistryWebhookEventActor Actor { get; } /// The subject or username associated with the request context that generated the event. + [WirePath("actor.name")] public string ActorName { get => Actor?.Name; } /// The registry node that generated the event. Put differently, while the actor initiates the event, the source generates it. + [WirePath("source")] public ContainerRegistryWebhookEventSource Source { get; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookEventInfo.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookEventInfo.Serialization.cs index b8d709ece7dea..d7d056235d073 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookEventInfo.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookEventInfo.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -93,6 +95,35 @@ internal static ContainerRegistryWebhookEventInfo DeserializeContainerRegistryWe return new ContainerRegistryWebhookEventInfo(id, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.Value.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -101,6 +132,8 @@ BinaryData IPersistableModel.Write(ModelReade { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryWebhookEventInfo)} does not support '{options.Format}' format."); } @@ -117,6 +150,8 @@ ContainerRegistryWebhookEventInfo IPersistableModel The event ID. + [WirePath("id")] public Guid? Id { get; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookEventListResult.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookEventListResult.Serialization.cs index abc6ee388b159..53894627d433a 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookEventListResult.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookEventListResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -114,6 +117,65 @@ internal static ContainerRegistryWebhookEventListResult DeserializeContainerRegi return new ContainerRegistryWebhookEventListResult(value ?? new ChangeTrackingList(), nextLink, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (Optional.IsDefined(NextLink) || hasPropertyOverride) + { + builder.Append(" nextLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -122,6 +184,8 @@ BinaryData IPersistableModel.Write(Mode { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryWebhookEventListResult)} does not support '{options.Format}' format."); } @@ -138,6 +202,8 @@ ContainerRegistryWebhookEventListResult IPersistableModel propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Addr), out propertyOverride); + if (Optional.IsDefined(Addr) || hasPropertyOverride) + { + builder.Append(" addr: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Addr.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Addr}'''"); + } + else + { + builder.AppendLine($"'{Addr}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Host), out propertyOverride); + if (Optional.IsDefined(Host) || hasPropertyOverride) + { + builder.Append(" host: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Host.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Host}'''"); + } + else + { + builder.AppendLine($"'{Host}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Method), out propertyOverride); + if (Optional.IsDefined(Method) || hasPropertyOverride) + { + builder.Append(" method: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Method.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Method}'''"); + } + else + { + builder.AppendLine($"'{Method}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(UserAgent), out propertyOverride); + if (Optional.IsDefined(UserAgent) || hasPropertyOverride) + { + builder.Append(" useragent: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (UserAgent.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{UserAgent}'''"); + } + else + { + builder.AppendLine($"'{UserAgent}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -151,6 +270,8 @@ BinaryData IPersistableModel.Write( { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryWebhookEventRequestContent)} does not support '{options.Format}' format."); } @@ -167,6 +288,8 @@ ContainerRegistryWebhookEventRequestContent IPersistableModel The ID of the request that initiated the event. + [WirePath("id")] public Guid? Id { get; } /// The IP or hostname and possibly port of the client connection that initiated the event. This is the RemoteAddr from the standard http request. + [WirePath("addr")] public string Addr { get; } /// The externally accessible hostname of the registry instance, as specified by the http host header on incoming requests. + [WirePath("host")] public string Host { get; } /// The request method that generated the event. + [WirePath("method")] public string Method { get; } /// The user agent header of the request. + [WirePath("useragent")] public string UserAgent { get; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookEventRequestMessage.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookEventRequestMessage.Serialization.cs index 737f0ae88f4f3..17ea631b0eee1 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookEventRequestMessage.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookEventRequestMessage.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -162,6 +165,129 @@ internal static ContainerRegistryWebhookEventRequestMessage DeserializeContainer serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Content), out propertyOverride); + if (Optional.IsDefined(Content) || hasPropertyOverride) + { + builder.Append(" content: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, Content, options, 2, false, " content: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Headers), out propertyOverride); + if (Optional.IsCollectionDefined(Headers) || hasPropertyOverride) + { + if (Headers.Any() || hasPropertyOverride) + { + builder.Append(" headers: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("{"); + foreach (var item in Headers) + { + builder.Append($" '{item.Key}': "); + if (item.Value == null) + { + builder.Append("null"); + continue; + } + if (item.Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{item.Value}'''"); + } + else + { + builder.AppendLine($"'{item.Value}'"); + } + } + builder.AppendLine(" }"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Method), out propertyOverride); + if (Optional.IsDefined(Method) || hasPropertyOverride) + { + builder.Append(" method: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Method.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Method}'''"); + } + else + { + builder.AppendLine($"'{Method}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RequestUri), out propertyOverride); + if (Optional.IsDefined(RequestUri) || hasPropertyOverride) + { + builder.Append(" requestUri: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{RequestUri.AbsoluteUri}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Version), out propertyOverride); + if (Optional.IsDefined(Version) || hasPropertyOverride) + { + builder.Append(" version: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Version.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Version}'''"); + } + else + { + builder.AppendLine($"'{Version}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -170,6 +296,8 @@ BinaryData IPersistableModel.Write( { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryWebhookEventRequestMessage)} does not support '{options.Format}' format."); } @@ -186,6 +314,8 @@ ContainerRegistryWebhookEventRequestMessage IPersistableModel The content of the event request message. + [WirePath("content")] public ContainerRegistryWebhookEventContent Content { get; } /// The headers of the event request message. + [WirePath("headers")] public IReadOnlyDictionary Headers { get; } /// The HTTP method used to send the event request message. + [WirePath("method")] public string Method { get; } /// The URI used to send the event request message. + [WirePath("requestUri")] public Uri RequestUri { get; } /// The HTTP message version. + [WirePath("version")] public string Version { get; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookEventResponseMessage.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookEventResponseMessage.Serialization.cs index c6de0c41410b9..6aaff83dc5bd2 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookEventResponseMessage.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookEventResponseMessage.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -154,6 +157,145 @@ internal static ContainerRegistryWebhookEventResponseMessage DeserializeContaine serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Content), out propertyOverride); + if (Optional.IsDefined(Content) || hasPropertyOverride) + { + builder.Append(" content: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Content.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Content}'''"); + } + else + { + builder.AppendLine($"'{Content}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Headers), out propertyOverride); + if (Optional.IsCollectionDefined(Headers) || hasPropertyOverride) + { + if (Headers.Any() || hasPropertyOverride) + { + builder.Append(" headers: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("{"); + foreach (var item in Headers) + { + builder.Append($" '{item.Key}': "); + if (item.Value == null) + { + builder.Append("null"); + continue; + } + if (item.Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{item.Value}'''"); + } + else + { + builder.AppendLine($"'{item.Value}'"); + } + } + builder.AppendLine(" }"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ReasonPhrase), out propertyOverride); + if (Optional.IsDefined(ReasonPhrase) || hasPropertyOverride) + { + builder.Append(" reasonPhrase: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ReasonPhrase.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ReasonPhrase}'''"); + } + else + { + builder.AppendLine($"'{ReasonPhrase}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StatusCode), out propertyOverride); + if (Optional.IsDefined(StatusCode) || hasPropertyOverride) + { + builder.Append(" statusCode: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (StatusCode.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{StatusCode}'''"); + } + else + { + builder.AppendLine($"'{StatusCode}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Version), out propertyOverride); + if (Optional.IsDefined(Version) || hasPropertyOverride) + { + builder.Append(" version: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Version.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Version}'''"); + } + else + { + builder.AppendLine($"'{Version}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -162,6 +304,8 @@ BinaryData IPersistableModel.Write { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryWebhookEventResponseMessage)} does not support '{options.Format}' format."); } @@ -178,6 +322,8 @@ ContainerRegistryWebhookEventResponseMessage IPersistableModel The content of the event response message. + [WirePath("content")] public string Content { get; } /// The headers of the event response message. + [WirePath("headers")] public IReadOnlyDictionary Headers { get; } /// The reason phrase of the event response message. + [WirePath("reasonPhrase")] public string ReasonPhrase { get; } /// The status code of the event response message. + [WirePath("statusCode")] public string StatusCode { get; } /// The HTTP message version. + [WirePath("version")] public string Version { get; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookEventSource.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookEventSource.Serialization.cs index 7900cbeb46ad2..0109428972aa5 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookEventSource.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookEventSource.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -100,6 +102,65 @@ internal static ContainerRegistryWebhookEventSource DeserializeContainerRegistry return new ContainerRegistryWebhookEventSource(addr, instanceId, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Addr), out propertyOverride); + if (Optional.IsDefined(Addr) || hasPropertyOverride) + { + builder.Append(" addr: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Addr.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Addr}'''"); + } + else + { + builder.AppendLine($"'{Addr}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(InstanceId), out propertyOverride); + if (Optional.IsDefined(InstanceId) || hasPropertyOverride) + { + builder.Append(" instanceID: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (InstanceId.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{InstanceId}'''"); + } + else + { + builder.AppendLine($"'{InstanceId}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -108,6 +169,8 @@ BinaryData IPersistableModel.Write(ModelRea { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryWebhookEventSource)} does not support '{options.Format}' format."); } @@ -124,6 +187,8 @@ ContainerRegistryWebhookEventSource IPersistableModel The IP or hostname and the port of the registry node that generated the event. Generally, this will be resolved by os.Hostname() along with the running port. + [WirePath("addr")] public string Addr { get; } /// The running instance of an application. Changes after each restart. + [WirePath("instanceID")] public string InstanceId { get; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookEventTarget.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookEventTarget.Serialization.cs index 59b2b7851c1fd..8c46e06f00a50 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookEventTarget.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookEventTarget.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -199,6 +201,195 @@ internal static ContainerRegistryWebhookEventTarget DeserializeContainerRegistry serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MediaType), out propertyOverride); + if (Optional.IsDefined(MediaType) || hasPropertyOverride) + { + builder.Append(" mediaType: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (MediaType.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{MediaType}'''"); + } + else + { + builder.AppendLine($"'{MediaType}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Size), out propertyOverride); + if (Optional.IsDefined(Size) || hasPropertyOverride) + { + builder.Append(" size: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Size.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Digest), out propertyOverride); + if (Optional.IsDefined(Digest) || hasPropertyOverride) + { + builder.Append(" digest: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Digest.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Digest}'''"); + } + else + { + builder.AppendLine($"'{Digest}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Length), out propertyOverride); + if (Optional.IsDefined(Length) || hasPropertyOverride) + { + builder.Append(" length: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Length.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Repository), out propertyOverride); + if (Optional.IsDefined(Repository) || hasPropertyOverride) + { + builder.Append(" repository: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Repository.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Repository}'''"); + } + else + { + builder.AppendLine($"'{Repository}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Uri), out propertyOverride); + if (Optional.IsDefined(Uri) || hasPropertyOverride) + { + builder.Append(" url: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Uri.AbsoluteUri}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tag), out propertyOverride); + if (Optional.IsDefined(Tag) || hasPropertyOverride) + { + builder.Append(" tag: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Tag.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Tag}'''"); + } + else + { + builder.AppendLine($"'{Tag}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Version), out propertyOverride); + if (Optional.IsDefined(Version) || hasPropertyOverride) + { + builder.Append(" version: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Version.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Version}'''"); + } + else + { + builder.AppendLine($"'{Version}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -207,6 +398,8 @@ BinaryData IPersistableModel.Write(ModelRea { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryWebhookEventTarget)} does not support '{options.Format}' format."); } @@ -223,6 +416,8 @@ ContainerRegistryWebhookEventTarget IPersistableModel The MIME type of the referenced object. + [WirePath("mediaType")] public string MediaType { get; } /// The number of bytes of the content. Same as Length field. + [WirePath("size")] public long? Size { get; } /// The digest of the content, as defined by the Registry V2 HTTP API Specification. + [WirePath("digest")] public string Digest { get; } /// The number of bytes of the content. Same as Size field. + [WirePath("length")] public long? Length { get; } /// The repository name. + [WirePath("repository")] public string Repository { get; } /// The direct URL to the content. + [WirePath("url")] public Uri Uri { get; } /// The tag name. + [WirePath("tag")] public string Tag { get; } /// The name of the artifact. + [WirePath("name")] public string Name { get; } /// The version of the artifact. + [WirePath("version")] public string Version { get; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookListResult.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookListResult.Serialization.cs index 419115edbc201..4c9770ec7f28d 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookListResult.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ContainerRegistryWebhookListResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -114,6 +117,65 @@ internal static ContainerRegistryWebhookListResult DeserializeContainerRegistryW return new ContainerRegistryWebhookListResult(value ?? new ChangeTrackingList(), nextLink, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (Optional.IsDefined(NextLink) || hasPropertyOverride) + { + builder.Append(" nextLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -122,6 +184,8 @@ BinaryData IPersistableModel.Write(ModelRead { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryWebhookListResult)} does not support '{options.Format}' format."); } @@ -138,6 +202,8 @@ ContainerRegistryWebhookListResult IPersistableModel tags, Uri ser } /// The tags for the webhook. + [WirePath("tags")] public IDictionary Tags { get; } /// The service URI for the webhook to post notifications. + [WirePath("properties.serviceUri")] public Uri ServiceUri { get; set; } /// Custom headers that will be added to the webhook notifications. + [WirePath("properties.customHeaders")] public IDictionary CustomHeaders { get; } /// The status of the webhook at the time the operation was called. + [WirePath("properties.status")] public ContainerRegistryWebhookStatus? Status { get; set; } /// The scope of repositories where the event can be triggered. For example, 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' only. 'foo' is equivalent to 'foo:latest'. Empty means all events. + [WirePath("properties.scope")] public string Scope { get; set; } /// The list of actions that trigger the webhook to post notifications. + [WirePath("properties.actions")] public IList Actions { get; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/CustomRegistryCredentials.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/CustomRegistryCredentials.Serialization.cs index a50bc73e71763..77f41f6cddf7a 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/CustomRegistryCredentials.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/CustomRegistryCredentials.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -119,6 +121,71 @@ internal static CustomRegistryCredentials DeserializeCustomRegistryCredentials(J return new CustomRegistryCredentials(userName, password, identity, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(UserName), out propertyOverride); + if (Optional.IsDefined(UserName) || hasPropertyOverride) + { + builder.Append(" userName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, UserName, options, 2, false, " userName: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Password), out propertyOverride); + if (Optional.IsDefined(Password) || hasPropertyOverride) + { + builder.Append(" password: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, Password, options, 2, false, " password: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Identity), out propertyOverride); + if (Optional.IsDefined(Identity) || hasPropertyOverride) + { + builder.Append(" identity: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Identity.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Identity}'''"); + } + else + { + builder.AppendLine($"'{Identity}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -127,6 +194,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterO { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(CustomRegistryCredentials)} does not support '{options.Format}' format."); } @@ -143,6 +212,8 @@ CustomRegistryCredentials IPersistableModel.Create(Bi using JsonDocument document = JsonDocument.Parse(data); return DeserializeCustomRegistryCredentials(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(CustomRegistryCredentials)} does not support '{options.Format}' format."); } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/CustomRegistryCredentials.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/CustomRegistryCredentials.cs index 4ee2f6b177ea7..a52e9480ab7f4 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/CustomRegistryCredentials.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/CustomRegistryCredentials.cs @@ -73,11 +73,13 @@ internal CustomRegistryCredentials(ContainerRegistrySecretObject userName, Conta } /// The username for logging into the custom registry. + [WirePath("userName")] public ContainerRegistrySecretObject UserName { get; set; } /// /// The password for logging into the custom registry. The password is a secret /// object that allows multiple ways of providing the value for it. /// + [WirePath("password")] public ContainerRegistrySecretObject Password { get; set; } /// /// Indicates the managed identity assigned to the custom credential. If a user-assigned identity @@ -86,6 +88,7 @@ internal CustomRegistryCredentials(ContainerRegistrySecretObject userName, Conta /// identity may be used to authenticate to key vault to retrieve credentials or it may be the only /// source of authentication used for accessing the registry. /// + [WirePath("identity")] public string Identity { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ScopeMapListResult.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ScopeMapListResult.Serialization.cs index 16d69ec3f9129..45012782bae32 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ScopeMapListResult.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ScopeMapListResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -114,6 +117,65 @@ internal static ScopeMapListResult DeserializeScopeMapListResult(JsonElement ele return new ScopeMapListResult(value ?? new ChangeTrackingList(), nextLink, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (Optional.IsDefined(NextLink) || hasPropertyOverride) + { + builder.Append(" nextLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -122,6 +184,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ScopeMapListResult)} does not support '{options.Format}' format."); } @@ -138,6 +202,8 @@ ScopeMapListResult IPersistableModel.Create(BinaryData data, using JsonDocument document = JsonDocument.Parse(data); return DeserializeScopeMapListResult(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ScopeMapListResult)} does not support '{options.Format}' format."); } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ScopeMapPatch.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ScopeMapPatch.cs index be1f5d269790f..78e6bf2db4821 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ScopeMapPatch.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/ScopeMapPatch.cs @@ -68,12 +68,14 @@ internal ScopeMapPatch(string description, IList actions, IDictionary The user friendly description of the scope map. + [WirePath("properties.description")] public string Description { get; set; } /// /// The list of scope permissions for registry artifacts. /// E.g. repositories/repository-name/pull, /// repositories/repository-name/delete /// + [WirePath("properties.actions")] public IList Actions { get; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/SourceCodeRepoAuthInfo.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/SourceCodeRepoAuthInfo.Serialization.cs index e50afed3eaee1..3eb6e89cbb039 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/SourceCodeRepoAuthInfo.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/SourceCodeRepoAuthInfo.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -137,6 +139,112 @@ internal static SourceCodeRepoAuthInfo DeserializeSourceCodeRepoAuthInfo(JsonEle serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TokenType), out propertyOverride); + builder.Append(" tokenType: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{TokenType.ToString()}'"); + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Token), out propertyOverride); + if (Optional.IsDefined(Token) || hasPropertyOverride) + { + builder.Append(" token: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Token.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Token}'''"); + } + else + { + builder.AppendLine($"'{Token}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RefreshToken), out propertyOverride); + if (Optional.IsDefined(RefreshToken) || hasPropertyOverride) + { + builder.Append(" refreshToken: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (RefreshToken.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{RefreshToken}'''"); + } + else + { + builder.AppendLine($"'{RefreshToken}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Scope), out propertyOverride); + if (Optional.IsDefined(Scope) || hasPropertyOverride) + { + builder.Append(" scope: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Scope.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Scope}'''"); + } + else + { + builder.AppendLine($"'{Scope}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExpireInSeconds), out propertyOverride); + if (Optional.IsDefined(ExpireInSeconds) || hasPropertyOverride) + { + builder.Append(" expiresIn: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{ExpireInSeconds.Value}"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -145,6 +253,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpti { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(SourceCodeRepoAuthInfo)} does not support '{options.Format}' format."); } @@ -161,6 +271,8 @@ SourceCodeRepoAuthInfo IPersistableModel.Create(BinaryDa using JsonDocument document = JsonDocument.Parse(data); return DeserializeSourceCodeRepoAuthInfo(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(SourceCodeRepoAuthInfo)} does not support '{options.Format}' format."); } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/SourceCodeRepoAuthInfo.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/SourceCodeRepoAuthInfo.cs index 1a1dfad1ac567..a1b1b0cb05254 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/SourceCodeRepoAuthInfo.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/SourceCodeRepoAuthInfo.cs @@ -81,14 +81,19 @@ internal SourceCodeRepoAuthInfo() } /// The type of Auth token. + [WirePath("tokenType")] public SourceCodeRepoAuthTokenType TokenType { get; set; } /// The access token used to access the source control provider. + [WirePath("token")] public string Token { get; set; } /// The refresh token used to refresh the access token. + [WirePath("refreshToken")] public string RefreshToken { get; set; } /// The scope of the access token. + [WirePath("scope")] public string Scope { get; set; } /// Time in seconds that the token remains valid. + [WirePath("expiresIn")] public int? ExpireInSeconds { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/SourceCodeRepoAuthInfoUpdateContent.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/SourceCodeRepoAuthInfoUpdateContent.cs index bc4701fc397cf..9d4a0e210ec7e 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/SourceCodeRepoAuthInfoUpdateContent.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/SourceCodeRepoAuthInfoUpdateContent.cs @@ -68,14 +68,19 @@ internal SourceCodeRepoAuthInfoUpdateContent(SourceCodeRepoAuthTokenType? tokenT } /// The type of Auth token. + [WirePath("tokenType")] public SourceCodeRepoAuthTokenType? TokenType { get; set; } /// The access token used to access the source control provider. + [WirePath("token")] public string Token { get; set; } /// The refresh token used to refresh the access token. + [WirePath("refreshToken")] public string RefreshToken { get; set; } /// The scope of the access token. + [WirePath("scope")] public string Scope { get; set; } /// Time in seconds that the token remains valid. + [WirePath("expiresIn")] public int? ExpiresIn { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/SourceCodeRepoProperties.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/SourceCodeRepoProperties.Serialization.cs index 47911394ce255..a8f0c6d772c79 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/SourceCodeRepoProperties.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/SourceCodeRepoProperties.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -120,6 +122,82 @@ internal static SourceCodeRepoProperties DeserializeSourceCodeRepoProperties(Jso return new SourceCodeRepoProperties(sourceControlType, repositoryUrl, branch, sourceControlAuthProperties, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SourceControlType), out propertyOverride); + builder.Append(" sourceControlType: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SourceControlType.ToString()}'"); + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RepositoryUri), out propertyOverride); + if (Optional.IsDefined(RepositoryUri) || hasPropertyOverride) + { + builder.Append(" repositoryUrl: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{RepositoryUri.AbsoluteUri}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Branch), out propertyOverride); + if (Optional.IsDefined(Branch) || hasPropertyOverride) + { + builder.Append(" branch: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Branch.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Branch}'''"); + } + else + { + builder.AppendLine($"'{Branch}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SourceControlAuthProperties), out propertyOverride); + if (Optional.IsDefined(SourceControlAuthProperties) || hasPropertyOverride) + { + builder.Append(" sourceControlAuthProperties: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + BicepSerializationHelpers.AppendChildObject(builder, SourceControlAuthProperties, options, 2, false, " sourceControlAuthProperties: "); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -128,6 +206,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOp { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(SourceCodeRepoProperties)} does not support '{options.Format}' format."); } @@ -144,6 +224,8 @@ SourceCodeRepoProperties IPersistableModel.Create(Bina using JsonDocument document = JsonDocument.Parse(data); return DeserializeSourceCodeRepoProperties(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(SourceCodeRepoProperties)} does not support '{options.Format}' format."); } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/SourceCodeRepoProperties.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/SourceCodeRepoProperties.cs index 5cd1ce27f4be8..81429dc261c84 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/SourceCodeRepoProperties.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/SourceCodeRepoProperties.cs @@ -82,15 +82,19 @@ internal SourceCodeRepoProperties() } /// The type of source control service. + [WirePath("sourceControlType")] public SourceControlType SourceControlType { get; set; } /// The full URL to the source code repository. + [WirePath("repositoryUrl")] public Uri RepositoryUri { get; set; } /// The branch name of the source code. + [WirePath("branch")] public string Branch { get; set; } /// /// The authorization properties for accessing the source code repository and to set up /// webhooks for notifications. /// + [WirePath("sourceControlAuthProperties")] public SourceCodeRepoAuthInfo SourceControlAuthProperties { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/SourceCodeRepoUpdateContent.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/SourceCodeRepoUpdateContent.cs index cfc59e1374808..fd72c276851bb 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/SourceCodeRepoUpdateContent.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/SourceCodeRepoUpdateContent.cs @@ -69,15 +69,19 @@ internal SourceCodeRepoUpdateContent(SourceControlType? sourceControlType, Uri r } /// The type of source control service. + [WirePath("sourceControlType")] public SourceControlType? SourceControlType { get; set; } /// The full URL to the source code repository. + [WirePath("repositoryUrl")] public Uri RepositoryUri { get; set; } /// The branch name of the source code. + [WirePath("branch")] public string Branch { get; set; } /// /// The authorization properties for accessing the source code repository and to set up /// webhooks for notifications. /// + [WirePath("sourceControlAuthProperties")] public SourceCodeRepoAuthInfoUpdateContent SourceControlAuthProperties { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/SourceRegistryCredentials.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/SourceRegistryCredentials.Serialization.cs index 9bba5d0beaa3f..4e99acb00dfc1 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/SourceRegistryCredentials.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/SourceRegistryCredentials.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -93,6 +95,35 @@ internal static SourceRegistryCredentials DeserializeSourceRegistryCredentials(J return new SourceRegistryCredentials(loginMode, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LoginMode), out propertyOverride); + if (Optional.IsDefined(LoginMode) || hasPropertyOverride) + { + builder.Append(" loginMode: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{LoginMode.Value.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -101,6 +132,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterO { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(SourceRegistryCredentials)} does not support '{options.Format}' format."); } @@ -117,6 +150,8 @@ SourceRegistryCredentials IPersistableModel.Create(Bi using JsonDocument document = JsonDocument.Parse(data); return DeserializeSourceRegistryCredentials(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(SourceRegistryCredentials)} does not support '{options.Format}' format."); } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/SourceRegistryCredentials.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/SourceRegistryCredentials.cs index e2263869d7dad..d89f8a5c03fcf 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/SourceRegistryCredentials.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/SourceRegistryCredentials.cs @@ -68,6 +68,7 @@ internal SourceRegistryCredentials(SourceRegistryLoginMode? loginMode, IDictiona /// will be generated using the given scope. These credentials will be used to login to /// the source registry during the run. /// + [WirePath("loginMode")] public SourceRegistryLoginMode? LoginMode { get; set; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/SourceUploadDefinition.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/SourceUploadDefinition.Serialization.cs index 01916d760bf9e..742b938c3ec35 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/SourceUploadDefinition.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/SourceUploadDefinition.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -104,6 +106,57 @@ internal static SourceUploadDefinition DeserializeSourceUploadDefinition(JsonEle return new SourceUploadDefinition(uploadUrl, relativePath, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(UploadUri), out propertyOverride); + if (Optional.IsDefined(UploadUri) || hasPropertyOverride) + { + builder.Append(" uploadUrl: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{UploadUri.AbsoluteUri}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RelativePath), out propertyOverride); + if (Optional.IsDefined(RelativePath) || hasPropertyOverride) + { + builder.Append(" relativePath: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (RelativePath.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{RelativePath}'''"); + } + else + { + builder.AppendLine($"'{RelativePath}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -112,6 +165,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpti { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(SourceUploadDefinition)} does not support '{options.Format}' format."); } @@ -128,6 +183,8 @@ SourceUploadDefinition IPersistableModel.Create(BinaryDa using JsonDocument document = JsonDocument.Parse(data); return DeserializeSourceUploadDefinition(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(SourceUploadDefinition)} does not support '{options.Format}' format."); } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/SourceUploadDefinition.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/SourceUploadDefinition.cs index 5ea4b01d34b1c..053c8d1eebbd4 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/SourceUploadDefinition.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/SourceUploadDefinition.cs @@ -62,8 +62,10 @@ internal SourceUploadDefinition(Uri uploadUri, string relativePath, IDictionary< } /// The URL where the client can upload the source. + [WirePath("uploadUrl")] public Uri UploadUri { get; } /// The relative path to the source. This is used to submit the subsequent queue build request. + [WirePath("relativePath")] public string RelativePath { get; } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/UnknownRunRequest.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/UnknownRunRequest.Serialization.cs index 878b62d0a7d84..699a5a33fda86 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/UnknownRunRequest.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/UnknownRunRequest.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -123,6 +125,102 @@ internal static UnknownRunRequest DeserializeUnknownRunRequest(JsonElement eleme return new UnknownRunRequest(type, isArchiveEnabled, agentPoolName, logTemplate, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RunRequestType), out propertyOverride); + if (Optional.IsDefined(RunRequestType) || hasPropertyOverride) + { + builder.Append(" type: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (RunRequestType.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{RunRequestType}'''"); + } + else + { + builder.AppendLine($"'{RunRequestType}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsArchiveEnabled), out propertyOverride); + if (Optional.IsDefined(IsArchiveEnabled) || hasPropertyOverride) + { + builder.Append(" isArchiveEnabled: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsArchiveEnabled.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AgentPoolName), out propertyOverride); + if (Optional.IsDefined(AgentPoolName) || hasPropertyOverride) + { + builder.Append(" agentPoolName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (AgentPoolName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{AgentPoolName}'''"); + } + else + { + builder.AppendLine($"'{AgentPoolName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LogTemplate), out propertyOverride); + if (Optional.IsDefined(LogTemplate) || hasPropertyOverride) + { + builder.Append(" logTemplate: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (LogTemplate.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{LogTemplate}'''"); + } + else + { + builder.AppendLine($"'{LogTemplate}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -131,6 +229,8 @@ BinaryData IPersistableModel.Write(ModelReaderWrite { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryRunContent)} does not support '{options.Format}' format."); } @@ -147,6 +247,8 @@ ContainerRegistryRunContent IPersistableModel.Creat using JsonDocument document = JsonDocument.Parse(data); return DeserializeContainerRegistryRunContent(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ContainerRegistryRunContent)} does not support '{options.Format}' format."); } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/UnknownTaskStepProperties.Serialization.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/UnknownTaskStepProperties.Serialization.cs index 87a2ae4fcd373..a785926f69cad 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/UnknownTaskStepProperties.Serialization.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/Models/UnknownTaskStepProperties.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.ContainerRegistry; namespace Azure.ResourceManager.ContainerRegistry.Models @@ -133,6 +136,98 @@ internal static UnknownTaskStepProperties DeserializeUnknownTaskStepProperties(J return new UnknownTaskStepProperties(type, baseImageDependencies ?? new ChangeTrackingList(), contextPath, contextAccessToken, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ContainerRegistryTaskStepType), out propertyOverride); + builder.Append(" type: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ContainerRegistryTaskStepType.ToString()}'"); + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BaseImageDependencies), out propertyOverride); + if (Optional.IsCollectionDefined(BaseImageDependencies) || hasPropertyOverride) + { + if (BaseImageDependencies.Any() || hasPropertyOverride) + { + builder.Append(" baseImageDependencies: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in BaseImageDependencies) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " baseImageDependencies: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ContextPath), out propertyOverride); + if (Optional.IsDefined(ContextPath) || hasPropertyOverride) + { + builder.Append(" contextPath: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ContextPath.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ContextPath}'''"); + } + else + { + builder.AppendLine($"'{ContextPath}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ContextAccessToken), out propertyOverride); + if (Optional.IsDefined(ContextAccessToken) || hasPropertyOverride) + { + builder.Append(" contextAccessToken: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ContextAccessToken.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ContextAccessToken}'''"); + } + else + { + builder.AppendLine($"'{ContextAccessToken}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -141,6 +236,8 @@ BinaryData IPersistableModel.Write(ModelRea { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ContainerRegistryTaskStepProperties)} does not support '{options.Format}' format."); } @@ -157,6 +254,8 @@ ContainerRegistryTaskStepProperties IPersistableModel propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); + if (Optional.IsDefined(Description) || hasPropertyOverride) + { + builder.Append(" description: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Description.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Description}'''"); + } + else + { + builder.AppendLine($"'{Description}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ScopeMapType), out propertyOverride); + if (Optional.IsDefined(ScopeMapType) || hasPropertyOverride) + { + builder.Append(" type: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ScopeMapType.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ScopeMapType}'''"); + } + else + { + builder.AppendLine($"'{ScopeMapType}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); + if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) + { + builder.Append(" creationDate: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); + if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) + { + builder.Append(" provisioningState: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ProvisioningState.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Actions), out propertyOverride); + if (Optional.IsCollectionDefined(Actions) || hasPropertyOverride) + { + if (Actions.Any() || hasPropertyOverride) + { + builder.Append(" actions: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Actions) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -237,6 +416,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions option { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ScopeMapData)} does not support '{options.Format}' format."); } @@ -253,6 +434,8 @@ ScopeMapData IPersistableModel.Create(BinaryData data, ModelReader using JsonDocument document = JsonDocument.Parse(data); return DeserializeScopeMapData(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ScopeMapData)} does not support '{options.Format}' format."); } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ScopeMapData.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ScopeMapData.cs index e2b9a94a7493d..357d3e1208893 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ScopeMapData.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/src/Generated/ScopeMapData.cs @@ -83,18 +83,23 @@ internal ScopeMapData(ResourceIdentifier id, string name, ResourceType resourceT } /// The user friendly description of the scope map. + [WirePath("properties.description")] public string Description { get; set; } /// The type of the scope map. E.g. BuildIn scope map. + [WirePath("properties.type")] public string ScopeMapType { get; } /// The creation date of scope map. + [WirePath("properties.creationDate")] public DateTimeOffset? CreatedOn { get; } /// Provisioning state of the resource. + [WirePath("properties.provisioningState")] public ContainerRegistryProvisioningState? ProvisioningState { get; } /// /// The list of scoped permissions for registry artifacts. /// E.g. repositories/repository-name/content/read, /// repositories/repository-name/metadata/write /// + [WirePath("properties.actions")] public IList Actions { get; } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Internal/BicepSerializationHelpers.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Internal/BicepSerializationHelpers.cs new file mode 100644 index 0000000000000..d163552174bb5 --- /dev/null +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Internal/BicepSerializationHelpers.cs @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text; + +namespace Azure.ResourceManager.OperationalInsights +{ + internal static class BicepSerializationHelpers + { + public static void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + } +} diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Internal/ChangeTrackingDictionary.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Internal/ChangeTrackingDictionary.cs new file mode 100644 index 0000000000000..f4a31176983dd --- /dev/null +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/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.OperationalInsights +{ + 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/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Internal/Optional.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Internal/Optional.cs index 144e404d96b8f..3ee8c0558edcb 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Internal/Optional.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Internal/Optional.cs @@ -7,7 +7,6 @@ using System.Collections.Generic; using System.Text.Json; -using Azure.Core; namespace Azure.ResourceManager.OperationalInsights { diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Internal/Utf8JsonRequestContent.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Internal/Utf8JsonRequestContent.cs new file mode 100644 index 0000000000000..5ce0ee3d2a12c --- /dev/null +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/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.OperationalInsights +{ + 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/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/LogAnalyticsQueryData.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/LogAnalyticsQueryData.Serialization.cs index 680f2ad914d16..07c541f3ed19e 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/LogAnalyticsQueryData.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/LogAnalyticsQueryData.Serialization.cs @@ -539,7 +539,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Related, options, 4, false, " related: "); + BicepSerializationHelpers.AppendChildObject(builder, Related, options, 4, false, " related: "); } } @@ -608,48 +608,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/LogAnalyticsQueryPackData.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/LogAnalyticsQueryPackData.Serialization.cs index f6b49bfebee1c..91de97cd4d2c1 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/LogAnalyticsQueryPackData.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/LogAnalyticsQueryPackData.Serialization.cs @@ -426,48 +426,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/ClusterListResult.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/ClusterListResult.Serialization.cs index 56e484728fb9f..465494c1b108f 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/ClusterListResult.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/ClusterListResult.Serialization.cs @@ -165,7 +165,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -176,48 +176,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/DataExportListResult.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/DataExportListResult.Serialization.cs index 2ea6fad0bd3d3..281a69c182ad1 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/DataExportListResult.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/DataExportListResult.Serialization.cs @@ -132,7 +132,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -143,48 +143,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/DataSourceListResult.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/DataSourceListResult.Serialization.cs index fdb696a94d336..d715ebdda96c2 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/DataSourceListResult.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/DataSourceListResult.Serialization.cs @@ -143,7 +143,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -176,48 +176,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/LinkedServiceListResult.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/LinkedServiceListResult.Serialization.cs index e9bfcddb50639..e7459f5ccb8b7 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/LinkedServiceListResult.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/LinkedServiceListResult.Serialization.cs @@ -132,7 +132,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -143,48 +143,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/LinkedStorageAccountsListResult.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/LinkedStorageAccountsListResult.Serialization.cs index f6284aabe1119..a850263dd17b8 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/LinkedStorageAccountsListResult.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/LinkedStorageAccountsListResult.Serialization.cs @@ -132,7 +132,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -143,48 +143,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/LogAnalyticsQueryPackListResult.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/LogAnalyticsQueryPackListResult.Serialization.cs index 10bf839c4e29e..e3220033c14f2 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/LogAnalyticsQueryPackListResult.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/LogAnalyticsQueryPackListResult.Serialization.cs @@ -136,7 +136,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -169,48 +169,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/LogAnalyticsQueryPackPatch.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/LogAnalyticsQueryPackPatch.cs index 7dac50de81341..ba8966292a8f1 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/LogAnalyticsQueryPackPatch.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/LogAnalyticsQueryPackPatch.cs @@ -7,7 +7,7 @@ using System; using System.Collections.Generic; -using Azure.Core; +using Azure.ResourceManager.OperationalInsights; namespace Azure.ResourceManager.OperationalInsights.Models { diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/LogAnalyticsQueryPackQueryListResult.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/LogAnalyticsQueryPackQueryListResult.Serialization.cs index 2789e1e0ea770..7a98562730428 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/LogAnalyticsQueryPackQueryListResult.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/LogAnalyticsQueryPackQueryListResult.Serialization.cs @@ -136,7 +136,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -169,48 +169,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/LogAnalyticsQueryRelatedMetadata.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/LogAnalyticsQueryRelatedMetadata.Serialization.cs index d3b2c068024e1..3c2f2381910b8 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/LogAnalyticsQueryRelatedMetadata.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/LogAnalyticsQueryRelatedMetadata.Serialization.cs @@ -276,48 +276,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/LogAnalyticsQuerySearchProperties.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/LogAnalyticsQuerySearchProperties.cs index 955ae0cdb43cd..44e855b8ca427 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/LogAnalyticsQuerySearchProperties.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/LogAnalyticsQuerySearchProperties.cs @@ -7,7 +7,7 @@ using System; using System.Collections.Generic; -using Azure.Core; +using Azure.ResourceManager.OperationalInsights; namespace Azure.ResourceManager.OperationalInsights.Models { diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsAvailableServiceTier.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsAvailableServiceTier.Serialization.cs index d568d363ca9ec..3abd37b5b92a5 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsAvailableServiceTier.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsAvailableServiceTier.Serialization.cs @@ -308,48 +308,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsCapacityReservationProperties.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsCapacityReservationProperties.Serialization.cs index 6074abfd5e8eb..42c7a03511bdc 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsCapacityReservationProperties.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsCapacityReservationProperties.Serialization.cs @@ -154,48 +154,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsClusterAssociatedWorkspace.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsClusterAssociatedWorkspace.Serialization.cs index ccf81af5c9b93..3f6d439cd35fe 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsClusterAssociatedWorkspace.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsClusterAssociatedWorkspace.Serialization.cs @@ -216,48 +216,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsClusterPatch.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsClusterPatch.cs index de632dc8b446f..33d3d438987c6 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsClusterPatch.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsClusterPatch.cs @@ -7,8 +7,8 @@ using System; using System.Collections.Generic; -using Azure.Core; using Azure.ResourceManager.Models; +using Azure.ResourceManager.OperationalInsights; namespace Azure.ResourceManager.OperationalInsights.Models { diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsColumn.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsColumn.Serialization.cs index e43ff3f95904b..319ec5b404def 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsColumn.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsColumn.Serialization.cs @@ -214,6 +214,20 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } } + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ColumnType), out propertyOverride); + if (Optional.IsDefined(ColumnType) || hasPropertyOverride) + { + builder.Append(" type: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ColumnType.Value.ToString()}'"); + } + } + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DataTypeHint), out propertyOverride); if (Optional.IsDefined(DataTypeHint) || hasPropertyOverride) { @@ -306,48 +320,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsIntelligencePack.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsIntelligencePack.Serialization.cs index d7d4dcf43ffae..22e5b7fab7254 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsIntelligencePack.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsIntelligencePack.Serialization.cs @@ -191,48 +191,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsKeyVaultProperties.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsKeyVaultProperties.Serialization.cs index 4611f0c26748b..0b3f94162d68a 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsKeyVaultProperties.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsKeyVaultProperties.Serialization.cs @@ -219,48 +219,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsManagementGroup.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsManagementGroup.Serialization.cs index d66288d7d7306..d4f0ab8016f02 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsManagementGroup.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsManagementGroup.Serialization.cs @@ -373,48 +373,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsMetricName.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsMetricName.Serialization.cs index ff96286b911a2..b8cae4b9e436d 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsMetricName.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsMetricName.Serialization.cs @@ -161,48 +161,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsPrivateLinkScopedResourceInfo.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsPrivateLinkScopedResourceInfo.Serialization.cs index ba3961619261e..8aa28f7b0302c 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsPrivateLinkScopedResourceInfo.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsPrivateLinkScopedResourceInfo.Serialization.cs @@ -157,48 +157,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsSchema.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsSchema.Serialization.cs index 4fda36c230937..57f848d9a52ff 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsSchema.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsSchema.Serialization.cs @@ -388,7 +388,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Columns) { - AppendChildObject(builder, item, options, 4, true, " columns: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " columns: "); } builder.AppendLine(" ]"); } @@ -410,7 +410,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in StandardColumns) { - AppendChildObject(builder, item, options, 4, true, " standardColumns: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " standardColumns: "); } builder.AppendLine(" ]"); } @@ -568,48 +568,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsSearchCoreSummary.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsSearchCoreSummary.Serialization.cs index 0519ebc48f53f..53547b2f451e5 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsSearchCoreSummary.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsSearchCoreSummary.Serialization.cs @@ -147,48 +147,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsSearchSchemaValue.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsSearchSchemaValue.Serialization.cs index c5ce036bd025e..dfe2114741ef0 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsSearchSchemaValue.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsSearchSchemaValue.Serialization.cs @@ -226,6 +226,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } } + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SearchSchemaValueType), out propertyOverride); + if (Optional.IsDefined(SearchSchemaValueType) || hasPropertyOverride) + { + builder.Append(" type: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (SearchSchemaValueType.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{SearchSchemaValueType}'''"); + } + else + { + builder.AppendLine($"'{SearchSchemaValueType}'"); + } + } + } + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Indexed), out propertyOverride); builder.Append(" indexed: "); if (hasPropertyOverride) @@ -301,48 +323,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsStorageAccount.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsStorageAccount.Serialization.cs index 8645d2cb7935d..794f2243850a2 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsStorageAccount.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsStorageAccount.Serialization.cs @@ -147,48 +147,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsTableRestoredLogs.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsTableRestoredLogs.Serialization.cs index 0b3045a6aeec1..a4d29faa990bf 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsTableRestoredLogs.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsTableRestoredLogs.Serialization.cs @@ -217,48 +217,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsTableResultStatistics.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsTableResultStatistics.Serialization.cs index f35c9b0a6d388..fa6d01d60a967 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsTableResultStatistics.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsTableResultStatistics.Serialization.cs @@ -182,48 +182,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsTableSearchResults.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsTableSearchResults.Serialization.cs index 6861bf6d26ff7..6e21b6931d661 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsTableSearchResults.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsTableSearchResults.Serialization.cs @@ -320,48 +320,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsTag.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsTag.Serialization.cs index fb5e1d83a28f3..5d4b684308358 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsTag.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsTag.Serialization.cs @@ -155,48 +155,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsUsageMetric.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsUsageMetric.Serialization.cs index 6c63f84c88789..0037e2a2816be 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsUsageMetric.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsUsageMetric.Serialization.cs @@ -190,7 +190,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Name, options, 2, false, " name: "); + BicepSerializationHelpers.AppendChildObject(builder, Name, options, 2, false, " name: "); } } @@ -285,48 +285,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspaceCapping.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspaceCapping.Serialization.cs index 18bc295171fa9..54c8203ecdae2 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspaceCapping.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspaceCapping.Serialization.cs @@ -186,48 +186,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspaceFeatures.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspaceFeatures.Serialization.cs index 039a5372f5264..11b68e66a138c 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspaceFeatures.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspaceFeatures.Serialization.cs @@ -284,48 +284,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspaceFeatures.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspaceFeatures.cs index a679c677d005a..c802e5b12252e 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspaceFeatures.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspaceFeatures.cs @@ -8,6 +8,7 @@ using System; using System.Collections.Generic; using Azure.Core; +using Azure.ResourceManager.OperationalInsights; namespace Azure.ResourceManager.OperationalInsights.Models { diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspacePatch.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspacePatch.Serialization.cs index ad2c8fb6986c3..0098462f94868 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspacePatch.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspacePatch.Serialization.cs @@ -515,7 +515,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Identity, options, 2, false, " identity: "); + BicepSerializationHelpers.AppendChildObject(builder, Identity, options, 2, false, " identity: "); } } @@ -601,7 +601,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Sku, options, 4, false, " sku: "); + BicepSerializationHelpers.AppendChildObject(builder, Sku, options, 4, false, " sku: "); } } @@ -629,7 +629,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, WorkspaceCapping, options, 4, false, " workspaceCapping: "); + BicepSerializationHelpers.AppendChildObject(builder, WorkspaceCapping, options, 4, false, " workspaceCapping: "); } } @@ -721,7 +721,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in PrivateLinkScopedResources) { - AppendChildObject(builder, item, options, 6, true, " privateLinkScopedResources: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 6, true, " privateLinkScopedResources: "); } builder.AppendLine(" ]"); } @@ -738,7 +738,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Features, options, 4, false, " features: "); + BicepSerializationHelpers.AppendChildObject(builder, Features, options, 4, false, " features: "); } } @@ -761,48 +761,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspacePurgeResult.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspacePurgeResult.Serialization.cs index bf760b4ebb017..0de847c24418a 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspacePurgeResult.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspacePurgeResult.Serialization.cs @@ -125,48 +125,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspacePurgeStatusResult.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspacePurgeStatusResult.Serialization.cs index 855095ae69257..66c591acb8bfc 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspacePurgeStatusResult.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspacePurgeStatusResult.Serialization.cs @@ -113,48 +113,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspaceSharedKeys.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspaceSharedKeys.Serialization.cs index 48c4658bf0758..8db98e044853c 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspaceSharedKeys.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspaceSharedKeys.Serialization.cs @@ -161,48 +161,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspaceSku.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspaceSku.Serialization.cs index 948f48ae5d808..2eb52d89f7ed7 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspaceSku.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/OperationalInsightsWorkspaceSku.Serialization.cs @@ -173,48 +173,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SavedSearchesListResult.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SavedSearchesListResult.Serialization.cs index 6889243a3bdd6..1f9b612ed284c 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SavedSearchesListResult.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SavedSearchesListResult.Serialization.cs @@ -132,7 +132,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -143,48 +143,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SearchGetSchemaResponse.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SearchGetSchemaResponse.Serialization.cs index 2ddf724098404..76d52ffd6a964 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SearchGetSchemaResponse.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SearchGetSchemaResponse.Serialization.cs @@ -142,7 +142,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Metadata, options, 2, false, " metadata: "); + BicepSerializationHelpers.AppendChildObject(builder, Metadata, options, 2, false, " metadata: "); } } @@ -161,7 +161,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -172,48 +172,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SearchMetadata.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SearchMetadata.Serialization.cs index 7d467ce079c54..cf4e61171c13c 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SearchMetadata.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SearchMetadata.Serialization.cs @@ -471,7 +471,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in CoreSummaries) { - AppendChildObject(builder, item, options, 4, true, " coreSummaries: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " coreSummaries: "); } builder.AppendLine(" ]"); } @@ -559,7 +559,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Sort) { - AppendChildObject(builder, item, options, 4, true, " sort: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " sort: "); } builder.AppendLine(" ]"); } @@ -662,7 +662,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Schema, options, 2, false, " schema: "); + BicepSerializationHelpers.AppendChildObject(builder, Schema, options, 2, false, " schema: "); } } @@ -670,48 +670,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SearchMetadataSchema.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SearchMetadataSchema.Serialization.cs index a37bf47169eac..37eab12e03afc 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SearchMetadataSchema.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SearchMetadataSchema.Serialization.cs @@ -157,48 +157,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SearchSort.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SearchSort.Serialization.cs index 60dd5cb94c57c..c6b1da09f9f3b 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SearchSort.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/SearchSort.Serialization.cs @@ -157,48 +157,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/StorageInsightListResult.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/StorageInsightListResult.Serialization.cs index 54258f662e467..0a33b673a3846 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/StorageInsightListResult.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/StorageInsightListResult.Serialization.cs @@ -143,7 +143,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -176,48 +176,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/StorageInsightStatus.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/StorageInsightStatus.Serialization.cs index 26e9d5947cbc7..72ae3703e7648 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/StorageInsightStatus.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/StorageInsightStatus.Serialization.cs @@ -147,48 +147,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/TablesListResult.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/TablesListResult.Serialization.cs index 2b4cc38ed28af..76c111661fc4e 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/TablesListResult.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/TablesListResult.Serialization.cs @@ -132,7 +132,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -143,48 +143,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/WorkspaceListManagementGroupsResult.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/WorkspaceListManagementGroupsResult.Serialization.cs index 73e1f5938d887..353ad99d97e5b 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/WorkspaceListManagementGroupsResult.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/WorkspaceListManagementGroupsResult.Serialization.cs @@ -132,7 +132,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -143,48 +143,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/WorkspaceListResult.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/WorkspaceListResult.Serialization.cs index da0d8b2480f20..8a76cacf4b9e5 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/WorkspaceListResult.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/WorkspaceListResult.Serialization.cs @@ -132,7 +132,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -143,48 +143,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/WorkspaceListUsagesResult.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/WorkspaceListUsagesResult.Serialization.cs index 233e26a886c86..0166753219555 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/WorkspaceListUsagesResult.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/Models/WorkspaceListUsagesResult.Serialization.cs @@ -132,7 +132,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -143,48 +143,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsClusterData.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsClusterData.Serialization.cs index 9c86c8baa4813..5776b23edab75 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsClusterData.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsClusterData.Serialization.cs @@ -478,7 +478,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Identity, options, 2, false, " identity: "); + BicepSerializationHelpers.AppendChildObject(builder, Identity, options, 2, false, " identity: "); } } @@ -492,7 +492,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Sku, options, 2, false, " sku: "); + BicepSerializationHelpers.AppendChildObject(builder, Sku, options, 2, false, " sku: "); } } @@ -608,7 +608,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, KeyVaultProperties, options, 4, false, " keyVaultProperties: "); + BicepSerializationHelpers.AppendChildObject(builder, KeyVaultProperties, options, 4, false, " keyVaultProperties: "); } } @@ -657,7 +657,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in AssociatedWorkspaces) { - AppendChildObject(builder, item, options, 6, true, " associatedWorkspaces: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 6, true, " associatedWorkspaces: "); } builder.AppendLine(" ]"); } @@ -674,7 +674,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, CapacityReservationProperties, options, 4, false, " capacityReservationProperties: "); + BicepSerializationHelpers.AppendChildObject(builder, CapacityReservationProperties, options, 4, false, " capacityReservationProperties: "); } } @@ -683,48 +683,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsDataExportData.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsDataExportData.Serialization.cs index de4f7f4c2a552..6ff732c63eb15 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsDataExportData.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsDataExportData.Serialization.cs @@ -532,48 +532,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsDataSourceData.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsDataSourceData.Serialization.cs index 3a06359a6163b..3b6d9aa5d68cb 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsDataSourceData.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsDataSourceData.Serialization.cs @@ -344,48 +344,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsLinkedServiceData.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsLinkedServiceData.Serialization.cs index 44b4b2af46cdd..1c8682f318f28 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsLinkedServiceData.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsLinkedServiceData.Serialization.cs @@ -371,48 +371,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsLinkedStorageAccountsData.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsLinkedStorageAccountsData.Serialization.cs index 578490145f449..ae6280340d526 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsLinkedStorageAccountsData.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsLinkedStorageAccountsData.Serialization.cs @@ -313,48 +313,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsSavedSearchData.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsSavedSearchData.Serialization.cs index cebf2928a52cb..7e011a3f6cf41 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsSavedSearchData.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsSavedSearchData.Serialization.cs @@ -476,7 +476,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Tags) { - AppendChildObject(builder, item, options, 6, true, " tags: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 6, true, " tags: "); } builder.AppendLine(" ]"); } @@ -488,48 +488,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsTableData.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsTableData.Serialization.cs index 6dc9a50e00b6e..df379357c8f3a 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsTableData.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsTableData.Serialization.cs @@ -452,7 +452,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, SearchResults, options, 4, false, " searchResults: "); + BicepSerializationHelpers.AppendChildObject(builder, SearchResults, options, 4, false, " searchResults: "); } } @@ -466,7 +466,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, RestoredLogs, options, 4, false, " restoredLogs: "); + BicepSerializationHelpers.AppendChildObject(builder, RestoredLogs, options, 4, false, " restoredLogs: "); } } @@ -480,7 +480,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, ResultStatistics, options, 4, false, " resultStatistics: "); + BicepSerializationHelpers.AppendChildObject(builder, ResultStatistics, options, 4, false, " resultStatistics: "); } } @@ -530,7 +530,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Schema, options, 4, false, " schema: "); + BicepSerializationHelpers.AppendChildObject(builder, Schema, options, 4, false, " schema: "); } } @@ -583,48 +583,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsWorkspaceData.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsWorkspaceData.Serialization.cs index 264cc3cf64242..075e362a3d4e8 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsWorkspaceData.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/OperationalInsightsWorkspaceData.Serialization.cs @@ -535,7 +535,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Identity, options, 2, false, " identity: "); + BicepSerializationHelpers.AppendChildObject(builder, Identity, options, 2, false, " identity: "); } } @@ -621,7 +621,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Sku, options, 4, false, " sku: "); + BicepSerializationHelpers.AppendChildObject(builder, Sku, options, 4, false, " sku: "); } } @@ -649,7 +649,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, WorkspaceCapping, options, 4, false, " workspaceCapping: "); + BicepSerializationHelpers.AppendChildObject(builder, WorkspaceCapping, options, 4, false, " workspaceCapping: "); } } @@ -741,7 +741,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in PrivateLinkScopedResources) { - AppendChildObject(builder, item, options, 6, true, " privateLinkScopedResources: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 6, true, " privateLinkScopedResources: "); } builder.AppendLine(" ]"); } @@ -758,7 +758,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Features, options, 4, false, " features: "); + BicepSerializationHelpers.AppendChildObject(builder, Features, options, 4, false, " features: "); } } @@ -781,48 +781,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/StorageInsightData.Serialization.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/StorageInsightData.Serialization.cs index 667a76064f3a2..63b9afddedd48 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/StorageInsightData.Serialization.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/src/Generated/StorageInsightData.Serialization.cs @@ -471,7 +471,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, StorageAccount, options, 4, false, " storageAccount: "); + BicepSerializationHelpers.AppendChildObject(builder, StorageAccount, options, 4, false, " storageAccount: "); } } @@ -485,7 +485,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Status, options, 4, false, " status: "); + BicepSerializationHelpers.AppendChildObject(builder, Status, options, 4, false, " status: "); } } @@ -494,48 +494,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; From 78f48a5546c40358ad19dacb93c0fef9926baddc Mon Sep 17 00:00:00 2001 From: jolov Date: Thu, 14 Mar 2024 16:02:14 -0700 Subject: [PATCH 04/10] regen RM --- NuGet.Config | 1 + eng/Packages.Data.props | 2 +- .../Internal/BicepSerializationHelpers.cs | 58 ++++++ .../Internal/ChangeTrackingDictionary.cs | 167 ++++++++++++++++++ .../src/Common/Generated/Internal/Optional.cs | 1 - .../Generated/Models/ArmPlan.Serialization.cs | 42 ----- .../Generated/Models/ArmSku.Serialization.cs | 42 ----- .../EncryptionProperties.Serialization.cs | 44 +---- .../KeyVaultProperties.Serialization.cs | 42 ----- .../OperationStatusResult.Serialization.cs | 74 ++------ ...emAssignedServiceIdentity.Serialization.cs | 49 +---- .../Models/SystemData.Serialization.cs | 42 ----- .../UserAssignedIdentity.Serialization.cs | 42 ----- .../Custom/HelperSuppressions.cs | 1 + .../Internal/BicepSerializationHelpers.cs | 58 ++++++ .../Internal/ChangeTrackingDictionary.cs | 167 ++++++++++++++++++ .../Internal/Utf8JsonRequestContent.cs | 55 ++++++ .../ManagementGroupData.Serialization.cs | 46 +---- ...mentGroupSubscriptionData.Serialization.cs | 44 +---- .../Models/DescendantData.Serialization.cs | 44 +---- .../DescendantListResult.Serialization.cs | 44 +---- ...DescendantParentGroupInfo.Serialization.cs | 42 ----- .../Models/EntityData.Serialization.cs | 44 +---- .../Models/EntityListResult.Serialization.cs | 44 +---- ...ptionUnderManagementGroup.Serialization.cs | 44 +---- .../ManagementGroupChildInfo.Serialization.cs | 44 +---- .../ManagementGroupInfo.Serialization.cs | 48 +---- ...ManagementGroupListResult.Serialization.cs | 44 +---- ...oupNameAvailabilityResult.Serialization.cs | 42 ----- ...anagementGroupPathElement.Serialization.cs | 42 ----- ...ParentManagementGroupInfo.Serialization.cs | 66 ++----- .../Resources/Custom/HelperSuppressions.cs | 1 + .../DataPolicyManifestData.Serialization.cs | 48 +---- .../Generated/FeatureData.Serialization.cs | 44 +---- .../GenericResourceData.Serialization.cs | 50 +----- .../Internal/BicepSerializationHelpers.cs | 58 ++++++ .../Internal/ChangeTrackingDictionary.cs | 167 ++++++++++++++++++ .../Internal/Utf8JsonRequestContent.cs | 55 ++++++ .../ManagementLockData.Serialization.cs | 44 +---- .../Models/ApiProfile.Serialization.cs | 42 ----- .../ArmPolicyParameter.Serialization.cs | 58 ++---- .../ArmPolicyParameterValue.Serialization.cs | 42 ----- .../AvailabilityZoneMappings.Serialization.cs | 42 ----- .../AzureRoleDefinition.Serialization.cs | 68 ++----- ...esourceFunctionDefinition.Serialization.cs | 42 ----- .../DataPolicyManifestEffect.Serialization.cs | 42 ----- ...aPolicyManifestListResult.Serialization.cs | 44 +---- .../Models/ExtendedLocation.Serialization.cs | 56 ++---- ...atureOperationsListResult.Serialization.cs | 44 +---- .../Models/FeatureProperties.Serialization.cs | 42 ----- .../Models/LocationExpanded.Serialization.cs | 46 +---- .../LocationListResult.Serialization.cs | 44 +---- .../Models/LocationMetadata.Serialization.cs | 44 +---- .../Models/ManagedByTenant.Serialization.cs | 42 ----- .../ManagementLockListResult.Serialization.cs | 44 +---- .../ManagementLockOwner.Serialization.cs | 42 ----- .../NonComplianceMessage.Serialization.cs | 42 ----- .../Models/PairedRegion.Serialization.cs | 42 ----- ...rDefinitionsValueMetadata.Serialization.cs | 42 ----- .../ParameterDefinitionsValueMetadata.cs | 2 +- .../Models/Permission.Serialization.cs | 42 ----- ...olicyAssignmentListResult.Serialization.cs | 44 +---- .../PolicyDefinitionGroup.Serialization.cs | 42 ----- ...olicyDefinitionListResult.Serialization.cs | 44 +---- ...PolicyDefinitionReference.Serialization.cs | 44 +---- .../Models/PolicyDefinitionReference.cs | 1 - .../Models/PolicyOverride.Serialization.cs | 44 +---- ...cySetDefinitionListResult.Serialization.cs | 44 +---- .../Models/PredefinedTag.Serialization.cs | 46 +---- .../PredefinedTagCount.Serialization.cs | 62 +++---- .../PredefinedTagValue.Serialization.cs | 44 +---- .../PredefinedTagsListResult.Serialization.cs | 44 +---- .../ProviderExtendedLocation.Serialization.cs | 64 +++---- .../ProviderPermission.Serialization.cs | 46 +---- ...viderPermissionListResult.Serialization.cs | 44 +---- .../ProviderResourceType.Serialization.cs | 50 +----- .../Generated/Models/ProviderResourceType.cs | 1 - ...derResourceTypeListResult.Serialization.cs | 44 +---- ...ResourceGroupExportResult.Serialization.cs | 44 +---- .../ResourceGroupListResult.Serialization.cs | 44 +---- .../Generated/Models/ResourceGroupPatch.cs | 2 +- .../ResourceGroupProperties.Serialization.cs | 42 ----- .../ResourceListResult.Serialization.cs | 44 +---- ...ourceNameValidationResult.Serialization.cs | 54 ++---- ...esourceProviderListResult.Serialization.cs | 44 +---- .../Models/ResourceSelector.Serialization.cs | 44 +---- ...esourceSelectorExpression.Serialization.cs | 42 ----- .../Models/ResourceTypeAlias.Serialization.cs | 62 ++----- .../ResourceTypeAliasPath.Serialization.cs | 46 +---- ...urceTypeAliasPathMetadata.Serialization.cs | 54 ++---- .../ResourceTypeAliasPattern.Serialization.cs | 46 +---- .../ResourceTypeAliases.Serialization.cs | 44 +---- .../Models/ResourcesSku.Serialization.cs | 42 ----- .../SubscriptionListResult.Serialization.cs | 44 +---- .../SubscriptionPolicies.Serialization.cs | 42 ----- .../Generated/Models/Tag.Serialization.cs | 42 ----- .../src/Resources/Generated/Models/Tag.cs | 2 +- .../Models/TenantListResult.Serialization.cs | 44 +---- .../TenantResourceProvider.Serialization.cs | 44 +---- ...esourceProviderListResult.Serialization.cs | 44 +---- ...ackedResourceExtendedData.Serialization.cs | 44 +---- .../Models/ZoneMapping.Serialization.cs | 42 ----- .../PolicyAssignmentData.Serialization.cs | 52 +----- .../PolicyDefinitionData.Serialization.cs | 44 +---- .../Generated/PolicyDefinitionData.cs | 1 + .../PolicySetDefinitionData.Serialization.cs | 48 +---- .../ResourceGroupData.Serialization.cs | 44 +---- .../ResourceProviderData.Serialization.cs | 44 +---- .../ResourceManagementRestOperations.cs | 1 + .../SubscriptionData.Serialization.cs | 110 ++++-------- .../TagResourceData.Serialization.cs | 44 +---- .../Generated/TenantData.Serialization.cs | 42 ----- 112 files changed, 1074 insertions(+), 4012 deletions(-) create mode 100644 sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Internal/BicepSerializationHelpers.cs create mode 100644 sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Internal/ChangeTrackingDictionary.cs create mode 100644 sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Internal/BicepSerializationHelpers.cs create mode 100644 sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Internal/ChangeTrackingDictionary.cs create mode 100644 sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Internal/Utf8JsonRequestContent.cs create mode 100644 sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Internal/BicepSerializationHelpers.cs create mode 100644 sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Internal/ChangeTrackingDictionary.cs create mode 100644 sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Internal/Utf8JsonRequestContent.cs diff --git a/NuGet.Config b/NuGet.Config index fd5e01a144660..37856d3631c9d 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -5,6 +5,7 @@ + diff --git a/eng/Packages.Data.props b/eng/Packages.Data.props index 8e15202ded99b..8fa8b0a9b2000 100644 --- a/eng/Packages.Data.props +++ b/eng/Packages.Data.props @@ -218,7 +218,7 @@ All should have PrivateAssets="All" set so they don't become package dependencies --> - + diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Internal/BicepSerializationHelpers.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Internal/BicepSerializationHelpers.cs new file mode 100644 index 0000000000000..054d4c0cd09a7 --- /dev/null +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Internal/BicepSerializationHelpers.cs @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text; + +namespace Azure.ResourceManager +{ + internal static class BicepSerializationHelpers + { + public static void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + } +} diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Internal/ChangeTrackingDictionary.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Internal/ChangeTrackingDictionary.cs new file mode 100644 index 0000000000000..3e0457dd8331c --- /dev/null +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Common/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 +{ + 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/resourcemanager/Azure.ResourceManager/src/Common/Generated/Internal/Optional.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Internal/Optional.cs index 17381901b19b2..c21cb37eeee76 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Internal/Optional.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Internal/Optional.cs @@ -7,7 +7,6 @@ using System.Collections.Generic; using System.Text.Json; -using Azure.Core; namespace Azure.ResourceManager { diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/ArmPlan.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/ArmPlan.Serialization.cs index 9a63580b63953..badf80739ee06 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/ArmPlan.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/ArmPlan.Serialization.cs @@ -230,48 +230,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/ArmSku.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/ArmSku.Serialization.cs index bd6cb9ee6a675..daeaca3ef273f 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/ArmSku.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/ArmSku.Serialization.cs @@ -228,48 +228,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/EncryptionProperties.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/EncryptionProperties.Serialization.cs index c6298bf940152..346fef82f956a 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/EncryptionProperties.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/EncryptionProperties.Serialization.cs @@ -124,7 +124,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, KeyVaultProperties, options, 2, false, " keyVaultProperties: "); + BicepSerializationHelpers.AppendChildObject(builder, KeyVaultProperties, options, 2, false, " keyVaultProperties: "); } } @@ -132,48 +132,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/KeyVaultProperties.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/KeyVaultProperties.Serialization.cs index b507de2f8fe9d..a124aa51f529d 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/KeyVaultProperties.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/KeyVaultProperties.Serialization.cs @@ -140,48 +140,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/OperationStatusResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/OperationStatusResult.Serialization.cs index 9bfacffd8974f..a699a98e1f7d0 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/OperationStatusResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/OperationStatusResult.Serialization.cs @@ -202,6 +202,20 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("{"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { @@ -224,20 +238,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } } - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); - if (Optional.IsDefined(Id) || hasPropertyOverride) - { - builder.Append(" id: "); - if (hasPropertyOverride) - { - builder.AppendLine($"{propertyOverride}"); - } - else - { - builder.AppendLine($"'{Id.ToString()}'"); - } - } - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); if (Optional.IsDefined(Status) || hasPropertyOverride) { @@ -319,7 +319,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Operations) { - AppendChildObject(builder, item, options, 4, true, " operations: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " operations: "); } builder.AppendLine(" ]"); } @@ -336,7 +336,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Error, options, 2, false, " error: "); + BicepSerializationHelpers.AppendChildObject(builder, Error, options, 2, false, " error: "); } } @@ -344,48 +344,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/SystemAssignedServiceIdentity.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/SystemAssignedServiceIdentity.Serialization.cs index ff8dc8165e2e5..7793abbe81e09 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/SystemAssignedServiceIdentity.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/SystemAssignedServiceIdentity.Serialization.cs @@ -136,50 +136,19 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } } - builder.AppendLine("}"); - return BinaryData.FromString(builder.ToString()); - } - - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemAssignedServiceIdentityType), out propertyOverride); + builder.Append(" type: "); + if (hasPropertyOverride) { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } + builder.AppendLine($"{propertyOverride}"); } - if (stringBuilder.Length == length + emptyObjectLength) + else { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + builder.AppendLine($"'{SystemAssignedServiceIdentityType.ToString()}'"); } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/SystemData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/SystemData.Serialization.cs index b1e843c5ddace..161bc11dcb89b 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/SystemData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/SystemData.Serialization.cs @@ -264,48 +264,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/UserAssignedIdentity.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/UserAssignedIdentity.Serialization.cs index 09a3089dd2ff5..58b1dd9d59132 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/UserAssignedIdentity.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Generated/Models/UserAssignedIdentity.Serialization.cs @@ -132,48 +132,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Custom/HelperSuppressions.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Custom/HelperSuppressions.cs index 759d5fe60b4df..c9e61bbbd98c1 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Custom/HelperSuppressions.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Custom/HelperSuppressions.cs @@ -7,3 +7,4 @@ [assembly: CodeGenSuppressType("Azure.ResourceManager.ChangeTrackingList")] [assembly: CodeGenSuppressType("Azure.ResourceManager.RequestContentHelper")] [assembly: CodeGenSuppressType("Azure.ResourceManager.Argument")] +[assembly: CodeGenSuppressType("Azure.ResourceManager.BicepSerializationHelpers")] diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Internal/BicepSerializationHelpers.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Internal/BicepSerializationHelpers.cs new file mode 100644 index 0000000000000..054d4c0cd09a7 --- /dev/null +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Internal/BicepSerializationHelpers.cs @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text; + +namespace Azure.ResourceManager +{ + internal static class BicepSerializationHelpers + { + public static void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + } +} diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Internal/ChangeTrackingDictionary.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Internal/ChangeTrackingDictionary.cs new file mode 100644 index 0000000000000..3e0457dd8331c --- /dev/null +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/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 +{ + 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/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Internal/Utf8JsonRequestContent.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Internal/Utf8JsonRequestContent.cs new file mode 100644 index 0000000000000..c0ffe14923189 --- /dev/null +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/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 +{ + 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/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/ManagementGroupData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/ManagementGroupData.Serialization.cs index db8ea6564c760..ef436f13f6201 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/ManagementGroupData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/ManagementGroupData.Serialization.cs @@ -337,7 +337,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Details, options, 4, false, " details: "); + BicepSerializationHelpers.AppendChildObject(builder, Details, options, 4, false, " details: "); } } @@ -356,7 +356,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Children) { - AppendChildObject(builder, item, options, 6, true, " children: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 6, true, " children: "); } builder.AppendLine(" ]"); } @@ -368,48 +368,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/ManagementGroupSubscriptionData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/ManagementGroupSubscriptionData.Serialization.cs index fc5c8a0a49406..78b4fd62d27d9 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/ManagementGroupSubscriptionData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/ManagementGroupSubscriptionData.Serialization.cs @@ -326,7 +326,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Parent, options, 4, false, " parent: "); + BicepSerializationHelpers.AppendChildObject(builder, Parent, options, 4, false, " parent: "); } } @@ -357,48 +357,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/DescendantData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/DescendantData.Serialization.cs index 86f015b3f4554..595f723a458ab 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/DescendantData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/DescendantData.Serialization.cs @@ -291,7 +291,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Parent, options, 4, false, " parent: "); + BicepSerializationHelpers.AppendChildObject(builder, Parent, options, 4, false, " parent: "); } } @@ -300,48 +300,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/DescendantListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/DescendantListResult.Serialization.cs index 3ba3f26764934..bf21327e4418b 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/DescendantListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/DescendantListResult.Serialization.cs @@ -142,7 +142,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -175,48 +175,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/DescendantParentGroupInfo.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/DescendantParentGroupInfo.Serialization.cs index b709c44d983ce..18cfb7a7148de 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/DescendantParentGroupInfo.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/DescendantParentGroupInfo.Serialization.cs @@ -123,48 +123,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/EntityData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/EntityData.Serialization.cs index 0f874df0d7dab..c7ba58ce448ed 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/EntityData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/EntityData.Serialization.cs @@ -511,7 +511,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Parent, options, 4, false, " parent: "); + BicepSerializationHelpers.AppendChildObject(builder, Parent, options, 4, false, " parent: "); } } @@ -660,48 +660,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/EntityListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/EntityListResult.Serialization.cs index 9f1fb2e4c411d..59598c9baee8f 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/EntityListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/EntityListResult.Serialization.cs @@ -157,7 +157,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -204,48 +204,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ListSubscriptionUnderManagementGroup.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ListSubscriptionUnderManagementGroup.Serialization.cs index 4514c205f0f0c..c130f4bc47dac 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ListSubscriptionUnderManagementGroup.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ListSubscriptionUnderManagementGroup.Serialization.cs @@ -143,7 +143,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -176,48 +176,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupChildInfo.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupChildInfo.Serialization.cs index 4f97a880cff11..5183acd2dd8f1 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupChildInfo.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupChildInfo.Serialization.cs @@ -251,7 +251,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Children) { - AppendChildObject(builder, item, options, 4, true, " children: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " children: "); } builder.AppendLine(" ]"); } @@ -262,48 +262,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupInfo.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupInfo.Serialization.cs index b2973c0b5df7a..7d0935dee175f 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupInfo.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupInfo.Serialization.cs @@ -315,7 +315,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Parent, options, 2, false, " parent: "); + BicepSerializationHelpers.AppendChildObject(builder, Parent, options, 2, false, " parent: "); } } @@ -334,7 +334,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Path) { - AppendChildObject(builder, item, options, 4, true, " path: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " path: "); } builder.AppendLine(" ]"); } @@ -391,7 +391,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in ManagementGroupAncestorChain) { - AppendChildObject(builder, item, options, 4, true, " managementGroupAncestorsChain: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " managementGroupAncestorsChain: "); } builder.AppendLine(" ]"); } @@ -402,48 +402,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupListResult.Serialization.cs index 426da2236b5c0..88d861717cb28 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupListResult.Serialization.cs @@ -143,7 +143,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -176,48 +176,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupNameAvailabilityResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupNameAvailabilityResult.Serialization.cs index d0cfa7f0a7b33..b79b8a62ea23e 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupNameAvailabilityResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupNameAvailabilityResult.Serialization.cs @@ -186,48 +186,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupPathElement.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupPathElement.Serialization.cs index 24890eb00d070..b5007cab694ca 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupPathElement.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupPathElement.Serialization.cs @@ -160,48 +160,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ParentManagementGroupInfo.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ParentManagementGroupInfo.Serialization.cs index c310a3770237e..d63be96305eee 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ParentManagementGroupInfo.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ParentManagementGroupInfo.Serialization.cs @@ -123,46 +123,46 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("{"); - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); - if (Optional.IsDefined(Name) || hasPropertyOverride) + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" name: "); + builder.Append(" id: "); if (hasPropertyOverride) { builder.AppendLine($"{propertyOverride}"); } else { - if (Name.Contains(Environment.NewLine)) + if (Id.Contains(Environment.NewLine)) { builder.AppendLine("'''"); - builder.AppendLine($"{Name}'''"); + builder.AppendLine($"{Id}'''"); } else { - builder.AppendLine($"'{Name}'"); + builder.AppendLine($"'{Id}'"); } } } - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); - if (Optional.IsDefined(Id) || hasPropertyOverride) + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" id: "); + builder.Append(" name: "); if (hasPropertyOverride) { builder.AppendLine($"{propertyOverride}"); } else { - if (Id.Contains(Environment.NewLine)) + if (Name.Contains(Environment.NewLine)) { builder.AppendLine("'''"); - builder.AppendLine($"{Id}'''"); + builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($"'{Id}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -193,48 +193,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Custom/HelperSuppressions.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Custom/HelperSuppressions.cs index 759d5fe60b4df..c9e61bbbd98c1 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Custom/HelperSuppressions.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Custom/HelperSuppressions.cs @@ -7,3 +7,4 @@ [assembly: CodeGenSuppressType("Azure.ResourceManager.ChangeTrackingList")] [assembly: CodeGenSuppressType("Azure.ResourceManager.RequestContentHelper")] [assembly: CodeGenSuppressType("Azure.ResourceManager.Argument")] +[assembly: CodeGenSuppressType("Azure.ResourceManager.BicepSerializationHelpers")] diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/DataPolicyManifestData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/DataPolicyManifestData.Serialization.cs index 9fe94a7debe37..b6a3b95e97ebf 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/DataPolicyManifestData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/DataPolicyManifestData.Serialization.cs @@ -499,7 +499,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in ResourceTypeAliases) { - AppendChildObject(builder, item, options, 6, true, " resourceTypeAliases: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 6, true, " resourceTypeAliases: "); } builder.AppendLine(" ]"); } @@ -521,7 +521,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Effects) { - AppendChildObject(builder, item, options, 6, true, " effects: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 6, true, " effects: "); } builder.AppendLine(" ]"); } @@ -615,7 +615,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in CustomDefinitions) { - AppendChildObject(builder, item, options, 8, true, " custom: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 8, true, " custom: "); } builder.AppendLine(" ]"); } @@ -628,48 +628,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/FeatureData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/FeatureData.Serialization.cs index 54401f49cae31..b5d7d4ac66b19 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/FeatureData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/FeatureData.Serialization.cs @@ -193,7 +193,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Properties, options, 2, false, " properties: "); + BicepSerializationHelpers.AppendChildObject(builder, Properties, options, 2, false, " properties: "); } } @@ -229,48 +229,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/GenericResourceData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/GenericResourceData.Serialization.cs index ea60ac2810f52..4c38808ba44f2 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/GenericResourceData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/GenericResourceData.Serialization.cs @@ -416,7 +416,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Plan, options, 2, false, " plan: "); + BicepSerializationHelpers.AppendChildObject(builder, Plan, options, 2, false, " plan: "); } } @@ -488,7 +488,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Sku, options, 2, false, " sku: "); + BicepSerializationHelpers.AppendChildObject(builder, Sku, options, 2, false, " sku: "); } } @@ -502,7 +502,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Identity, options, 2, false, " identity: "); + BicepSerializationHelpers.AppendChildObject(builder, Identity, options, 2, false, " identity: "); } } @@ -568,7 +568,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, ExtendedLocation, options, 2, false, " extendedLocation: "); + BicepSerializationHelpers.AppendChildObject(builder, ExtendedLocation, options, 2, false, " extendedLocation: "); } } @@ -604,48 +604,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Internal/BicepSerializationHelpers.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Internal/BicepSerializationHelpers.cs new file mode 100644 index 0000000000000..054d4c0cd09a7 --- /dev/null +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Internal/BicepSerializationHelpers.cs @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text; + +namespace Azure.ResourceManager +{ + internal static class BicepSerializationHelpers + { + public static void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + } +} diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Internal/ChangeTrackingDictionary.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Internal/ChangeTrackingDictionary.cs new file mode 100644 index 0000000000000..3e0457dd8331c --- /dev/null +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/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 +{ + 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/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Internal/Utf8JsonRequestContent.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Internal/Utf8JsonRequestContent.cs new file mode 100644 index 0000000000000..c0ffe14923189 --- /dev/null +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/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 +{ + 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/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ManagementLockData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ManagementLockData.Serialization.cs index 6dbcd3bda3607..4e5e862dccc18 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ManagementLockData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ManagementLockData.Serialization.cs @@ -308,7 +308,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Owners) { - AppendChildObject(builder, item, options, 6, true, " owners: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 6, true, " owners: "); } builder.AppendLine(" ]"); } @@ -320,48 +320,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ApiProfile.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ApiProfile.Serialization.cs index 83ced777dd21b..5eb94ae8a4203 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ApiProfile.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ApiProfile.Serialization.cs @@ -160,48 +160,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ArmPolicyParameter.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ArmPolicyParameter.Serialization.cs index 7a8386a17f815..0e0a8397ad53d 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ArmPolicyParameter.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ArmPolicyParameter.Serialization.cs @@ -187,6 +187,20 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("{"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ParameterType), out propertyOverride); + if (Optional.IsDefined(ParameterType) || hasPropertyOverride) + { + builder.Append(" type: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ParameterType.Value.ToString()}'"); + } + } + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AllowedValues), out propertyOverride); if (Optional.IsCollectionDefined(AllowedValues) || hasPropertyOverride) { @@ -238,7 +252,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Metadata, options, 2, false, " metadata: "); + BicepSerializationHelpers.AppendChildObject(builder, Metadata, options, 2, false, " metadata: "); } } @@ -246,48 +260,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ArmPolicyParameterValue.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ArmPolicyParameterValue.Serialization.cs index 857aabf356921..42271ef996ffa 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ArmPolicyParameterValue.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ArmPolicyParameterValue.Serialization.cs @@ -130,48 +130,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/AvailabilityZoneMappings.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/AvailabilityZoneMappings.Serialization.cs index 4a267e7c22269..70a8cf4c93262 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/AvailabilityZoneMappings.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/AvailabilityZoneMappings.Serialization.cs @@ -160,48 +160,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/AzureRoleDefinition.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/AzureRoleDefinition.Serialization.cs index 3e7e8277d31ed..8c426ab0ffb0a 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/AzureRoleDefinition.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/AzureRoleDefinition.Serialization.cs @@ -184,46 +184,46 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("{"); - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); - if (Optional.IsDefined(Name) || hasPropertyOverride) + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) { - builder.Append(" name: "); + builder.Append(" id: "); if (hasPropertyOverride) { builder.AppendLine($"{propertyOverride}"); } else { - if (Name.Contains(Environment.NewLine)) + if (Id.Contains(Environment.NewLine)) { builder.AppendLine("'''"); - builder.AppendLine($"{Name}'''"); + builder.AppendLine($"{Id}'''"); } else { - builder.AppendLine($"'{Name}'"); + builder.AppendLine($"'{Id}'"); } } } - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); - if (Optional.IsDefined(Id) || hasPropertyOverride) + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) { - builder.Append(" id: "); + builder.Append(" name: "); if (hasPropertyOverride) { builder.AppendLine($"{propertyOverride}"); } else { - if (Id.Contains(Environment.NewLine)) + if (Name.Contains(Environment.NewLine)) { builder.AppendLine("'''"); - builder.AppendLine($"{Id}'''"); + builder.AppendLine($"{Name}'''"); } else { - builder.AppendLine($"'{Id}'"); + builder.AppendLine($"'{Name}'"); } } } @@ -258,7 +258,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Permissions) { - AppendChildObject(builder, item, options, 4, true, " permissions: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " permissions: "); } builder.AppendLine(" ]"); } @@ -304,48 +304,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataManifestCustomResourceFunctionDefinition.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataManifestCustomResourceFunctionDefinition.Serialization.cs index be77c815f3dc1..ab4dc0e34804b 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataManifestCustomResourceFunctionDefinition.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataManifestCustomResourceFunctionDefinition.Serialization.cs @@ -247,48 +247,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataPolicyManifestEffect.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataPolicyManifestEffect.Serialization.cs index 0c6d2302f17b1..0a8de3c2a57f1 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataPolicyManifestEffect.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataPolicyManifestEffect.Serialization.cs @@ -163,48 +163,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataPolicyManifestListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataPolicyManifestListResult.Serialization.cs index 2a2675ed37de3..1d719f3c1765e 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataPolicyManifestListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/DataPolicyManifestListResult.Serialization.cs @@ -143,7 +143,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -176,48 +176,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ExtendedLocation.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ExtendedLocation.Serialization.cs index 397f71acde043..75dd29495d221 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ExtendedLocation.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ExtendedLocation.Serialization.cs @@ -96,6 +96,20 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("{"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExtendedLocationType), out propertyOverride); + if (Optional.IsDefined(ExtendedLocationType) || hasPropertyOverride) + { + builder.Append(" type: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ExtendedLocationType.Value.ToString()}'"); + } + } + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); if (Optional.IsDefined(Name) || hasPropertyOverride) { @@ -122,48 +136,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/FeatureOperationsListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/FeatureOperationsListResult.Serialization.cs index 45beb1de8af0a..2d54aa43d02e7 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/FeatureOperationsListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/FeatureOperationsListResult.Serialization.cs @@ -143,7 +143,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -176,48 +176,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/FeatureProperties.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/FeatureProperties.Serialization.cs index adfb0cc326862..47205a1b21eef 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/FeatureProperties.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/FeatureProperties.Serialization.cs @@ -127,48 +127,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/LocationExpanded.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/LocationExpanded.Serialization.cs index a997b6fbfed75..27b0f9febfd16 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/LocationExpanded.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/LocationExpanded.Serialization.cs @@ -330,7 +330,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Metadata, options, 2, false, " metadata: "); + BicepSerializationHelpers.AppendChildObject(builder, Metadata, options, 2, false, " metadata: "); } } @@ -349,7 +349,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in AvailabilityZoneMappings) { - AppendChildObject(builder, item, options, 4, true, " availabilityZoneMappings: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " availabilityZoneMappings: "); } builder.AppendLine(" ]"); } @@ -360,48 +360,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/LocationListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/LocationListResult.Serialization.cs index 27e1831485dd4..a4769dcb4ea74 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/LocationListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/LocationListResult.Serialization.cs @@ -131,7 +131,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -142,48 +142,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/LocationMetadata.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/LocationMetadata.Serialization.cs index 1f0e54fc69de4..650849704f3f5 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/LocationMetadata.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/LocationMetadata.Serialization.cs @@ -359,7 +359,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in PairedRegions) { - AppendChildObject(builder, item, options, 4, true, " pairedRegion: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " pairedRegion: "); } builder.AppendLine(" ]"); } @@ -392,48 +392,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagedByTenant.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagedByTenant.Serialization.cs index 78311cb22d546..e5cb41d8de0bc 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagedByTenant.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagedByTenant.Serialization.cs @@ -123,48 +123,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagementLockListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagementLockListResult.Serialization.cs index 7e82d12a26079..499326a324375 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagementLockListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagementLockListResult.Serialization.cs @@ -143,7 +143,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -176,48 +176,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagementLockOwner.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagementLockOwner.Serialization.cs index 9d85ddbdb78ac..975e7ce63def0 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagementLockOwner.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ManagementLockOwner.Serialization.cs @@ -127,48 +127,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/NonComplianceMessage.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/NonComplianceMessage.Serialization.cs index 4c8c6aa5d6cdf..de8450242b961 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/NonComplianceMessage.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/NonComplianceMessage.Serialization.cs @@ -157,48 +157,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PairedRegion.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PairedRegion.Serialization.cs index 66308dc8298c0..3cb6e73b8918e 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PairedRegion.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PairedRegion.Serialization.cs @@ -193,48 +193,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ParameterDefinitionsValueMetadata.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ParameterDefinitionsValueMetadata.Serialization.cs index 1ec51e61d9e5e..14278de27244d 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ParameterDefinitionsValueMetadata.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ParameterDefinitionsValueMetadata.Serialization.cs @@ -217,48 +217,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ParameterDefinitionsValueMetadata.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ParameterDefinitionsValueMetadata.cs index 5f95ff0642b07..dfe731fd68a44 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ParameterDefinitionsValueMetadata.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ParameterDefinitionsValueMetadata.cs @@ -7,7 +7,7 @@ using System; using System.Collections.Generic; -using Azure.Core; +using Azure.ResourceManager; namespace Azure.ResourceManager.Resources.Models { diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/Permission.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/Permission.Serialization.cs index 06dc4c79ef029..beecf9e8dc510 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/Permission.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/Permission.Serialization.cs @@ -335,48 +335,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyAssignmentListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyAssignmentListResult.Serialization.cs index d31c13dd08924..bdc28787b212b 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyAssignmentListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyAssignmentListResult.Serialization.cs @@ -143,7 +143,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -176,48 +176,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionGroup.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionGroup.Serialization.cs index ede8d8007003b..c55c08310094b 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionGroup.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionGroup.Serialization.cs @@ -262,48 +262,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionListResult.Serialization.cs index 2e75896faae1c..de35b9f86d6a4 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionListResult.Serialization.cs @@ -143,7 +143,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -176,48 +176,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionReference.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionReference.Serialization.cs index 9ad9078853ba3..1ef61ade23b89 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionReference.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionReference.Serialization.cs @@ -199,7 +199,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) foreach (var item in Parameters) { builder.Append($" '{item.Key}': "); - AppendChildObject(builder, item.Value, options, 4, false, " parameters: "); + BicepSerializationHelpers.AppendChildObject(builder, item.Value, options, 4, false, " parameters: "); } builder.AppendLine(" }"); } @@ -267,48 +267,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionReference.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionReference.cs index 055430a1f6c6e..ee28dadd2dee2 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionReference.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyDefinitionReference.cs @@ -7,7 +7,6 @@ using System; using System.Collections.Generic; -using Azure.Core; using Azure.ResourceManager; namespace Azure.ResourceManager.Resources.Models diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyOverride.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyOverride.Serialization.cs index 472f34c121551..28d9653fea6b7 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyOverride.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicyOverride.Serialization.cs @@ -193,7 +193,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Selectors) { - AppendChildObject(builder, item, options, 4, true, " selectors: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " selectors: "); } builder.AppendLine(" ]"); } @@ -204,48 +204,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicySetDefinitionListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicySetDefinitionListResult.Serialization.cs index 10d67a3d7ee61..fa7f38ccd26c6 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicySetDefinitionListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PolicySetDefinitionListResult.Serialization.cs @@ -143,7 +143,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -176,48 +176,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTag.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTag.Serialization.cs index 8098f4ae747d2..fd120fd868344 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTag.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTag.Serialization.cs @@ -207,7 +207,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Count, options, 2, false, " count: "); + BicepSerializationHelpers.AppendChildObject(builder, Count, options, 2, false, " count: "); } } @@ -226,7 +226,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Values) { - AppendChildObject(builder, item, options, 4, true, " values: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " values: "); } builder.AppendLine(" ]"); } @@ -237,48 +237,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTagCount.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTagCount.Serialization.cs index c5683ebf81513..be81c7e57c8da 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTagCount.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTagCount.Serialization.cs @@ -116,64 +116,44 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("{"); - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); - if (Optional.IsDefined(Value) || hasPropertyOverride) + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PredefinedTagCountType), out propertyOverride); + if (Optional.IsDefined(PredefinedTagCountType) || hasPropertyOverride) { - builder.Append(" value: "); + builder.Append(" type: "); if (hasPropertyOverride) { builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($"{Value.Value}"); + if (PredefinedTagCountType.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{PredefinedTagCountType}'''"); + } + else + { + builder.AppendLine($"'{PredefinedTagCountType}'"); + } } } - builder.AppendLine("}"); - return BinaryData.FromString(builder.ToString()); - } - - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsDefined(Value) || hasPropertyOverride) { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) + builder.Append(" value: "); + if (hasPropertyOverride) { - stringBuilder.AppendLine($"{line}"); + builder.AppendLine($"{propertyOverride}"); } else { - stringBuilder.AppendLine($"{indent}{line}"); + builder.AppendLine($"{Value.Value}"); } } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTagValue.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTagValue.Serialization.cs index cfd186524d6e8..28282dc5be68c 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTagValue.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTagValue.Serialization.cs @@ -181,7 +181,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Count, options, 2, false, " count: "); + BicepSerializationHelpers.AppendChildObject(builder, Count, options, 2, false, " count: "); } } @@ -189,48 +189,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTagsListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTagsListResult.Serialization.cs index 9929d0129780c..ab3181cda0e11 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTagsListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/PredefinedTagsListResult.Serialization.cs @@ -142,7 +142,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -175,48 +175,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderExtendedLocation.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderExtendedLocation.Serialization.cs index 14e522938524e..afffd664e4eba 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderExtendedLocation.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderExtendedLocation.Serialization.cs @@ -156,6 +156,28 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } } + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProviderExtendedLocationType), out propertyOverride); + if (Optional.IsDefined(ProviderExtendedLocationType) || hasPropertyOverride) + { + builder.Append(" type: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ProviderExtendedLocationType.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ProviderExtendedLocationType}'''"); + } + else + { + builder.AppendLine($"'{ProviderExtendedLocationType}'"); + } + } + } + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExtendedLocations), out propertyOverride); if (Optional.IsCollectionDefined(ExtendedLocations) || hasPropertyOverride) { @@ -195,48 +217,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderPermission.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderPermission.Serialization.cs index 727586105666a..bd7e8e4922bda 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderPermission.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderPermission.Serialization.cs @@ -178,7 +178,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, RoleDefinition, options, 2, false, " roleDefinition: "); + BicepSerializationHelpers.AppendChildObject(builder, RoleDefinition, options, 2, false, " roleDefinition: "); } } @@ -192,7 +192,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, ManagedByRoleDefinition, options, 2, false, " managedByRoleDefinition: "); + BicepSerializationHelpers.AppendChildObject(builder, ManagedByRoleDefinition, options, 2, false, " managedByRoleDefinition: "); } } @@ -214,48 +214,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderPermissionListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderPermissionListResult.Serialization.cs index 4807069fff184..8f27dc6f8f12e 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderPermissionListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderPermissionListResult.Serialization.cs @@ -142,7 +142,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -175,48 +175,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderResourceType.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderResourceType.Serialization.cs index 7597ef5a7757c..694f10447c2af 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderResourceType.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderResourceType.Serialization.cs @@ -383,7 +383,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in LocationMappings) { - AppendChildObject(builder, item, options, 4, true, " locationMappings: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " locationMappings: "); } builder.AppendLine(" ]"); } @@ -405,7 +405,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Aliases) { - AppendChildObject(builder, item, options, 4, true, " aliases: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " aliases: "); } builder.AppendLine(" ]"); } @@ -484,7 +484,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in ZoneMappings) { - AppendChildObject(builder, item, options, 4, true, " zoneMappings: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " zoneMappings: "); } builder.AppendLine(" ]"); } @@ -506,7 +506,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in ApiProfiles) { - AppendChildObject(builder, item, options, 4, true, " apiProfiles: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " apiProfiles: "); } builder.AppendLine(" ]"); } @@ -575,48 +575,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderResourceType.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderResourceType.cs index e1cee20baf1fb..f9924f35d3e5a 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderResourceType.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderResourceType.cs @@ -7,7 +7,6 @@ using System; using System.Collections.Generic; -using Azure.Core; using Azure.ResourceManager; namespace Azure.ResourceManager.Resources.Models diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderResourceTypeListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderResourceTypeListResult.Serialization.cs index 91c6c10ac685c..9c42d62f31d73 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderResourceTypeListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ProviderResourceTypeListResult.Serialization.cs @@ -142,7 +142,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -175,48 +175,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupExportResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupExportResult.Serialization.cs index d0dd3bd8a3feb..80aeaee0a8d4e 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupExportResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupExportResult.Serialization.cs @@ -152,7 +152,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Error, options, 2, false, " error: "); + BicepSerializationHelpers.AppendChildObject(builder, Error, options, 2, false, " error: "); } } @@ -160,48 +160,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupListResult.Serialization.cs index 6afc275f2da6e..fbba1bb38929c 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupListResult.Serialization.cs @@ -143,7 +143,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -176,48 +176,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupPatch.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupPatch.cs index e21fe1f1f6f38..45be047346abf 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupPatch.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupPatch.cs @@ -7,7 +7,7 @@ using System; using System.Collections.Generic; -using Azure.Core; +using Azure.ResourceManager; namespace Azure.ResourceManager.Resources.Models { diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupProperties.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupProperties.Serialization.cs index 57b8d70fbe7f4..42364d8bb37d6 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupProperties.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceGroupProperties.Serialization.cs @@ -127,48 +127,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceListResult.Serialization.cs index 72cafdab82f39..7a55a7d1ec7d7 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceListResult.Serialization.cs @@ -143,7 +143,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -176,48 +176,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceNameValidationResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceNameValidationResult.Serialization.cs index e508eda388e47..252770cc38cb2 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceNameValidationResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceNameValidationResult.Serialization.cs @@ -153,64 +153,36 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } } - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); - if (Optional.IsDefined(Status) || hasPropertyOverride) + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ResourceType), out propertyOverride); + if (Optional.IsDefined(ResourceType) || hasPropertyOverride) { - builder.Append(" status: "); + builder.Append(" type: "); if (hasPropertyOverride) { builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($"'{Status.Value.ToString()}'"); + builder.AppendLine($"'{ResourceType.Value.ToString()}'"); } } - builder.AppendLine("}"); - return BinaryData.FromString(builder.ToString()); - } - - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); + if (Optional.IsDefined(Status) || hasPropertyOverride) { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) + builder.Append(" status: "); + if (hasPropertyOverride) { - stringBuilder.AppendLine($"{line}"); + builder.AppendLine($"{propertyOverride}"); } else { - stringBuilder.AppendLine($"{indent}{line}"); + builder.AppendLine($"'{Status.Value.ToString()}'"); } } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceProviderListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceProviderListResult.Serialization.cs index 172ae8b34ba45..8ef2abf191e35 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceProviderListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceProviderListResult.Serialization.cs @@ -143,7 +143,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -176,48 +176,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceSelector.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceSelector.Serialization.cs index 4c5d9e41eb5a8..ac1758a3d1733 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceSelector.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceSelector.Serialization.cs @@ -164,7 +164,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Selectors) { - AppendChildObject(builder, item, options, 4, true, " selectors: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " selectors: "); } builder.AppendLine(" ]"); } @@ -175,48 +175,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceSelectorExpression.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceSelectorExpression.Serialization.cs index 7d9a4120cbcd0..401503f6438f1 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceSelectorExpression.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceSelectorExpression.Serialization.cs @@ -244,48 +244,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAlias.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAlias.Serialization.cs index f5f9d23f31a4c..2e594a2d4d742 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAlias.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAlias.Serialization.cs @@ -227,13 +227,27 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Paths) { - AppendChildObject(builder, item, options, 4, true, " paths: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " paths: "); } builder.AppendLine(" ]"); } } } + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AliasType), out propertyOverride); + if (Optional.IsDefined(AliasType) || hasPropertyOverride) + { + builder.Append(" type: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{AliasType.Value.ToSerialString()}'"); + } + } + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DefaultPath), out propertyOverride); if (Optional.IsDefined(DefaultPath) || hasPropertyOverride) { @@ -266,7 +280,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, DefaultPattern, options, 2, false, " defaultPattern: "); + BicepSerializationHelpers.AppendChildObject(builder, DefaultPattern, options, 2, false, " defaultPattern: "); } } @@ -280,7 +294,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, DefaultMetadata, options, 2, false, " defaultMetadata: "); + BicepSerializationHelpers.AppendChildObject(builder, DefaultMetadata, options, 2, false, " defaultMetadata: "); } } @@ -288,48 +302,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliasPath.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliasPath.Serialization.cs index 64ddfcb49082d..43c5fe61b7193 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliasPath.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliasPath.Serialization.cs @@ -224,7 +224,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Pattern, options, 2, false, " pattern: "); + BicepSerializationHelpers.AppendChildObject(builder, Pattern, options, 2, false, " pattern: "); } } @@ -238,7 +238,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Metadata, options, 2, false, " metadata: "); + BicepSerializationHelpers.AppendChildObject(builder, Metadata, options, 2, false, " metadata: "); } } @@ -246,48 +246,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliasPathMetadata.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliasPathMetadata.Serialization.cs index 0979f8f0b7d87..f9143a6d20c6b 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliasPathMetadata.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliasPathMetadata.Serialization.cs @@ -120,64 +120,36 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("{"); - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Attributes), out propertyOverride); - if (Optional.IsDefined(Attributes) || hasPropertyOverride) + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TokenType), out propertyOverride); + if (Optional.IsDefined(TokenType) || hasPropertyOverride) { - builder.Append(" attributes: "); + builder.Append(" type: "); if (hasPropertyOverride) { builder.AppendLine($"{propertyOverride}"); } else { - builder.AppendLine($"'{Attributes.Value.ToString()}'"); + builder.AppendLine($"'{TokenType.Value.ToString()}'"); } } - builder.AppendLine("}"); - return BinaryData.FromString(builder.ToString()); - } - - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Attributes), out propertyOverride); + if (Optional.IsDefined(Attributes) || hasPropertyOverride) { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) + builder.Append(" attributes: "); + if (hasPropertyOverride) { - stringBuilder.AppendLine($"{line}"); + builder.AppendLine($"{propertyOverride}"); } else { - stringBuilder.AppendLine($"{indent}{line}"); + builder.AppendLine($"'{Attributes.Value.ToString()}'"); } } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliasPattern.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliasPattern.Serialization.cs index 34256212545a9..b1ed2924dff22 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliasPattern.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliasPattern.Serialization.cs @@ -171,50 +171,22 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } } - builder.AppendLine("}"); - return BinaryData.FromString(builder.ToString()); - } - - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PatternType), out propertyOverride); + if (Optional.IsDefined(PatternType) || hasPropertyOverride) { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) + builder.Append(" type: "); + if (hasPropertyOverride) { - stringBuilder.AppendLine($"{line}"); + builder.AppendLine($"{propertyOverride}"); } else { - stringBuilder.AppendLine($"{indent}{line}"); + builder.AppendLine($"'{PatternType.Value.ToSerialString()}'"); } } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliases.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliases.Serialization.cs index 2c46653d2f157..edc337b005e54 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliases.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceTypeAliases.Serialization.cs @@ -164,7 +164,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Aliases) { - AppendChildObject(builder, item, options, 4, true, " aliases: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " aliases: "); } builder.AppendLine(" ]"); } @@ -175,48 +175,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourcesSku.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourcesSku.Serialization.cs index 47c67d79ae848..9a7d778ae8185 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourcesSku.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourcesSku.Serialization.cs @@ -295,48 +295,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/SubscriptionListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/SubscriptionListResult.Serialization.cs index 338013080d8b9..33d4cfff2ad9c 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/SubscriptionListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/SubscriptionListResult.Serialization.cs @@ -140,7 +140,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -173,48 +173,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/SubscriptionPolicies.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/SubscriptionPolicies.Serialization.cs index 579d05ab72775..7212ae88a1164 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/SubscriptionPolicies.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/SubscriptionPolicies.Serialization.cs @@ -189,48 +189,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/Tag.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/Tag.Serialization.cs index db1dbd4580562..f731f15b2fa81 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/Tag.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/Tag.Serialization.cs @@ -157,48 +157,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/Tag.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/Tag.cs index 18f30b9f867cc..f9984cb188dfd 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/Tag.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/Tag.cs @@ -7,7 +7,7 @@ using System; using System.Collections.Generic; -using Azure.Core; +using Azure.ResourceManager; namespace Azure.ResourceManager.Resources.Models { diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantListResult.Serialization.cs index c86a2f56b13af..2987163341f32 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantListResult.Serialization.cs @@ -140,7 +140,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -173,48 +173,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantResourceProvider.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantResourceProvider.Serialization.cs index 79ab4c5751268..a25f582e4dcca 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantResourceProvider.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantResourceProvider.Serialization.cs @@ -164,7 +164,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in ResourceTypes) { - AppendChildObject(builder, item, options, 4, true, " resourceTypes: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " resourceTypes: "); } builder.AppendLine(" ]"); } @@ -175,48 +175,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantResourceProviderListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantResourceProviderListResult.Serialization.cs index 9beb87a3c8d75..5f43d5784de9e 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantResourceProviderListResult.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TenantResourceProviderListResult.Serialization.cs @@ -142,7 +142,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Value) { - AppendChildObject(builder, item, options, 4, true, " value: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); } builder.AppendLine(" ]"); } @@ -175,48 +175,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TrackedResourceExtendedData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TrackedResourceExtendedData.Serialization.cs index a1e39c9e8b8d3..b45d3e243c29f 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TrackedResourceExtendedData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/TrackedResourceExtendedData.Serialization.cs @@ -276,7 +276,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, ExtendedLocation, options, 2, false, " extendedLocation: "); + BicepSerializationHelpers.AppendChildObject(builder, ExtendedLocation, options, 2, false, " extendedLocation: "); } } @@ -312,48 +312,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ZoneMapping.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ZoneMapping.Serialization.cs index faef9f48ffada..6af9e4158218e 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ZoneMapping.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ZoneMapping.Serialization.cs @@ -184,48 +184,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/PolicyAssignmentData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/PolicyAssignmentData.Serialization.cs index f2d653330732e..6171f84498959 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/PolicyAssignmentData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/PolicyAssignmentData.Serialization.cs @@ -457,7 +457,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, ManagedIdentity, options, 2, false, " identity: "); + BicepSerializationHelpers.AppendChildObject(builder, ManagedIdentity, options, 2, false, " identity: "); } } @@ -608,7 +608,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) foreach (var item in Parameters) { builder.Append($" '{item.Key}': "); - AppendChildObject(builder, item.Value, options, 6, false, " parameters: "); + BicepSerializationHelpers.AppendChildObject(builder, item.Value, options, 6, false, " parameters: "); } builder.AppendLine(" }"); } @@ -680,7 +680,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in NonComplianceMessages) { - AppendChildObject(builder, item, options, 6, true, " nonComplianceMessages: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 6, true, " nonComplianceMessages: "); } builder.AppendLine(" ]"); } @@ -702,7 +702,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in ResourceSelectors) { - AppendChildObject(builder, item, options, 6, true, " resourceSelectors: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 6, true, " resourceSelectors: "); } builder.AppendLine(" ]"); } @@ -724,7 +724,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in Overrides) { - AppendChildObject(builder, item, options, 6, true, " overrides: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 6, true, " overrides: "); } builder.AppendLine(" ]"); } @@ -736,48 +736,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/PolicyDefinitionData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/PolicyDefinitionData.Serialization.cs index a65ef6bf83dd7..c1ee9adf1d0e4 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/PolicyDefinitionData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/PolicyDefinitionData.Serialization.cs @@ -462,7 +462,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) foreach (var item in Parameters) { builder.Append($" '{item.Key}': "); - AppendChildObject(builder, item.Value, options, 6, false, " parameters: "); + BicepSerializationHelpers.AppendChildObject(builder, item.Value, options, 6, false, " parameters: "); } builder.AppendLine(" }"); } @@ -474,48 +474,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/PolicyDefinitionData.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/PolicyDefinitionData.cs index 6689f9af87fb4..e000130f771b8 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/PolicyDefinitionData.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/PolicyDefinitionData.cs @@ -8,6 +8,7 @@ using System; using System.Collections.Generic; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.Models; using Azure.ResourceManager.Resources.Models; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/PolicySetDefinitionData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/PolicySetDefinitionData.Serialization.cs index b884fe087b0ec..36f97a16fe467 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/PolicySetDefinitionData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/PolicySetDefinitionData.Serialization.cs @@ -443,7 +443,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) foreach (var item in Parameters) { builder.Append($" '{item.Key}': "); - AppendChildObject(builder, item.Value, options, 6, false, " parameters: "); + BicepSerializationHelpers.AppendChildObject(builder, item.Value, options, 6, false, " parameters: "); } builder.AppendLine(" }"); } @@ -465,7 +465,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in PolicyDefinitions) { - AppendChildObject(builder, item, options, 6, true, " policyDefinitions: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 6, true, " policyDefinitions: "); } builder.AppendLine(" ]"); } @@ -487,7 +487,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in PolicyDefinitionGroups) { - AppendChildObject(builder, item, options, 6, true, " policyDefinitionGroups: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 6, true, " policyDefinitionGroups: "); } builder.AppendLine(" ]"); } @@ -499,48 +499,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ResourceGroupData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ResourceGroupData.Serialization.cs index edf3160fa5890..1878d68630b67 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ResourceGroupData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ResourceGroupData.Serialization.cs @@ -289,7 +289,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Properties, options, 2, false, " properties: "); + BicepSerializationHelpers.AppendChildObject(builder, Properties, options, 2, false, " properties: "); } } @@ -347,48 +347,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ResourceProviderData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ResourceProviderData.Serialization.cs index bf208060b6cb0..5be3415bf8887 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ResourceProviderData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ResourceProviderData.Serialization.cs @@ -282,7 +282,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in ResourceTypes) { - AppendChildObject(builder, item, options, 4, true, " resourceTypes: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " resourceTypes: "); } builder.AppendLine(" ]"); } @@ -307,48 +307,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/RestOperations/ResourceManagementRestOperations.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/RestOperations/ResourceManagementRestOperations.cs index 261ba58b57df4..2397a0ab9c6ed 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/RestOperations/ResourceManagementRestOperations.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/RestOperations/ResourceManagementRestOperations.cs @@ -12,6 +12,7 @@ using Azure; using Azure.Core; using Azure.Core.Pipeline; +using Azure.ResourceManager; using Azure.ResourceManager.Resources.Models; namespace Azure.ResourceManager.Resources diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/SubscriptionData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/SubscriptionData.Serialization.cs index 3aaeef7c5e731..e0c153d9cc70d 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/SubscriptionData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/SubscriptionData.Serialization.cs @@ -246,42 +246,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("{"); - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tags), out propertyOverride); - if (Optional.IsCollectionDefined(Tags) || hasPropertyOverride) - { - if (Tags.Any() || hasPropertyOverride) - { - builder.Append(" tags: "); - if (hasPropertyOverride) - { - builder.AppendLine($"{propertyOverride}"); - } - else - { - builder.AppendLine("{"); - foreach (var item in Tags) - { - builder.Append($" '{item.Key}': "); - if (item.Value == null) - { - builder.Append("null"); - continue; - } - if (item.Value.Contains(Environment.NewLine)) - { - builder.AppendLine("'''"); - builder.AppendLine($"{item.Value}'''"); - } - else - { - builder.AppendLine($"'{item.Value}'"); - } - } - builder.AppendLine(" }"); - } - } - } - hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); if (Optional.IsDefined(Id) || hasPropertyOverride) { @@ -378,7 +342,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, SubscriptionPolicies, options, 2, false, " subscriptionPolicies: "); + BicepSerializationHelpers.AppendChildObject(builder, SubscriptionPolicies, options, 2, false, " subscriptionPolicies: "); } } @@ -419,57 +383,51 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) builder.AppendLine("["); foreach (var item in ManagedByTenants) { - AppendChildObject(builder, item, options, 4, true, " managedByTenants: "); + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " managedByTenants: "); } builder.AppendLine(" ]"); } } } - builder.AppendLine("}"); - return BinaryData.FromString(builder.ToString()); - } - - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tags), out propertyOverride); + if (Optional.IsCollectionDefined(Tags) || hasPropertyOverride) { - string line = lines[i]; - if (inMultilineString) + if (Tags.Any() || hasPropertyOverride) { - if (line.Contains("'''")) + builder.Append(" tags: "); + if (hasPropertyOverride) { - inMultilineString = false; + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("{"); + foreach (var item in Tags) + { + builder.Append($" '{item.Key}': "); + if (item.Value == null) + { + builder.Append("null"); + continue; + } + if (item.Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{item.Value}'''"); + } + else + { + builder.AppendLine($"'{item.Value}'"); + } + } + builder.AppendLine(" }"); } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); } } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/TagResourceData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/TagResourceData.Serialization.cs index 81ec021e92676..a69f670344801 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/TagResourceData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/TagResourceData.Serialization.cs @@ -186,7 +186,7 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } else { - AppendChildObject(builder, Properties, options, 2, false, " properties: "); + BicepSerializationHelpers.AppendChildObject(builder, Properties, options, 2, false, " properties: "); } } @@ -222,48 +222,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/TenantData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/TenantData.Serialization.cs index 30203c588a608..be446acc424e4 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/TenantData.Serialization.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/TenantData.Serialization.cs @@ -452,48 +452,6 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) return BinaryData.FromString(builder.ToString()); } - private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; From 11bfa613d35cc52784c18e0e61ba3dc2534b511c Mon Sep 17 00:00:00 2001 From: jolov Date: Thu, 14 Mar 2024 16:03:42 -0700 Subject: [PATCH 05/10] regen --- .../Internal/BicepSerializationHelpers.cs | 58 ------------------- .../Internal/BicepSerializationHelpers.cs | 58 ------------------- 2 files changed, 116 deletions(-) delete mode 100644 sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Internal/BicepSerializationHelpers.cs delete mode 100644 sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Internal/BicepSerializationHelpers.cs diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Internal/BicepSerializationHelpers.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Internal/BicepSerializationHelpers.cs deleted file mode 100644 index 054d4c0cd09a7..0000000000000 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Internal/BicepSerializationHelpers.cs +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Text; - -namespace Azure.ResourceManager -{ - internal static class BicepSerializationHelpers - { - public static void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - } -} diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Internal/BicepSerializationHelpers.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Internal/BicepSerializationHelpers.cs deleted file mode 100644 index 054d4c0cd09a7..0000000000000 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Internal/BicepSerializationHelpers.cs +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Text; - -namespace Azure.ResourceManager -{ - internal static class BicepSerializationHelpers - { - public static void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) - { - string indent = new string(' ', spaces); - int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; - int length = stringBuilder.Length; - bool inMultilineString = false; - - BinaryData data = ModelReaderWriter.Write(childObject, options); - string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < lines.Length; i++) - { - string line = lines[i]; - if (inMultilineString) - { - if (line.Contains("'''")) - { - inMultilineString = false; - } - stringBuilder.AppendLine(line); - continue; - } - if (line.Contains("'''")) - { - inMultilineString = true; - stringBuilder.AppendLine($"{indent}{line}"); - continue; - } - if (i == 0 && !indentFirstLine) - { - stringBuilder.AppendLine($"{line}"); - } - else - { - stringBuilder.AppendLine($"{indent}{line}"); - } - } - if (stringBuilder.Length == length + emptyObjectLength) - { - stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; - } - } - } -} From eb78921f20cfea82d2d19255bb24a924d2e0cdc9 Mon Sep 17 00:00:00 2001 From: jolov Date: Thu, 14 Mar 2024 16:06:00 -0700 Subject: [PATCH 06/10] revert nuget.config --- NuGet.Config | 1 - 1 file changed, 1 deletion(-) diff --git a/NuGet.Config b/NuGet.Config index 37856d3631c9d..fd5e01a144660 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -5,7 +5,6 @@ - From 2d60ec0b9758650979c49ecb8f6e5174795d2303 Mon Sep 17 00:00:00 2001 From: jolov Date: Thu, 14 Mar 2024 16:13:18 -0700 Subject: [PATCH 07/10] use correct autorest --- eng/Packages.Data.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/Packages.Data.props b/eng/Packages.Data.props index 8fa8b0a9b2000..8e15202ded99b 100644 --- a/eng/Packages.Data.props +++ b/eng/Packages.Data.props @@ -218,7 +218,7 @@ All should have PrivateAssets="All" set so they don't become package dependencies --> - + From 75e6feaa301daa1f234a7d76ac172c67e06536b2 Mon Sep 17 00:00:00 2001 From: jolov Date: Thu, 14 Mar 2024 16:26:10 -0700 Subject: [PATCH 08/10] changetrackingdictionary suppression --- .../Custom/HelperSuppressions.cs | 1 + .../Internal/ChangeTrackingDictionary.cs | 167 ------------------ .../Resources/Custom/HelperSuppressions.cs | 1 + .../Internal/ChangeTrackingDictionary.cs | 167 ------------------ 4 files changed, 2 insertions(+), 334 deletions(-) delete mode 100644 sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Internal/ChangeTrackingDictionary.cs delete mode 100644 sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Internal/ChangeTrackingDictionary.cs diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Custom/HelperSuppressions.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Custom/HelperSuppressions.cs index c9e61bbbd98c1..1b0fc69a8cff4 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Custom/HelperSuppressions.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Custom/HelperSuppressions.cs @@ -7,4 +7,5 @@ [assembly: CodeGenSuppressType("Azure.ResourceManager.ChangeTrackingList")] [assembly: CodeGenSuppressType("Azure.ResourceManager.RequestContentHelper")] [assembly: CodeGenSuppressType("Azure.ResourceManager.Argument")] +[assembly: CodeGenSuppressType("Azure.ResourceManager.ChangeTrackingDictionary")] [assembly: CodeGenSuppressType("Azure.ResourceManager.BicepSerializationHelpers")] diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Internal/ChangeTrackingDictionary.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Internal/ChangeTrackingDictionary.cs deleted file mode 100644 index 3e0457dd8331c..0000000000000 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Internal/ChangeTrackingDictionary.cs +++ /dev/null @@ -1,167 +0,0 @@ -// 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 -{ - 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/resourcemanager/Azure.ResourceManager/src/Resources/Custom/HelperSuppressions.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Custom/HelperSuppressions.cs index c9e61bbbd98c1..1b0fc69a8cff4 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Custom/HelperSuppressions.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Custom/HelperSuppressions.cs @@ -7,4 +7,5 @@ [assembly: CodeGenSuppressType("Azure.ResourceManager.ChangeTrackingList")] [assembly: CodeGenSuppressType("Azure.ResourceManager.RequestContentHelper")] [assembly: CodeGenSuppressType("Azure.ResourceManager.Argument")] +[assembly: CodeGenSuppressType("Azure.ResourceManager.ChangeTrackingDictionary")] [assembly: CodeGenSuppressType("Azure.ResourceManager.BicepSerializationHelpers")] diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Internal/ChangeTrackingDictionary.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Internal/ChangeTrackingDictionary.cs deleted file mode 100644 index 3e0457dd8331c..0000000000000 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Internal/ChangeTrackingDictionary.cs +++ /dev/null @@ -1,167 +0,0 @@ -// 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 -{ - 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(); - } - } -} From c76c299bb8207e0169731bc0ba8e312556dc0a75 Mon Sep 17 00:00:00 2001 From: jolov Date: Thu, 14 Mar 2024 17:14:46 -0700 Subject: [PATCH 09/10] add helper suppression --- .../src/ManagementGroup/Custom/HelperSuppressions.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Custom/HelperSuppressions.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Custom/HelperSuppressions.cs index 1b0fc69a8cff4..c565508b7ab3a 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Custom/HelperSuppressions.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Custom/HelperSuppressions.cs @@ -7,5 +7,6 @@ [assembly: CodeGenSuppressType("Azure.ResourceManager.ChangeTrackingList")] [assembly: CodeGenSuppressType("Azure.ResourceManager.RequestContentHelper")] [assembly: CodeGenSuppressType("Azure.ResourceManager.Argument")] +[assembly: CodeGenSuppressType("Azure.ResourceManager.Utf8JsonRequestContent")] [assembly: CodeGenSuppressType("Azure.ResourceManager.ChangeTrackingDictionary")] [assembly: CodeGenSuppressType("Azure.ResourceManager.BicepSerializationHelpers")] From 418646339ac39a442fc4cfd8425cb0a8549823b3 Mon Sep 17 00:00:00 2001 From: jolov Date: Thu, 14 Mar 2024 19:59:41 -0700 Subject: [PATCH 10/10] regen --- .../Internal/Utf8JsonRequestContent.cs | 55 ------------------- .../Resources/Custom/HelperSuppressions.cs | 1 + .../Internal/Utf8JsonRequestContent.cs | 55 ------------------- 3 files changed, 1 insertion(+), 110 deletions(-) delete mode 100644 sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Internal/Utf8JsonRequestContent.cs delete mode 100644 sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Internal/Utf8JsonRequestContent.cs diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Internal/Utf8JsonRequestContent.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Internal/Utf8JsonRequestContent.cs deleted file mode 100644 index c0ffe14923189..0000000000000 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Internal/Utf8JsonRequestContent.cs +++ /dev/null @@ -1,55 +0,0 @@ -// 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 -{ - 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/resourcemanager/Azure.ResourceManager/src/Resources/Custom/HelperSuppressions.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Custom/HelperSuppressions.cs index 1b0fc69a8cff4..cbc5891380e6e 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Custom/HelperSuppressions.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Custom/HelperSuppressions.cs @@ -8,4 +8,5 @@ [assembly: CodeGenSuppressType("Azure.ResourceManager.RequestContentHelper")] [assembly: CodeGenSuppressType("Azure.ResourceManager.Argument")] [assembly: CodeGenSuppressType("Azure.ResourceManager.ChangeTrackingDictionary")] +[assembly: CodeGenSuppressType("Azure.ResourceManager.Utf8JsonRequestContent")] [assembly: CodeGenSuppressType("Azure.ResourceManager.BicepSerializationHelpers")] diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Internal/Utf8JsonRequestContent.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Internal/Utf8JsonRequestContent.cs deleted file mode 100644 index c0ffe14923189..0000000000000 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Internal/Utf8JsonRequestContent.cs +++ /dev/null @@ -1,55 +0,0 @@ -// 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 -{ - 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(); - } - } -}