From 6008fb58ef2b28fb0ffce090de6f6f8c5f70555d Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Thu, 8 May 2025 13:43:37 +0000 Subject: [PATCH] CodeGen from PR 34440 in Azure/azure-rest-api-specs Merge 8f1f4b4fc44d28e721b477f8adfdf53ac7a5f9a4 into 9dddeb9b39af228f444c2d375d0edf51883f6d76 --- eng/versioning/version_client.txt | 1 + pom.xml | 1 + .../CHANGELOG.md | 8 + .../README.md | 102 ++ .../SAMPLE.md | 859 +++++++++++ .../azure-resourcemanager-cloudhealth/pom.xml | 74 + .../cloudhealth/CloudHealthManager.java | 378 +++++ .../fluent/AuthenticationSettingsClient.java | 137 ++ .../cloudhealth/fluent/CloudHealthClient.java | 97 ++ .../fluent/DiscoveryRulesClient.java | 142 ++ .../cloudhealth/fluent/EntitiesClient.java | 140 ++ .../fluent/HealthModelsClient.java | 269 ++++ .../cloudhealth/fluent/OperationsClient.java | 40 + .../fluent/RelationshipsClient.java | 146 ++ .../fluent/SignalDefinitionsClient.java | 140 ++ .../models/AuthenticationSettingInner.java | 167 +++ .../fluent/models/DiscoveryRuleInner.java | 167 +++ .../fluent/models/EntityInner.java | 166 +++ .../fluent/models/HealthModelInner.java | 224 +++ .../fluent/models/OperationInner.java | 161 +++ .../fluent/models/RelationshipInner.java | 166 +++ .../fluent/models/SignalDefinitionInner.java | 166 +++ .../fluent/models/package-info.java | 8 + .../cloudhealth/fluent/package-info.java | 8 + .../AuthenticationSettingImpl.java | 139 ++ .../AuthenticationSettingsClientImpl.java | 750 ++++++++++ .../AuthenticationSettingsImpl.java | 164 +++ .../CloudHealthClientBuilder.java | 138 ++ .../implementation/CloudHealthClientImpl.java | 384 +++++ .../implementation/DiscoveryRuleImpl.java | 137 ++ .../DiscoveryRulesClientImpl.java | 775 ++++++++++ .../implementation/DiscoveryRulesImpl.java | 161 +++ .../implementation/EntitiesClientImpl.java | 761 ++++++++++ .../implementation/EntitiesImpl.java | 160 ++ .../implementation/EntityImpl.java | 132 ++ .../implementation/HealthModelImpl.java | 198 +++ .../HealthModelsClientImpl.java | 1288 +++++++++++++++++ .../implementation/HealthModelsImpl.java | 146 ++ .../implementation/OperationImpl.java | 50 + .../implementation/OperationsClientImpl.java | 235 +++ .../implementation/OperationsImpl.java | 45 + .../implementation/RelationshipImpl.java | 137 ++ .../RelationshipsClientImpl.java | 790 ++++++++++ .../implementation/RelationshipsImpl.java | 161 +++ .../implementation/ResourceManagerUtils.java | 195 +++ .../implementation/SignalDefinitionImpl.java | 138 ++ .../SignalDefinitionsClientImpl.java | 772 ++++++++++ .../implementation/SignalDefinitionsImpl.java | 163 +++ .../AuthenticationSettingListResult.java | 115 ++ .../models/DiscoveryRuleListResult.java | 112 ++ .../models/EntityListResult.java | 112 ++ .../models/HealthModelListResult.java | 112 ++ .../models/OperationListResult.java | 113 ++ .../models/RelationshipListResult.java | 112 ++ .../models/SignalDefinitionListResult.java | 114 ++ .../implementation/package-info.java | 8 + .../cloudhealth/models/ActionType.java | 46 + .../models/AlertConfiguration.java | 162 +++ .../cloudhealth/models/AlertSeverity.java | 66 + .../models/AuthenticationKind.java | 46 + .../models/AuthenticationSetting.java | 189 +++ .../AuthenticationSettingProperties.java | 166 +++ .../models/AuthenticationSettings.java | 148 ++ .../AzureMonitorWorkspaceSignalGroup.java | 176 +++ .../models/AzureResourceSignalGroup.java | 174 +++ .../models/DependenciesAggregationType.java | 51 + .../models/DependenciesSignalGroup.java | 178 +++ .../cloudhealth/models/DiscoveryRule.java | 189 +++ .../models/DiscoveryRuleProperties.java | 331 +++++ ...scoveryRuleRecommendedSignalsBehavior.java | 52 + ...veryRuleRelationshipDiscoveryBehavior.java | 52 + .../cloudhealth/models/DiscoveryRules.java | 151 ++ .../models/DynamicDetectionRule.java | 204 +++ .../models/DynamicThresholdDirection.java | 56 + .../models/DynamicThresholdModel.java | 46 + .../cloudhealth/models/Entities.java | 151 ++ .../cloudhealth/models/Entity.java | 189 +++ .../cloudhealth/models/EntityAlerts.java | 127 ++ .../cloudhealth/models/EntityCoordinates.java | 122 ++ .../cloudhealth/models/EntityImpact.java | 56 + .../cloudhealth/models/EntityProperties.java | 399 +++++ .../cloudhealth/models/EvaluationRule.java | 164 +++ .../cloudhealth/models/HealthModel.java | 299 ++++ .../models/HealthModelProperties.java | 132 ++ .../models/HealthModelProvisioningState.java | 66 + .../cloudhealth/models/HealthModelUpdate.java | 157 ++ .../models/HealthModelUpdateProperties.java | 99 ++ .../cloudhealth/models/HealthModels.java | 158 ++ .../cloudhealth/models/HealthState.java | 66 + .../cloudhealth/models/IconDefinition.java | 129 ++ ...lyticsQuerySignalDefinitionProperties.java | 261 ++++ .../models/LogAnalyticsSignalGroup.java | 174 +++ ...entityAuthenticationSettingProperties.java | 140 ++ .../models/ManagedServiceIdentity.java | 176 +++ .../models/ManagedServiceIdentityType.java | 62 + .../models/MetricAggregationType.java | 71 + .../models/ModelDiscoverySettings.java | 174 +++ .../cloudhealth/models/Operation.java | 58 + .../cloudhealth/models/OperationDisplay.java | 136 ++ .../cloudhealth/models/Operations.java | 35 + .../cloudhealth/models/Origin.java | 57 + ...heusMetricsSignalDefinitionProperties.java | 228 +++ .../cloudhealth/models/RefreshInterval.java | 71 + .../cloudhealth/models/Relationship.java | 189 +++ .../models/RelationshipProperties.java | 246 ++++ .../cloudhealth/models/Relationships.java | 155 ++ ...ourceMetricSignalDefinitionProperties.java | 359 +++++ .../cloudhealth/models/SignalAssignment.java | 107 ++ .../cloudhealth/models/SignalDefinition.java | 189 +++ .../models/SignalDefinitionProperties.java | 324 +++++ .../cloudhealth/models/SignalDefinitions.java | 151 ++ .../cloudhealth/models/SignalGroup.java | 192 +++ .../cloudhealth/models/SignalKind.java | 56 + .../cloudhealth/models/SignalOperator.java | 66 + .../cloudhealth/models/ThresholdRule.java | 133 ++ .../models/UserAssignedIdentity.java | 97 ++ .../cloudhealth/models/package-info.java | 8 + .../cloudhealth/package-info.java | 8 + .../src/main/java/module-info.java | 16 + .../proxy-config.json | 1 + .../reflect-config.json | 1 + ...ure-resourcemanager-cloudhealth.properties | 1 + ...ticationSettingsCreateOrUpdateSamples.java | 30 + .../AuthenticationSettingsDeleteSamples.java | 24 + .../AuthenticationSettingsGetSamples.java | 24 + ...ationSettingsListByHealthModelSamples.java | 24 + .../DiscoveryRulesCreateOrUpdateSamples.java | 35 + .../DiscoveryRulesDeleteSamples.java | 24 + .../generated/DiscoveryRulesGetSamples.java | 23 + ...iscoveryRulesListByHealthModelSamples.java | 24 + .../EntitiesCreateOrUpdateSamples.java | 90 ++ .../generated/EntitiesDeleteSamples.java | 24 + .../generated/EntitiesGetSamples.java | 22 + .../EntitiesListByHealthModelSamples.java | 24 + .../generated/HealthModelsCreateSamples.java | 57 + .../generated/HealthModelsDeleteSamples.java | 22 + ...HealthModelsGetByResourceGroupSamples.java | 23 + ...ealthModelsListByResourceGroupSamples.java | 23 + .../generated/HealthModelsListSamples.java | 23 + .../generated/HealthModelsUpdateSamples.java | 51 + .../generated/OperationsListSamples.java | 22 + .../RelationshipsCreateOrUpdateSamples.java | 45 + .../generated/RelationshipsDeleteSamples.java | 22 + .../generated/RelationshipsGetSamples.java | 24 + ...RelationshipsListByHealthModelSamples.java | 23 + ...ignalDefinitionsCreateOrUpdateSamples.java | 60 + .../SignalDefinitionsDeleteSamples.java | 22 + .../SignalDefinitionsGetSamples.java | 23 + ...alDefinitionsListByHealthModelSamples.java | 24 + .../generated/AlertConfigurationTests.java | 35 + .../AuthenticationSettingInnerTests.java | 28 + .../AuthenticationSettingListResultTests.java | 20 + .../AuthenticationSettingPropertiesTests.java | 27 + ...gsCreateOrUpdateWithResponseMockTests.java | 42 + ...onSettingsDeleteWithResponseMockTests.java | 34 + ...ationSettingsGetWithResponseMockTests.java | 39 + ...ionSettingsListByHealthModelMockTests.java | 39 + ...AzureMonitorWorkspaceSignalGroupTests.java | 38 + .../AzureResourceSignalGroupTests.java | 39 + .../DependenciesSignalGroupTests.java | 34 + .../generated/DiscoveryRuleInnerTests.java | 46 + .../DiscoveryRuleListResultTests.java | 28 + .../DiscoveryRulePropertiesTests.java | 40 + ...esCreateOrUpdateWithResponseMockTests.java | 54 + ...overyRulesDeleteWithResponseMockTests.java | 33 + ...iscoveryRulesGetWithResponseMockTests.java | 47 + ...coveryRulesListByHealthModelMockTests.java | 48 + .../generated/DynamicDetectionRuleTests.java | 39 + ...esCreateOrUpdateWithResponseMockTests.java | 135 ++ .../EntitiesDeleteWithResponseMockTests.java | 33 + .../EntitiesGetWithResponseMockTests.java | 71 + .../EntitiesListByHealthModelMockTests.java | 85 ++ .../generated/EntityAlertsTests.java | 45 + .../generated/EntityCoordinatesTests.java | 27 + .../generated/EntityInnerTests.java | 170 +++ .../generated/EntityListResultTests.java | 57 + .../generated/EntityPropertiesTests.java | 157 ++ .../generated/EvaluationRuleTests.java | 60 + .../generated/HealthModelInnerTests.java | 69 + .../generated/HealthModelListResultTests.java | 28 + .../generated/HealthModelPropertiesTests.java | 37 + .../HealthModelUpdatePropertiesTests.java | 37 + .../generated/HealthModelUpdateTests.java | 65 + .../HealthModelsCreateMockTests.java | 74 + ...tByResourceGroupWithResponseMockTests.java | 47 + ...lthModelsListByResourceGroupMockTests.java | 48 + .../generated/HealthModelsListMockTests.java | 46 + .../generated/IconDefinitionTests.java | 27 + ...sQuerySignalDefinitionPropertiesTests.java | 98 ++ .../LogAnalyticsSignalGroupTests.java | 38 + ...yAuthenticationSettingPropertiesTests.java | 30 + .../ManagedServiceIdentityTests.java | 45 + .../ModelDiscoverySettingsTests.java | 33 + .../generated/OperationDisplayTests.java | 17 + .../generated/OperationInnerTests.java | 17 + .../generated/OperationListResultTests.java | 19 + .../generated/OperationsListMockTests.java | 36 + ...etricsSignalDefinitionPropertiesTests.java | 95 ++ .../generated/RelationshipInnerTests.java | 51 + .../RelationshipListResultTests.java | 23 + .../RelationshipPropertiesTests.java | 49 + ...psCreateOrUpdateWithResponseMockTests.java | 63 + ...ationshipsDeleteWithResponseMockTests.java | 34 + ...RelationshipsGetWithResponseMockTests.java | 42 + ...lationshipsListByHealthModelMockTests.java | 43 + ...MetricSignalDefinitionPropertiesTests.java | 110 ++ .../generated/SignalAssignmentTests.java | 28 + .../generated/SignalDefinitionInnerTests.java | 97 ++ .../SignalDefinitionListResultTests.java | 44 + .../SignalDefinitionPropertiesTests.java | 88 ++ ...nsCreateOrUpdateWithResponseMockTests.java | 93 ++ ...efinitionsDeleteWithResponseMockTests.java | 34 + ...alDefinitionsGetWithResponseMockTests.java | 60 + ...DefinitionsListByHealthModelMockTests.java | 68 + .../generated/SignalGroupTests.java | 83 ++ .../generated/ThresholdRuleTests.java | 28 + .../generated/UserAssignedIdentityTests.java | 22 + .../tsp-location.yaml | 4 + sdk/cloudhealth/ci.yml | 46 + sdk/cloudhealth/pom.xml | 15 + 220 files changed, 25736 insertions(+) create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/CHANGELOG.md create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/README.md create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/SAMPLE.md create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/pom.xml create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/CloudHealthManager.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/AuthenticationSettingsClient.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/CloudHealthClient.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/DiscoveryRulesClient.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/EntitiesClient.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/HealthModelsClient.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/OperationsClient.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/RelationshipsClient.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/SignalDefinitionsClient.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/models/AuthenticationSettingInner.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/models/DiscoveryRuleInner.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/models/EntityInner.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/models/HealthModelInner.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/models/OperationInner.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/models/RelationshipInner.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/models/SignalDefinitionInner.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/models/package-info.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/package-info.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/AuthenticationSettingImpl.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/AuthenticationSettingsClientImpl.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/AuthenticationSettingsImpl.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/CloudHealthClientBuilder.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/CloudHealthClientImpl.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/DiscoveryRuleImpl.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/DiscoveryRulesClientImpl.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/DiscoveryRulesImpl.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/EntitiesClientImpl.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/EntitiesImpl.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/EntityImpl.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/HealthModelImpl.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/HealthModelsClientImpl.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/HealthModelsImpl.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/OperationImpl.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/OperationsClientImpl.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/OperationsImpl.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/RelationshipImpl.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/RelationshipsClientImpl.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/RelationshipsImpl.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/ResourceManagerUtils.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/SignalDefinitionImpl.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/SignalDefinitionsClientImpl.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/SignalDefinitionsImpl.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/models/AuthenticationSettingListResult.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/models/DiscoveryRuleListResult.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/models/EntityListResult.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/models/HealthModelListResult.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/models/OperationListResult.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/models/RelationshipListResult.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/models/SignalDefinitionListResult.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/package-info.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/ActionType.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/AlertConfiguration.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/AlertSeverity.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/AuthenticationKind.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/AuthenticationSetting.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/AuthenticationSettingProperties.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/AuthenticationSettings.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/AzureMonitorWorkspaceSignalGroup.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/AzureResourceSignalGroup.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/DependenciesAggregationType.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/DependenciesSignalGroup.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/DiscoveryRule.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/DiscoveryRuleProperties.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/DiscoveryRuleRecommendedSignalsBehavior.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/DiscoveryRuleRelationshipDiscoveryBehavior.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/DiscoveryRules.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/DynamicDetectionRule.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/DynamicThresholdDirection.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/DynamicThresholdModel.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/Entities.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/Entity.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/EntityAlerts.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/EntityCoordinates.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/EntityImpact.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/EntityProperties.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/EvaluationRule.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/HealthModel.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/HealthModelProperties.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/HealthModelProvisioningState.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/HealthModelUpdate.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/HealthModelUpdateProperties.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/HealthModels.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/HealthState.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/IconDefinition.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/LogAnalyticsQuerySignalDefinitionProperties.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/LogAnalyticsSignalGroup.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/ManagedIdentityAuthenticationSettingProperties.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/ManagedServiceIdentity.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/ManagedServiceIdentityType.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/MetricAggregationType.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/ModelDiscoverySettings.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/Operation.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/OperationDisplay.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/Operations.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/Origin.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/PrometheusMetricsSignalDefinitionProperties.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/RefreshInterval.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/Relationship.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/RelationshipProperties.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/Relationships.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/ResourceMetricSignalDefinitionProperties.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/SignalAssignment.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/SignalDefinition.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/SignalDefinitionProperties.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/SignalDefinitions.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/SignalGroup.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/SignalKind.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/SignalOperator.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/ThresholdRule.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/UserAssignedIdentity.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/package-info.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/package-info.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/module-info.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-cloudhealth/proxy-config.json create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-cloudhealth/reflect-config.json create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/resources/azure-resourcemanager-cloudhealth.properties create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/AuthenticationSettingsCreateOrUpdateSamples.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/AuthenticationSettingsDeleteSamples.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/AuthenticationSettingsGetSamples.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/AuthenticationSettingsListByHealthModelSamples.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/DiscoveryRulesCreateOrUpdateSamples.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/DiscoveryRulesDeleteSamples.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/DiscoveryRulesGetSamples.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/DiscoveryRulesListByHealthModelSamples.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/EntitiesCreateOrUpdateSamples.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/EntitiesDeleteSamples.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/EntitiesGetSamples.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/EntitiesListByHealthModelSamples.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelsCreateSamples.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelsDeleteSamples.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelsGetByResourceGroupSamples.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelsListByResourceGroupSamples.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelsListSamples.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelsUpdateSamples.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/OperationsListSamples.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/RelationshipsCreateOrUpdateSamples.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/RelationshipsDeleteSamples.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/RelationshipsGetSamples.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/RelationshipsListByHealthModelSamples.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/SignalDefinitionsCreateOrUpdateSamples.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/SignalDefinitionsDeleteSamples.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/SignalDefinitionsGetSamples.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/SignalDefinitionsListByHealthModelSamples.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/AlertConfigurationTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/AuthenticationSettingInnerTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/AuthenticationSettingListResultTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/AuthenticationSettingPropertiesTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/AuthenticationSettingsCreateOrUpdateWithResponseMockTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/AuthenticationSettingsDeleteWithResponseMockTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/AuthenticationSettingsGetWithResponseMockTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/AuthenticationSettingsListByHealthModelMockTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/AzureMonitorWorkspaceSignalGroupTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/AzureResourceSignalGroupTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/DependenciesSignalGroupTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/DiscoveryRuleInnerTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/DiscoveryRuleListResultTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/DiscoveryRulePropertiesTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/DiscoveryRulesCreateOrUpdateWithResponseMockTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/DiscoveryRulesDeleteWithResponseMockTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/DiscoveryRulesGetWithResponseMockTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/DiscoveryRulesListByHealthModelMockTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/DynamicDetectionRuleTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/EntitiesCreateOrUpdateWithResponseMockTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/EntitiesDeleteWithResponseMockTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/EntitiesGetWithResponseMockTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/EntitiesListByHealthModelMockTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/EntityAlertsTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/EntityCoordinatesTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/EntityInnerTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/EntityListResultTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/EntityPropertiesTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/EvaluationRuleTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelInnerTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelListResultTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelPropertiesTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelUpdatePropertiesTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelUpdateTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelsCreateMockTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelsGetByResourceGroupWithResponseMockTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelsListByResourceGroupMockTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelsListMockTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/IconDefinitionTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/LogAnalyticsQuerySignalDefinitionPropertiesTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/LogAnalyticsSignalGroupTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/ManagedIdentityAuthenticationSettingPropertiesTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/ManagedServiceIdentityTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/ModelDiscoverySettingsTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/OperationDisplayTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/OperationInnerTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/OperationListResultTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/OperationsListMockTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/PrometheusMetricsSignalDefinitionPropertiesTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/RelationshipInnerTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/RelationshipListResultTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/RelationshipPropertiesTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/RelationshipsCreateOrUpdateWithResponseMockTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/RelationshipsDeleteWithResponseMockTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/RelationshipsGetWithResponseMockTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/RelationshipsListByHealthModelMockTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/ResourceMetricSignalDefinitionPropertiesTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/SignalAssignmentTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/SignalDefinitionInnerTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/SignalDefinitionListResultTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/SignalDefinitionPropertiesTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/SignalDefinitionsCreateOrUpdateWithResponseMockTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/SignalDefinitionsDeleteWithResponseMockTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/SignalDefinitionsGetWithResponseMockTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/SignalDefinitionsListByHealthModelMockTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/SignalGroupTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/ThresholdRuleTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/UserAssignedIdentityTests.java create mode 100644 sdk/cloudhealth/azure-resourcemanager-cloudhealth/tsp-location.yaml create mode 100644 sdk/cloudhealth/ci.yml create mode 100644 sdk/cloudhealth/pom.xml diff --git a/eng/versioning/version_client.txt b/eng/versioning/version_client.txt index 4a90a182f7a0..0d5a641e8cfc 100644 --- a/eng/versioning/version_client.txt +++ b/eng/versioning/version_client.txt @@ -481,6 +481,7 @@ com.azure.resourcemanager:azure-resourcemanager-onlineexperimentation;1.0.0-beta com.azure.resourcemanager:azure-resourcemanager-secretsstoreextension;1.0.0-beta.1;1.0.0-beta.1 com.azure.resourcemanager:azure-resourcemanager-programmableconnectivity;1.0.0-beta.1;1.0.0-beta.1 com.azure.resourcemanager:azure-resourcemanager-dell-storage;1.0.0-beta.1;1.0.0-beta.1 +com.azure.resourcemanager:azure-resourcemanager-cloudhealth;1.0.0-beta.1;1.0.0-beta.1 com.azure.tools:azure-sdk-archetype;1.0.0;1.2.0-beta.1 com.azure.tools:azure-sdk-build-tool;1.0.0;1.1.0-beta.1 com.azure.v2:azure-client-sdk-parent;2.0.0-beta.1;2.0.0-beta.1 diff --git a/pom.xml b/pom.xml index d3143f80bf28..86f6f1c379a9 100644 --- a/pom.xml +++ b/pom.xml @@ -42,6 +42,7 @@ sdk/changeanalysis sdk/chaos sdk/clientcore + sdk/cloudhealth sdk/cognitiveservices sdk/commerce sdk/communication diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/CHANGELOG.md b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/CHANGELOG.md new file mode 100644 index 000000000000..4da5c9f9a3a6 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/CHANGELOG.md @@ -0,0 +1,8 @@ +# Release History + +## 1.0.0-beta.1 (2025-05-08) + +- Azure Resource Manager CloudHealth client library for Java. This package contains Microsoft Azure SDK for CloudHealth Management SDK. For documentation on how to use this package, please see [Azure Management Libraries for Java](https://aka.ms/azsdk/java/mgmt). +### Features Added + +- Initial release for the azure-resourcemanager-cloudhealth Java SDK. diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/README.md b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/README.md new file mode 100644 index 000000000000..7a07662696b5 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/README.md @@ -0,0 +1,102 @@ +# Azure Resource Manager CloudHealth client library for Java + +Azure Resource Manager CloudHealth client library for Java. + +This package contains Microsoft Azure SDK for CloudHealth Management SDK. For documentation on how to use this package, please see [Azure Management Libraries for Java](https://aka.ms/azsdk/java/mgmt). + +## We'd love to hear your feedback + +We're always working on improving our products and the way we communicate with our users. So we'd love to learn what's working and how we can do better. + +If you haven't already, please take a few minutes to [complete this short survey][survey] we have put together. + +Thank you in advance for your collaboration. We really appreciate your time! + +## Documentation + +Various documentation is available to help you get started + +- [API reference documentation][docs] + +## Getting started + +### Prerequisites + +- [Java Development Kit (JDK)][jdk] with version 8 or above +- [Azure Subscription][azure_subscription] + +### Adding the package to your product + +[//]: # ({x-version-update-start;com.azure.resourcemanager:azure-resourcemanager-cloudhealth;current}) +```xml + + com.azure.resourcemanager + azure-resourcemanager-cloudhealth + 1.0.0-beta.1 + +``` +[//]: # ({x-version-update-end}) + +### Include the recommended packages + +Azure Management Libraries require a `TokenCredential` implementation for authentication and an `HttpClient` implementation for HTTP client. + +[Azure Identity][azure_identity] and [Azure Core Netty HTTP][azure_core_http_netty] packages provide the default implementation. + +### Authentication + +Microsoft Entra ID token authentication relies on the [credential class][azure_identity_credentials] from [Azure Identity][azure_identity] package. + +Azure subscription ID can be configured via `AZURE_SUBSCRIPTION_ID` environment variable. + +Assuming the use of the `DefaultAzureCredential` credential class, the client can be authenticated using the following code: + +```java +AzureProfile profile = new AzureProfile(AzureCloud.AZURE_PUBLIC_CLOUD); +TokenCredential credential = new DefaultAzureCredentialBuilder() + .authorityHost(profile.getEnvironment().getActiveDirectoryEndpoint()) + .build(); +CloudHealthManager manager = CloudHealthManager + .authenticate(credential, profile); +``` + +The sample code assumes global Azure. Please change the `AzureCloud.AZURE_PUBLIC_CLOUD` variable if otherwise. + +See [Authentication][authenticate] for more options. + +## Key concepts + +See [API design][design] for general introduction on design and key concepts on Azure Management Libraries. + +## Examples + +[Code snippets and samples](https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/cloudhealth/azure-resourcemanager-cloudhealth/SAMPLE.md) + + +## Troubleshooting + +## Next steps + +## Contributing + +For details on contributing to this repository, see the [contributing guide][cg]. + +This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit . + +When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repositories using our CLA. + +This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For more information see the [Code of Conduct FAQ][coc_faq] or contact with any additional questions or comments. + + +[survey]: https://microsoft.qualtrics.com/jfe/form/SV_ehN0lIk2FKEBkwd?Q_CHL=DOCS +[docs]: https://azure.github.io/azure-sdk-for-java/ +[jdk]: https://learn.microsoft.com/azure/developer/java/fundamentals/ +[azure_subscription]: https://azure.microsoft.com/free/ +[azure_identity]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/identity/azure-identity +[azure_identity_credentials]: https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/identity/azure-identity#credentials +[azure_core_http_netty]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/core/azure-core-http-netty +[authenticate]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/resourcemanager/docs/AUTH.md +[design]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/resourcemanager/docs/DESIGN.md +[cg]: https://github.com/Azure/azure-sdk-for-java/blob/main/CONTRIBUTING.md +[coc]: https://opensource.microsoft.com/codeofconduct/ +[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/ diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/SAMPLE.md b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/SAMPLE.md new file mode 100644 index 000000000000..d32098551308 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/SAMPLE.md @@ -0,0 +1,859 @@ +# Code snippets and samples + + +## AuthenticationSettings + +- [CreateOrUpdate](#authenticationsettings_createorupdate) +- [Delete](#authenticationsettings_delete) +- [Get](#authenticationsettings_get) +- [ListByHealthModel](#authenticationsettings_listbyhealthmodel) + +## DiscoveryRules + +- [CreateOrUpdate](#discoveryrules_createorupdate) +- [Delete](#discoveryrules_delete) +- [Get](#discoveryrules_get) +- [ListByHealthModel](#discoveryrules_listbyhealthmodel) + +## Entities + +- [CreateOrUpdate](#entities_createorupdate) +- [Delete](#entities_delete) +- [Get](#entities_get) +- [ListByHealthModel](#entities_listbyhealthmodel) + +## HealthModels + +- [Create](#healthmodels_create) +- [Delete](#healthmodels_delete) +- [GetByResourceGroup](#healthmodels_getbyresourcegroup) +- [List](#healthmodels_list) +- [ListByResourceGroup](#healthmodels_listbyresourcegroup) +- [Update](#healthmodels_update) + +## Operations + +- [List](#operations_list) + +## Relationships + +- [CreateOrUpdate](#relationships_createorupdate) +- [Delete](#relationships_delete) +- [Get](#relationships_get) +- [ListByHealthModel](#relationships_listbyhealthmodel) + +## SignalDefinitions + +- [CreateOrUpdate](#signaldefinitions_createorupdate) +- [Delete](#signaldefinitions_delete) +- [Get](#signaldefinitions_get) +- [ListByHealthModel](#signaldefinitions_listbyhealthmodel) +### AuthenticationSettings_CreateOrUpdate + +```java +/** + * Samples for AuthenticationSettings ListByHealthModel. + */ +public final class AuthenticationSettingsListByHealthModelSamples { + /* + * x-ms-original-file: 2023-10-01-preview/AuthenticationSettings_ListByHealthModel.json + */ + /** + * Sample code: AuthenticationSettings_ListByHealthModel. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void + authenticationSettingsListByHealthModel(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.authenticationSettings() + .listByHealthModel("my-resource-group", "my-health-model", com.azure.core.util.Context.NONE); + } +} +``` + +### AuthenticationSettings_Delete + +```java +/** + * Samples for HealthModels ListByResourceGroup. + */ +public final class HealthModelsListByResourceGroupSamples { + /* + * x-ms-original-file: 2023-10-01-preview/HealthModels_ListByResourceGroup.json + */ + /** + * Sample code: HealthModels_ListByResourceGroup. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void + healthModelsListByResourceGroup(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.healthModels().listByResourceGroup("rgopenapi", com.azure.core.util.Context.NONE); + } +} +``` + +### AuthenticationSettings_Get + +```java +/** + * Samples for Operations List. + */ +public final class OperationsListSamples { + /* + * x-ms-original-file: 2023-10-01-preview/Operations_List.json + */ + /** + * Sample code: Operations_List. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void operationsList(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.operations().list(com.azure.core.util.Context.NONE); + } +} +``` + +### AuthenticationSettings_ListByHealthModel + +```java + +/** + * Samples for Relationships ListByHealthModel. + */ +public final class RelationshipsListByHealthModelSamples { + /* + * x-ms-original-file: 2023-10-01-preview/Relationships_ListByHealthModel.json + */ + /** + * Sample code: Relationships_ListByHealthModel. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void + relationshipsListByHealthModel(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.relationships().listByHealthModel("rgopenapi", "model1", null, com.azure.core.util.Context.NONE); + } +} +``` + +### DiscoveryRules_CreateOrUpdate + +```java +import com.azure.resourcemanager.cloudhealth.models.DiscoveryRuleRecommendedSignalsBehavior; +import com.azure.resourcemanager.cloudhealth.models.HealthModelProperties; +import com.azure.resourcemanager.cloudhealth.models.ManagedServiceIdentity; +import com.azure.resourcemanager.cloudhealth.models.ManagedServiceIdentityType; +import com.azure.resourcemanager.cloudhealth.models.ModelDiscoverySettings; +import com.azure.resourcemanager.cloudhealth.models.UserAssignedIdentity; +import java.util.HashMap; +import java.util.Map; + +/** + * Samples for HealthModels Create. + */ +public final class HealthModelsCreateSamples { + /* + * x-ms-original-file: 2023-10-01-preview/HealthModels_Create.json + */ + /** + * Sample code: HealthModels_Create. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void healthModelsCreate(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.healthModels() + .define("model1") + .withRegion("eastus2") + .withExistingResourceGroup("rgopenapi") + .withTags(mapOf("key2961", "fakeTokenPlaceholder")) + .withProperties(new HealthModelProperties().withDiscovery( + new ModelDiscoverySettings().withScope("/providers/Microsoft.Management/serviceGroups/myServiceGroup") + .withAddRecommendedSignals(DiscoveryRuleRecommendedSignalsBehavior.ENABLED) + .withIdentity("SystemAssigned"))) + .withIdentity(new ManagedServiceIdentity() + .withType(ManagedServiceIdentityType.fromString("SystemAssigned, UserAssigned")) + .withUserAssignedIdentities(mapOf( + "/subscriptions/4980D7D5-4E07-47AD-AD34-E76C6BC9F061/resourceGroups/rgopenapi/providers/Microsoft.ManagedIdentity/userAssignedIdentities/ua1", + new UserAssignedIdentity()))) + .create(); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} +``` + +### DiscoveryRules_Delete + +```java + +/** + * Samples for DiscoveryRules ListByHealthModel. + */ +public final class DiscoveryRulesListByHealthModelSamples { + /* + * x-ms-original-file: 2023-10-01-preview/DiscoveryRules_ListByHealthModel.json + */ + /** + * Sample code: DiscoveryRules_ListByHealthModel. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void + discoveryRulesListByHealthModel(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.discoveryRules() + .listByHealthModel("my-resource-group", "my-health-model", null, com.azure.core.util.Context.NONE); + } +} +``` + +### DiscoveryRules_Get + +```java + +/** + * Samples for SignalDefinitions ListByHealthModel. + */ +public final class SignalDefinitionsListByHealthModelSamples { + /* + * x-ms-original-file: 2023-10-01-preview/SignalDefinitions_ListByHealthModel.json + */ + /** + * Sample code: SignalDefinitions_ListByHealthModel. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void + signalDefinitionsListByHealthModel(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.signalDefinitions() + .listByHealthModel("rgopenapi", "myHealthModel", null, com.azure.core.util.Context.NONE); + } +} +``` + +### DiscoveryRules_ListByHealthModel + +```java + +/** + * Samples for Entities ListByHealthModel. + */ +public final class EntitiesListByHealthModelSamples { + /* + * x-ms-original-file: 2023-10-01-preview/Entities_ListByHealthModel.json + */ + /** + * Sample code: Entities_ListByHealthModel. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void entitiesListByHealthModel(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.entities() + .listByHealthModel("rgopenapi", "gPWT6GP85xRV248L7LhNRTD--2Yc73wu-5Qk-0tS", null, + com.azure.core.util.Context.NONE); + } +} +``` + +### Entities_CreateOrUpdate + +```java +/** + * Samples for Relationships Get. + */ +public final class RelationshipsGetSamples { + /* + * x-ms-original-file: 2023-10-01-preview/Relationships_Get.json + */ + /** + * Sample code: Relationships_Get. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void relationshipsGet(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.relationships() + .getWithResponse("rgopenapi", "myHealthModel", "Ue-21-F3M12V3w-13x18F8H-7HOk--kq6tP-HB", + com.azure.core.util.Context.NONE); + } +} +``` + +### Entities_Delete + +```java +/** + * Samples for DiscoveryRules Delete. + */ +public final class DiscoveryRulesDeleteSamples { + /* + * x-ms-original-file: 2023-10-01-preview/DiscoveryRules_Delete.json + */ + /** + * Sample code: DiscoveryRules_Delete. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void discoveryRulesDelete(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.discoveryRules() + .deleteWithResponse("my-resource-group", "my-health-model", "my-discovery-rule", + com.azure.core.util.Context.NONE); + } +} +``` + +### Entities_Get + +```java +/** + * Samples for DiscoveryRules Get. + */ +public final class DiscoveryRulesGetSamples { + /* + * x-ms-original-file: 2023-10-01-preview/DiscoveryRules_Get.json + */ + /** + * Sample code: DiscoveryRules_Get. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void discoveryRulesGet(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.discoveryRules() + .getWithResponse("myResourceGroup", "myHealthModel", "myDiscoveryRule", com.azure.core.util.Context.NONE); + } +} +``` + +### Entities_ListByHealthModel + +```java +/** + * Samples for HealthModels Delete. + */ +public final class HealthModelsDeleteSamples { + /* + * x-ms-original-file: 2023-10-01-preview/HealthModels_Delete.json + */ + /** + * Sample code: HealthModels_Delete. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void healthModelsDelete(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.healthModels().delete("rgopenapi", "model1", com.azure.core.util.Context.NONE); + } +} +``` + +### HealthModels_Create + +```java +/** + * Samples for SignalDefinitions Get. + */ +public final class SignalDefinitionsGetSamples { + /* + * x-ms-original-file: 2023-10-01-preview/SignalDefinitions_Get.json + */ + /** + * Sample code: SignalDefinitions_Get. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void signalDefinitionsGet(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.signalDefinitions() + .getWithResponse("rgopenapi", "myHealthModel", "sig1", com.azure.core.util.Context.NONE); + } +} +``` + +### HealthModels_Delete + +```java +import com.azure.resourcemanager.cloudhealth.models.AlertConfiguration; +import com.azure.resourcemanager.cloudhealth.models.AlertSeverity; +import com.azure.resourcemanager.cloudhealth.models.AzureMonitorWorkspaceSignalGroup; +import com.azure.resourcemanager.cloudhealth.models.AzureResourceSignalGroup; +import com.azure.resourcemanager.cloudhealth.models.DependenciesAggregationType; +import com.azure.resourcemanager.cloudhealth.models.DependenciesSignalGroup; +import com.azure.resourcemanager.cloudhealth.models.EntityAlerts; +import com.azure.resourcemanager.cloudhealth.models.EntityCoordinates; +import com.azure.resourcemanager.cloudhealth.models.EntityImpact; +import com.azure.resourcemanager.cloudhealth.models.EntityProperties; +import com.azure.resourcemanager.cloudhealth.models.IconDefinition; +import com.azure.resourcemanager.cloudhealth.models.LogAnalyticsSignalGroup; +import com.azure.resourcemanager.cloudhealth.models.SignalAssignment; +import com.azure.resourcemanager.cloudhealth.models.SignalGroup; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +/** + * Samples for Entities CreateOrUpdate. + */ +public final class EntitiesCreateOrUpdateSamples { + /* + * x-ms-original-file: 2023-10-01-preview/Entities_CreateOrUpdate.json + */ + /** + * Sample code: Entities_CreateOrUpdate. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void entitiesCreateOrUpdate(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.entities() + .define("uszrxbdkxesdrxhmagmzywebgbjj") + .withExistingHealthmodel("rgopenapi", "myHealthModel") + .withProperties(new EntityProperties().withDisplayName("My entity") + .withCanvasPosition(new EntityCoordinates().withX(14.0).withY(13.0)) + .withIcon(new IconDefinition().withIconName("Custom").withCustomData("rcitntvapruccrhtxmkqjphbxunkz")) + .withHealthObjective(62.0D) + .withImpact(EntityImpact.STANDARD) + .withLabels(mapOf("key1376", "fakeTokenPlaceholder")) + .withSignals(new SignalGroup().withAzureResource(new AzureResourceSignalGroup() + .withSignalAssignments( + Arrays.asList(new SignalAssignment().withSignalDefinitions(Arrays.asList("sigdef1")))) + .withAuthenticationSetting("B3P1X3e-FZtZ-4Ak-2VLHGQ-4m4-05DE-XNW5zW3P-46XY-DC3SSX") + .withAzureResourceId( + "/subscriptions/12345678-1234-1234-1234-123456789012/resourceGroups/rg1/providers/Microsoft.Compute/virtualMachines/vm1")) + .withAzureLogAnalytics(new LogAnalyticsSignalGroup() + .withSignalAssignments(Arrays.asList(new SignalAssignment().withSignalDefinitions( + Arrays.asList("B3P1X3e-FZtZ-4Ak-2VLHGQ-4m4-05DE-XNW5zW3P-46XY-DC3SSX")))) + .withAuthenticationSetting("B3P1X3e-FZtZ-4Ak-2VLHGQ-4m4-05DE-XNW5zW3P-46XY-DC3SSX") + .withLogAnalyticsWorkspaceResourceId( + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg/providers/Microsoft.OperationalInsights/workspaces/myworkspace")) + .withAzureMonitorWorkspace(new AzureMonitorWorkspaceSignalGroup() + .withSignalAssignments( + Arrays.asList(new SignalAssignment().withSignalDefinitions(Arrays.asList("sigdef2")), + new SignalAssignment().withSignalDefinitions(Arrays.asList("sigdef3")))) + .withAuthenticationSetting("B3P1X3e-FZtZ-4Ak-2VLHGQ-4m4-05DE-XNW5zW3P-46XY-DC3SSX") + .withAzureMonitorWorkspaceResourceId( + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg/providers/Microsoft.OperationalInsights/workspaces/myworkspace")) + .withDependencies( + new DependenciesSignalGroup().withAggregationType(DependenciesAggregationType.WORST_OF))) + .withAlerts(new EntityAlerts().withUnhealthy(new AlertConfiguration().withSeverity(AlertSeverity.SEV1) + .withDescription("Alert description") + .withActionGroupIds(Arrays.asList( + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg/providers/Microsoft.Insights/actionGroups/myactiongroup"))) + .withDegraded(new AlertConfiguration().withSeverity(AlertSeverity.SEV4) + .withDescription("Alert description") + .withActionGroupIds(Arrays.asList( + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg/providers/Microsoft.Insights/actionGroups/myactiongroup"))))) + .create(); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} +``` + +### HealthModels_GetByResourceGroup + +```java +/** + * Samples for Entities Delete. + */ +public final class EntitiesDeleteSamples { + /* + * x-ms-original-file: 2023-10-01-preview/Entities_Delete.json + */ + /** + * Sample code: Entities_Delete. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void entitiesDelete(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.entities() + .deleteWithResponse("rgopenapi", "model1", "U4VTRFlUkm9kR6H23-c-6U-XHq7n", + com.azure.core.util.Context.NONE); + } +} +``` + +### HealthModels_List + +```java +import com.azure.resourcemanager.cloudhealth.models.DiscoveryRuleProperties; +import com.azure.resourcemanager.cloudhealth.models.DiscoveryRuleRecommendedSignalsBehavior; +import com.azure.resourcemanager.cloudhealth.models.DiscoveryRuleRelationshipDiscoveryBehavior; + +/** + * Samples for DiscoveryRules CreateOrUpdate. + */ +public final class DiscoveryRulesCreateOrUpdateSamples { + /* + * x-ms-original-file: 2023-10-01-preview/DiscoveryRules_CreateOrUpdate.json + */ + /** + * Sample code: DiscoveryRules_CreateOrUpdate. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void discoveryRulesCreateOrUpdate(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.discoveryRules() + .define("myDiscoveryRule") + .withExistingHealthmodel("myResourceGroup", "myHealthModel") + .withProperties(new DiscoveryRuleProperties().withDisplayName("myDisplayName") + .withResourceGraphQuery( + "resources | where subscriptionId == '7ddfffd7-9b32-40df-1234-828cbd55d6f4' | where resourceGroup == 'my-rg'") + .withAuthenticationSetting("authSetting1") + .withDiscoverRelationships(DiscoveryRuleRelationshipDiscoveryBehavior.ENABLED) + .withAddRecommendedSignals(DiscoveryRuleRecommendedSignalsBehavior.ENABLED)) + .create(); + } +} +``` + +### HealthModels_ListByResourceGroup + +```java +/** + * Samples for HealthModels GetByResourceGroup. + */ +public final class HealthModelsGetByResourceGroupSamples { + /* + * x-ms-original-file: 2023-10-01-preview/HealthModels_Get.json + */ + /** + * Sample code: HealthModels_Get. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void healthModelsGet(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.healthModels() + .getByResourceGroupWithResponse("rgopenapi", "myHealthModel", com.azure.core.util.Context.NONE); + } +} +``` + +### HealthModels_Update + +```java +/** + * Samples for HealthModels List. + */ +public final class HealthModelsListSamples { + /* + * x-ms-original-file: 2023-10-01-preview/HealthModels_ListBySubscription.json + */ + /** + * Sample code: HealthModels_ListBySubscription. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void + healthModelsListBySubscription(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.healthModels().list(com.azure.core.util.Context.NONE); + } +} +``` + +### Operations_List + +```java +/** + * Samples for AuthenticationSettings Get. + */ +public final class AuthenticationSettingsGetSamples { + /* + * x-ms-original-file: 2023-10-01-preview/AuthenticationSettings_Get.json + */ + /** + * Sample code: AuthenticationSettings_Get. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void authenticationSettingsGet(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.authenticationSettings() + .getWithResponse("my-resource-group", "my-health-model", "my-auth-setting", + com.azure.core.util.Context.NONE); + } +} +``` + +### Relationships_CreateOrUpdate + +```java +import com.azure.resourcemanager.cloudhealth.models.HealthModel; +import com.azure.resourcemanager.cloudhealth.models.ManagedServiceIdentity; +import com.azure.resourcemanager.cloudhealth.models.ManagedServiceIdentityType; +import com.azure.resourcemanager.cloudhealth.models.UserAssignedIdentity; +import java.util.HashMap; +import java.util.Map; + +/** + * Samples for HealthModels Update. + */ +public final class HealthModelsUpdateSamples { + /* + * x-ms-original-file: 2023-10-01-preview/HealthModels_Update.json + */ + /** + * Sample code: HealthModels_Update. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void healthModelsUpdate(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + HealthModel resource = manager.healthModels() + .getByResourceGroupWithResponse("rgopenapi", "model1", com.azure.core.util.Context.NONE) + .getValue(); + resource.update() + .withTags(mapOf("key21", "fakeTokenPlaceholder")) + .withIdentity(new ManagedServiceIdentity() + .withType(ManagedServiceIdentityType.fromString("SystemAssigned, UserAssigned")) + .withUserAssignedIdentities(mapOf( + "/subscriptions/4980D7D5-4E07-47AD-AD34-E76C6BC9F061/resourceGroups/rgopenapi/providers/Microsoft.ManagedIdentity/userAssignedIdentities/ua1", + new UserAssignedIdentity()))) + .apply(); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} +``` + +### Relationships_Delete + +```java +/** + * Samples for AuthenticationSettings Delete. + */ +public final class AuthenticationSettingsDeleteSamples { + /* + * x-ms-original-file: 2023-10-01-preview/AuthenticationSettings_Delete.json + */ + /** + * Sample code: AuthenticationSettings_Delete. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void authenticationSettingsDelete(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.authenticationSettings() + .deleteWithResponse("my-resource-group", "my-health-model", "my-auth-setting", + com.azure.core.util.Context.NONE); + } +} +``` + +### Relationships_Get + +```java +import com.azure.resourcemanager.cloudhealth.models.RelationshipProperties; +import java.util.HashMap; +import java.util.Map; + +/** + * Samples for Relationships CreateOrUpdate. + */ +public final class RelationshipsCreateOrUpdateSamples { + /* + * x-ms-original-file: 2023-10-01-preview/Relationships_CreateOrUpdate.json + */ + /** + * Sample code: Relationships_CreateOrUpdate. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void relationshipsCreateOrUpdate(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.relationships() + .define("rel1") + .withExistingHealthmodel("rgopenapi", "model1") + .withProperties(new RelationshipProperties().withDisplayName("My relationship") + .withParentEntityName("Entity1") + .withChildEntityName("Entity2") + .withLabels(mapOf("key9681", "fakeTokenPlaceholder"))) + .create(); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} +``` + +### Relationships_ListByHealthModel + +```java +/** + * Samples for Relationships Delete. + */ +public final class RelationshipsDeleteSamples { + /* + * x-ms-original-file: 2023-10-01-preview/Relationships_Delete.json + */ + /** + * Sample code: Relationships_Delete. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void relationshipsDelete(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.relationships().deleteWithResponse("rgopenapi", "model1", "rel1", com.azure.core.util.Context.NONE); + } +} +``` + +### SignalDefinitions_CreateOrUpdate + +```java +import com.azure.resourcemanager.cloudhealth.models.ManagedIdentityAuthenticationSettingProperties; + +/** + * Samples for AuthenticationSettings CreateOrUpdate. + */ +public final class AuthenticationSettingsCreateOrUpdateSamples { + /* + * x-ms-original-file: 2023-10-01-preview/AuthenticationSettings_CreateOrUpdate.json + */ + /** + * Sample code: AuthenticationSettings_CreateOrUpdate. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void + authenticationSettingsCreateOrUpdate(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.authenticationSettings() + .define("myAuthSetting") + .withExistingHealthmodel("myResourceGroup", "myHealthModel") + .withProperties(new ManagedIdentityAuthenticationSettingProperties().withDisplayName("myDisplayName") + .withManagedIdentityName("SystemAssigned")) + .create(); + } +} +``` + +### SignalDefinitions_Delete + +```java +import com.azure.resourcemanager.cloudhealth.models.EvaluationRule; +import com.azure.resourcemanager.cloudhealth.models.MetricAggregationType; +import com.azure.resourcemanager.cloudhealth.models.RefreshInterval; +import com.azure.resourcemanager.cloudhealth.models.ResourceMetricSignalDefinitionProperties; +import com.azure.resourcemanager.cloudhealth.models.SignalOperator; +import com.azure.resourcemanager.cloudhealth.models.ThresholdRule; +import java.util.HashMap; +import java.util.Map; + +/** + * Samples for SignalDefinitions CreateOrUpdate. + */ +public final class SignalDefinitionsCreateOrUpdateSamples { + /* + * x-ms-original-file: 2023-10-01-preview/SignalDefinitions_CreateOrUpdate.json + */ + /** + * Sample code: SignalDefinitions_CreateOrUpdate. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void + signalDefinitionsCreateOrUpdate(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.signalDefinitions() + .define("sig1") + .withExistingHealthmodel("rgopenapi", "myHealthModel") + .withProperties(new ResourceMetricSignalDefinitionProperties().withDisplayName("cpu usage") + .withRefreshInterval(RefreshInterval.PT1M) + .withLabels(mapOf("key4788", "fakeTokenPlaceholder")) + .withDataUnit("byte") + .withEvaluationRules(new EvaluationRule() + .withDegradedRule(new ThresholdRule().withOperator(SignalOperator.LOWER_THAN).withThreshold("65")) + .withUnhealthyRule(new ThresholdRule().withOperator(SignalOperator.LOWER_THAN).withThreshold("60"))) + .withMetricNamespace("microsoft.compute/virtualMachines") + .withMetricName("cpuusage") + .withTimeGrain("PT1M") + .withAggregationType(MetricAggregationType.NONE) + .withDimension("nodename") + .withDimensionFilter("node1")) + .create(); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} +``` + +### SignalDefinitions_Get + +```java +/** + * Samples for SignalDefinitions Delete. + */ +public final class SignalDefinitionsDeleteSamples { + /* + * x-ms-original-file: 2023-10-01-preview/SignalDefinitions_Delete.json + */ + /** + * Sample code: SignalDefinitions_Delete. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void signalDefinitionsDelete(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.signalDefinitions().deleteWithResponse("rgopenapi", "model1", "sig", com.azure.core.util.Context.NONE); + } +} +``` + +### SignalDefinitions_ListByHealthModel + +```java +/** + * Samples for Entities Get. + */ +public final class EntitiesGetSamples { + /* + * x-ms-original-file: 2023-10-01-preview/Entities_Get.json + */ + /** + * Sample code: Entities_Get. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void entitiesGet(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.entities().getWithResponse("rgopenapi", "myHealthModel", "entity1", com.azure.core.util.Context.NONE); + } +} +``` + diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/pom.xml b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/pom.xml new file mode 100644 index 000000000000..e6c5c43f0886 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/pom.xml @@ -0,0 +1,74 @@ + + + 4.0.0 + + com.azure + azure-client-sdk-parent + 1.7.0 + ../../parents/azure-client-sdk-parent + + + com.azure.resourcemanager + azure-resourcemanager-cloudhealth + 1.0.0-beta.1 + jar + + Microsoft Azure SDK for CloudHealth Management + This package contains Microsoft Azure SDK for CloudHealth Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. + https://github.com/Azure/azure-sdk-for-java + + + + The MIT License (MIT) + http://opensource.org/licenses/MIT + repo + + + + + https://github.com/Azure/azure-sdk-for-java + scm:git:git@github.com:Azure/azure-sdk-for-java.git + scm:git:git@github.com:Azure/azure-sdk-for-java.git + HEAD + + + + microsoft + Microsoft + + + + UTF-8 + 0 + 0 + true + + + + com.azure + azure-core + 1.55.3 + + + com.azure + azure-core-management + 1.17.0 + + + com.azure + azure-core-test + 1.27.0-beta.8 + test + + + com.azure + azure-identity + 1.16.0 + test + + + diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/CloudHealthManager.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/CloudHealthManager.java new file mode 100644 index 000000000000..d4b62eaba075 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/CloudHealthManager.java @@ -0,0 +1,378 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth; + +import com.azure.core.credential.TokenCredential; +import com.azure.core.http.HttpClient; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.HttpPipelinePosition; +import com.azure.core.http.policy.AddDatePolicy; +import com.azure.core.http.policy.AddHeadersFromContextPolicy; +import com.azure.core.http.policy.BearerTokenAuthenticationPolicy; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.http.policy.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpPipelinePolicy; +import com.azure.core.http.policy.HttpPolicyProviders; +import com.azure.core.http.policy.RequestIdPolicy; +import com.azure.core.http.policy.RetryOptions; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.util.Configuration; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.cloudhealth.fluent.CloudHealthClient; +import com.azure.resourcemanager.cloudhealth.implementation.AuthenticationSettingsImpl; +import com.azure.resourcemanager.cloudhealth.implementation.CloudHealthClientBuilder; +import com.azure.resourcemanager.cloudhealth.implementation.DiscoveryRulesImpl; +import com.azure.resourcemanager.cloudhealth.implementation.EntitiesImpl; +import com.azure.resourcemanager.cloudhealth.implementation.HealthModelsImpl; +import com.azure.resourcemanager.cloudhealth.implementation.OperationsImpl; +import com.azure.resourcemanager.cloudhealth.implementation.RelationshipsImpl; +import com.azure.resourcemanager.cloudhealth.implementation.SignalDefinitionsImpl; +import com.azure.resourcemanager.cloudhealth.models.AuthenticationSettings; +import com.azure.resourcemanager.cloudhealth.models.DiscoveryRules; +import com.azure.resourcemanager.cloudhealth.models.Entities; +import com.azure.resourcemanager.cloudhealth.models.HealthModels; +import com.azure.resourcemanager.cloudhealth.models.Operations; +import com.azure.resourcemanager.cloudhealth.models.Relationships; +import com.azure.resourcemanager.cloudhealth.models.SignalDefinitions; +import java.time.Duration; +import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * Entry point to CloudHealthManager. + */ +public final class CloudHealthManager { + private Operations operations; + + private HealthModels healthModels; + + private SignalDefinitions signalDefinitions; + + private AuthenticationSettings authenticationSettings; + + private Entities entities; + + private Relationships relationships; + + private DiscoveryRules discoveryRules; + + private final CloudHealthClient clientObject; + + private CloudHealthManager(HttpPipeline httpPipeline, AzureProfile profile, Duration defaultPollInterval) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + this.clientObject = new CloudHealthClientBuilder().pipeline(httpPipeline) + .endpoint(profile.getEnvironment().getResourceManagerEndpoint()) + .subscriptionId(profile.getSubscriptionId()) + .defaultPollInterval(defaultPollInterval) + .buildClient(); + } + + /** + * Creates an instance of CloudHealth service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the CloudHealth service API instance. + */ + public static CloudHealthManager authenticate(TokenCredential credential, AzureProfile profile) { + Objects.requireNonNull(credential, "'credential' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + return configure().authenticate(credential, profile); + } + + /** + * Creates an instance of CloudHealth service API entry point. + * + * @param httpPipeline the {@link HttpPipeline} configured with Azure authentication credential. + * @param profile the Azure profile for client. + * @return the CloudHealth service API instance. + */ + public static CloudHealthManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + return new CloudHealthManager(httpPipeline, profile, null); + } + + /** + * Gets a Configurable instance that can be used to create CloudHealthManager with optional configuration. + * + * @return the Configurable instance allowing configurations. + */ + public static Configurable configure() { + return new CloudHealthManager.Configurable(); + } + + /** + * The Configurable allowing configurations to be set. + */ + public static final class Configurable { + private static final ClientLogger LOGGER = new ClientLogger(Configurable.class); + private static final String SDK_VERSION = "version"; + private static final Map PROPERTIES + = CoreUtils.getProperties("azure-resourcemanager-cloudhealth.properties"); + + private HttpClient httpClient; + private HttpLogOptions httpLogOptions; + private final List policies = new ArrayList<>(); + private final List scopes = new ArrayList<>(); + private RetryPolicy retryPolicy; + private RetryOptions retryOptions; + private Duration defaultPollInterval; + + private Configurable() { + } + + /** + * Sets the http client. + * + * @param httpClient the HTTP client. + * @return the configurable object itself. + */ + public Configurable withHttpClient(HttpClient httpClient) { + this.httpClient = Objects.requireNonNull(httpClient, "'httpClient' cannot be null."); + return this; + } + + /** + * Sets the logging options to the HTTP pipeline. + * + * @param httpLogOptions the HTTP log options. + * @return the configurable object itself. + */ + public Configurable withLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = Objects.requireNonNull(httpLogOptions, "'httpLogOptions' cannot be null."); + return this; + } + + /** + * Adds the pipeline policy to the HTTP pipeline. + * + * @param policy the HTTP pipeline policy. + * @return the configurable object itself. + */ + public Configurable withPolicy(HttpPipelinePolicy policy) { + this.policies.add(Objects.requireNonNull(policy, "'policy' cannot be null.")); + return this; + } + + /** + * Adds the scope to permission sets. + * + * @param scope the scope. + * @return the configurable object itself. + */ + public Configurable withScope(String scope) { + this.scopes.add(Objects.requireNonNull(scope, "'scope' cannot be null.")); + return this; + } + + /** + * Sets the retry policy to the HTTP pipeline. + * + * @param retryPolicy the HTTP pipeline retry policy. + * @return the configurable object itself. + */ + public Configurable withRetryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = Objects.requireNonNull(retryPolicy, "'retryPolicy' cannot be null."); + return this; + } + + /** + * Sets the retry options for the HTTP pipeline retry policy. + *

+ * This setting has no effect, if retry policy is set via {@link #withRetryPolicy(RetryPolicy)}. + * + * @param retryOptions the retry options for the HTTP pipeline retry policy. + * @return the configurable object itself. + */ + public Configurable withRetryOptions(RetryOptions retryOptions) { + this.retryOptions = Objects.requireNonNull(retryOptions, "'retryOptions' cannot be null."); + return this; + } + + /** + * Sets the default poll interval, used when service does not provide "Retry-After" header. + * + * @param defaultPollInterval the default poll interval. + * @return the configurable object itself. + */ + public Configurable withDefaultPollInterval(Duration defaultPollInterval) { + this.defaultPollInterval + = Objects.requireNonNull(defaultPollInterval, "'defaultPollInterval' cannot be null."); + if (this.defaultPollInterval.isNegative()) { + throw LOGGER + .logExceptionAsError(new IllegalArgumentException("'defaultPollInterval' cannot be negative")); + } + return this; + } + + /** + * Creates an instance of CloudHealth service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the CloudHealth service API instance. + */ + public CloudHealthManager authenticate(TokenCredential credential, AzureProfile profile) { + Objects.requireNonNull(credential, "'credential' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + + String clientVersion = PROPERTIES.getOrDefault(SDK_VERSION, "UnknownVersion"); + + StringBuilder userAgentBuilder = new StringBuilder(); + userAgentBuilder.append("azsdk-java") + .append("-") + .append("com.azure.resourcemanager.cloudhealth") + .append("/") + .append(clientVersion); + if (!Configuration.getGlobalConfiguration().get("AZURE_TELEMETRY_DISABLED", false)) { + userAgentBuilder.append(" (") + .append(Configuration.getGlobalConfiguration().get("java.version")) + .append("; ") + .append(Configuration.getGlobalConfiguration().get("os.name")) + .append("; ") + .append(Configuration.getGlobalConfiguration().get("os.version")) + .append("; auto-generated)"); + } else { + userAgentBuilder.append(" (auto-generated)"); + } + + if (scopes.isEmpty()) { + scopes.add(profile.getEnvironment().getManagementEndpoint() + "/.default"); + } + if (retryPolicy == null) { + if (retryOptions != null) { + retryPolicy = new RetryPolicy(retryOptions); + } else { + retryPolicy = new RetryPolicy("Retry-After", ChronoUnit.SECONDS); + } + } + List policies = new ArrayList<>(); + policies.add(new UserAgentPolicy(userAgentBuilder.toString())); + policies.add(new AddHeadersFromContextPolicy()); + policies.add(new RequestIdPolicy()); + policies.addAll(this.policies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) + .collect(Collectors.toList())); + HttpPolicyProviders.addBeforeRetryPolicies(policies); + policies.add(retryPolicy); + policies.add(new AddDatePolicy()); + policies.add(new BearerTokenAuthenticationPolicy(credential, scopes.toArray(new String[0]))); + policies.addAll(this.policies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) + .collect(Collectors.toList())); + HttpPolicyProviders.addAfterRetryPolicies(policies); + policies.add(new HttpLoggingPolicy(httpLogOptions)); + HttpPipeline httpPipeline = new HttpPipelineBuilder().httpClient(httpClient) + .policies(policies.toArray(new HttpPipelinePolicy[0])) + .build(); + return new CloudHealthManager(httpPipeline, profile, defaultPollInterval); + } + } + + /** + * Gets the resource collection API of Operations. + * + * @return Resource collection API of Operations. + */ + public Operations operations() { + if (this.operations == null) { + this.operations = new OperationsImpl(clientObject.getOperations(), this); + } + return operations; + } + + /** + * Gets the resource collection API of HealthModels. It manages HealthModel. + * + * @return Resource collection API of HealthModels. + */ + public HealthModels healthModels() { + if (this.healthModels == null) { + this.healthModels = new HealthModelsImpl(clientObject.getHealthModels(), this); + } + return healthModels; + } + + /** + * Gets the resource collection API of SignalDefinitions. It manages SignalDefinition. + * + * @return Resource collection API of SignalDefinitions. + */ + public SignalDefinitions signalDefinitions() { + if (this.signalDefinitions == null) { + this.signalDefinitions = new SignalDefinitionsImpl(clientObject.getSignalDefinitions(), this); + } + return signalDefinitions; + } + + /** + * Gets the resource collection API of AuthenticationSettings. It manages AuthenticationSetting. + * + * @return Resource collection API of AuthenticationSettings. + */ + public AuthenticationSettings authenticationSettings() { + if (this.authenticationSettings == null) { + this.authenticationSettings + = new AuthenticationSettingsImpl(clientObject.getAuthenticationSettings(), this); + } + return authenticationSettings; + } + + /** + * Gets the resource collection API of Entities. It manages Entity. + * + * @return Resource collection API of Entities. + */ + public Entities entities() { + if (this.entities == null) { + this.entities = new EntitiesImpl(clientObject.getEntities(), this); + } + return entities; + } + + /** + * Gets the resource collection API of Relationships. It manages Relationship. + * + * @return Resource collection API of Relationships. + */ + public Relationships relationships() { + if (this.relationships == null) { + this.relationships = new RelationshipsImpl(clientObject.getRelationships(), this); + } + return relationships; + } + + /** + * Gets the resource collection API of DiscoveryRules. It manages DiscoveryRule. + * + * @return Resource collection API of DiscoveryRules. + */ + public DiscoveryRules discoveryRules() { + if (this.discoveryRules == null) { + this.discoveryRules = new DiscoveryRulesImpl(clientObject.getDiscoveryRules(), this); + } + return discoveryRules; + } + + /** + * Gets wrapped service client CloudHealthClient providing direct access to the underlying auto-generated API + * implementation, based on Azure REST API. + * + * @return Wrapped service client CloudHealthClient. + */ + public CloudHealthClient serviceClient() { + return this.clientObject; + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/AuthenticationSettingsClient.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/AuthenticationSettingsClient.java new file mode 100644 index 000000000000..ed65d5fe3b09 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/AuthenticationSettingsClient.java @@ -0,0 +1,137 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.fluent; + +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; +import com.azure.resourcemanager.cloudhealth.fluent.models.AuthenticationSettingInner; + +/** + * An instance of this class provides access to all the operations defined in AuthenticationSettingsClient. + */ +public interface AuthenticationSettingsClient { + /** + * Get a AuthenticationSetting. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param authenticationSettingName Name of the authentication setting. Must be unique within a health model. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a AuthenticationSetting along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getWithResponse(String resourceGroupName, String healthModelName, + String authenticationSettingName, Context context); + + /** + * Get a AuthenticationSetting. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param authenticationSettingName Name of the authentication setting. Must be unique within a health model. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a AuthenticationSetting. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + AuthenticationSettingInner get(String resourceGroupName, String healthModelName, String authenticationSettingName); + + /** + * Create a AuthenticationSetting. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param authenticationSettingName Name of the authentication setting. Must be unique within a health model. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an authentication setting in a health model along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response createOrUpdateWithResponse(String resourceGroupName, String healthModelName, + String authenticationSettingName, AuthenticationSettingInner resource, Context context); + + /** + * Create a AuthenticationSetting. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param authenticationSettingName Name of the authentication setting. Must be unique within a health model. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an authentication setting in a health model. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + AuthenticationSettingInner createOrUpdate(String resourceGroupName, String healthModelName, + String authenticationSettingName, AuthenticationSettingInner resource); + + /** + * Delete a AuthenticationSetting. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param authenticationSettingName Name of the authentication setting. Must be unique within a health model. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response deleteWithResponse(String resourceGroupName, String healthModelName, + String authenticationSettingName, Context context); + + /** + * Delete a AuthenticationSetting. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param authenticationSettingName Name of the authentication setting. Must be unique within a health model. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + void delete(String resourceGroupName, String healthModelName, String authenticationSettingName); + + /** + * List AuthenticationSetting resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a AuthenticationSetting list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByHealthModel(String resourceGroupName, String healthModelName); + + /** + * List AuthenticationSetting resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a AuthenticationSetting list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByHealthModel(String resourceGroupName, String healthModelName, + Context context); +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/CloudHealthClient.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/CloudHealthClient.java new file mode 100644 index 000000000000..112c9a8dbfcd --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/CloudHealthClient.java @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.fluent; + +import com.azure.core.http.HttpPipeline; +import java.time.Duration; + +/** + * The interface for CloudHealthClient class. + */ +public interface CloudHealthClient { + /** + * Gets Service host. + * + * @return the endpoint value. + */ + String getEndpoint(); + + /** + * Gets Version parameter. + * + * @return the apiVersion value. + */ + String getApiVersion(); + + /** + * Gets The ID of the target subscription. The value must be an UUID. + * + * @return the subscriptionId value. + */ + String getSubscriptionId(); + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + HttpPipeline getHttpPipeline(); + + /** + * Gets The default poll interval for long-running operation. + * + * @return the defaultPollInterval value. + */ + Duration getDefaultPollInterval(); + + /** + * Gets the OperationsClient object to access its operations. + * + * @return the OperationsClient object. + */ + OperationsClient getOperations(); + + /** + * Gets the HealthModelsClient object to access its operations. + * + * @return the HealthModelsClient object. + */ + HealthModelsClient getHealthModels(); + + /** + * Gets the SignalDefinitionsClient object to access its operations. + * + * @return the SignalDefinitionsClient object. + */ + SignalDefinitionsClient getSignalDefinitions(); + + /** + * Gets the AuthenticationSettingsClient object to access its operations. + * + * @return the AuthenticationSettingsClient object. + */ + AuthenticationSettingsClient getAuthenticationSettings(); + + /** + * Gets the EntitiesClient object to access its operations. + * + * @return the EntitiesClient object. + */ + EntitiesClient getEntities(); + + /** + * Gets the RelationshipsClient object to access its operations. + * + * @return the RelationshipsClient object. + */ + RelationshipsClient getRelationships(); + + /** + * Gets the DiscoveryRulesClient object to access its operations. + * + * @return the DiscoveryRulesClient object. + */ + DiscoveryRulesClient getDiscoveryRules(); +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/DiscoveryRulesClient.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/DiscoveryRulesClient.java new file mode 100644 index 000000000000..f2b1811881d7 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/DiscoveryRulesClient.java @@ -0,0 +1,142 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.fluent; + +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; +import com.azure.resourcemanager.cloudhealth.fluent.models.DiscoveryRuleInner; +import java.time.OffsetDateTime; + +/** + * An instance of this class provides access to all the operations defined in DiscoveryRulesClient. + */ +public interface DiscoveryRulesClient { + /** + * Get a DiscoveryRule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param discoveryRuleName Name of the discovery rule. Must be unique within a health model. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a DiscoveryRule along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getWithResponse(String resourceGroupName, String healthModelName, + String discoveryRuleName, Context context); + + /** + * Get a DiscoveryRule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param discoveryRuleName Name of the discovery rule. Must be unique within a health model. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a DiscoveryRule. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + DiscoveryRuleInner get(String resourceGroupName, String healthModelName, String discoveryRuleName); + + /** + * Create a DiscoveryRule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param discoveryRuleName Name of the discovery rule. Must be unique within a health model. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a discovery rule which automatically finds entities and relationships in a health model based on an Azure + * Resource Graph query along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response createOrUpdateWithResponse(String resourceGroupName, String healthModelName, + String discoveryRuleName, DiscoveryRuleInner resource, Context context); + + /** + * Create a DiscoveryRule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param discoveryRuleName Name of the discovery rule. Must be unique within a health model. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a discovery rule which automatically finds entities and relationships in a health model based on an Azure + * Resource Graph query. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + DiscoveryRuleInner createOrUpdate(String resourceGroupName, String healthModelName, String discoveryRuleName, + DiscoveryRuleInner resource); + + /** + * Delete a DiscoveryRule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param discoveryRuleName Name of the discovery rule. Must be unique within a health model. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response deleteWithResponse(String resourceGroupName, String healthModelName, String discoveryRuleName, + Context context); + + /** + * Delete a DiscoveryRule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param discoveryRuleName Name of the discovery rule. Must be unique within a health model. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + void delete(String resourceGroupName, String healthModelName, String discoveryRuleName); + + /** + * List DiscoveryRule resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a DiscoveryRule list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByHealthModel(String resourceGroupName, String healthModelName); + + /** + * List DiscoveryRule resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param timestamp Timestamp to use for the operation. When specified, the version of the resource at this point in + * time is retrieved. If not specified, the latest version is used. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a DiscoveryRule list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByHealthModel(String resourceGroupName, String healthModelName, + OffsetDateTime timestamp, Context context); +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/EntitiesClient.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/EntitiesClient.java new file mode 100644 index 000000000000..b82c6d00903b --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/EntitiesClient.java @@ -0,0 +1,140 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.fluent; + +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; +import com.azure.resourcemanager.cloudhealth.fluent.models.EntityInner; +import java.time.OffsetDateTime; + +/** + * An instance of this class provides access to all the operations defined in EntitiesClient. + */ +public interface EntitiesClient { + /** + * Get a Entity. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param entityName Name of the entity. Must be unique within a health model. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Entity along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getWithResponse(String resourceGroupName, String healthModelName, String entityName, + Context context); + + /** + * Get a Entity. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param entityName Name of the entity. Must be unique within a health model. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Entity. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + EntityInner get(String resourceGroupName, String healthModelName, String entityName); + + /** + * Create a Entity. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param entityName Name of the entity. Must be unique within a health model. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an entity (aka node) of a health model along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response createOrUpdateWithResponse(String resourceGroupName, String healthModelName, + String entityName, EntityInner resource, Context context); + + /** + * Create a Entity. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param entityName Name of the entity. Must be unique within a health model. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an entity (aka node) of a health model. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + EntityInner createOrUpdate(String resourceGroupName, String healthModelName, String entityName, + EntityInner resource); + + /** + * Delete a Entity. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param entityName Name of the entity. Must be unique within a health model. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response deleteWithResponse(String resourceGroupName, String healthModelName, String entityName, + Context context); + + /** + * Delete a Entity. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param entityName Name of the entity. Must be unique within a health model. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + void delete(String resourceGroupName, String healthModelName, String entityName); + + /** + * List Entity resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Entity list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByHealthModel(String resourceGroupName, String healthModelName); + + /** + * List Entity resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param timestamp Timestamp to use for the operation. When specified, the version of the resource at this point in + * time is retrieved. If not specified, the latest version is used. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Entity list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByHealthModel(String resourceGroupName, String healthModelName, + OffsetDateTime timestamp, Context context); +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/HealthModelsClient.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/HealthModelsClient.java new file mode 100644 index 000000000000..0faddae2b6b5 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/HealthModelsClient.java @@ -0,0 +1,269 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.fluent; + +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.management.polling.PollResult; +import com.azure.core.util.Context; +import com.azure.core.util.polling.SyncPoller; +import com.azure.resourcemanager.cloudhealth.fluent.models.HealthModelInner; +import com.azure.resourcemanager.cloudhealth.models.HealthModelUpdate; + +/** + * An instance of this class provides access to all the operations defined in HealthModelsClient. + */ +public interface HealthModelsClient { + /** + * Get a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a HealthModel along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getByResourceGroupWithResponse(String resourceGroupName, String healthModelName, + Context context); + + /** + * Get a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a HealthModel. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + HealthModelInner getByResourceGroup(String resourceGroupName, String healthModelName); + + /** + * Create a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of a HealthModel resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, HealthModelInner> beginCreate(String resourceGroupName, + String healthModelName, HealthModelInner resource); + + /** + * Create a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of a HealthModel resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, HealthModelInner> beginCreate(String resourceGroupName, + String healthModelName, HealthModelInner resource, Context context); + + /** + * Create a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a HealthModel resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + HealthModelInner create(String resourceGroupName, String healthModelName, HealthModelInner resource); + + /** + * Create a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a HealthModel resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + HealthModelInner create(String resourceGroupName, String healthModelName, HealthModelInner resource, + Context context); + + /** + * Update a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param properties The resource properties to be updated. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of a HealthModel resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, HealthModelInner> beginUpdate(String resourceGroupName, + String healthModelName, HealthModelUpdate properties); + + /** + * Update a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param properties The resource properties to be updated. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of a HealthModel resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, HealthModelInner> beginUpdate(String resourceGroupName, + String healthModelName, HealthModelUpdate properties, Context context); + + /** + * Update a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param properties The resource properties to be updated. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a HealthModel resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + HealthModelInner update(String resourceGroupName, String healthModelName, HealthModelUpdate properties); + + /** + * Update a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param properties The resource properties to be updated. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a HealthModel resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + HealthModelInner update(String resourceGroupName, String healthModelName, HealthModelUpdate properties, + Context context); + + /** + * Delete a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, Void> beginDelete(String resourceGroupName, String healthModelName); + + /** + * Delete a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, Void> beginDelete(String resourceGroupName, String healthModelName, Context context); + + /** + * Delete a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + void delete(String resourceGroupName, String healthModelName); + + /** + * Delete a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + void delete(String resourceGroupName, String healthModelName, Context context); + + /** + * List HealthModel resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a HealthModel list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByResourceGroup(String resourceGroupName); + + /** + * List HealthModel resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a HealthModel list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByResourceGroup(String resourceGroupName, Context context); + + /** + * List HealthModel resources by subscription ID. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a HealthModel list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(); + + /** + * List HealthModel resources by subscription ID. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a HealthModel list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(Context context); +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/OperationsClient.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/OperationsClient.java new file mode 100644 index 000000000000..cbf8ac999275 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/OperationsClient.java @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.fluent; + +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Context; +import com.azure.resourcemanager.cloudhealth.fluent.models.OperationInner; + +/** + * An instance of this class provides access to all the operations defined in OperationsClient. + */ +public interface OperationsClient { + /** + * List the operations for the provider. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(); + + /** + * List the operations for the provider. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(Context context); +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/RelationshipsClient.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/RelationshipsClient.java new file mode 100644 index 000000000000..8ec96fd3f09f --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/RelationshipsClient.java @@ -0,0 +1,146 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.fluent; + +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; +import com.azure.resourcemanager.cloudhealth.fluent.models.RelationshipInner; +import java.time.OffsetDateTime; + +/** + * An instance of this class provides access to all the operations defined in RelationshipsClient. + */ +public interface RelationshipsClient { + /** + * Get a Relationship. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param relationshipName Name of the relationship. Must be unique within a health model. For example, a + * concatenation of parentEntityName and childEntityName can be used as the name. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Relationship along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getWithResponse(String resourceGroupName, String healthModelName, + String relationshipName, Context context); + + /** + * Get a Relationship. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param relationshipName Name of the relationship. Must be unique within a health model. For example, a + * concatenation of parentEntityName and childEntityName can be used as the name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Relationship. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + RelationshipInner get(String resourceGroupName, String healthModelName, String relationshipName); + + /** + * Create a Relationship. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param relationshipName Name of the relationship. Must be unique within a health model. For example, a + * concatenation of parentEntityName and childEntityName can be used as the name. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a relationship (aka edge) between two entities in a health model along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response createOrUpdateWithResponse(String resourceGroupName, String healthModelName, + String relationshipName, RelationshipInner resource, Context context); + + /** + * Create a Relationship. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param relationshipName Name of the relationship. Must be unique within a health model. For example, a + * concatenation of parentEntityName and childEntityName can be used as the name. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a relationship (aka edge) between two entities in a health model. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + RelationshipInner createOrUpdate(String resourceGroupName, String healthModelName, String relationshipName, + RelationshipInner resource); + + /** + * Delete a Relationship. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param relationshipName Name of the relationship. Must be unique within a health model. For example, a + * concatenation of parentEntityName and childEntityName can be used as the name. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response deleteWithResponse(String resourceGroupName, String healthModelName, String relationshipName, + Context context); + + /** + * Delete a Relationship. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param relationshipName Name of the relationship. Must be unique within a health model. For example, a + * concatenation of parentEntityName and childEntityName can be used as the name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + void delete(String resourceGroupName, String healthModelName, String relationshipName); + + /** + * List Relationship resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Relationship list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByHealthModel(String resourceGroupName, String healthModelName); + + /** + * List Relationship resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param timestamp Timestamp to use for the operation. When specified, the version of the resource at this point in + * time is retrieved. If not specified, the latest version is used. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Relationship list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByHealthModel(String resourceGroupName, String healthModelName, + OffsetDateTime timestamp, Context context); +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/SignalDefinitionsClient.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/SignalDefinitionsClient.java new file mode 100644 index 000000000000..e29ce828c033 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/SignalDefinitionsClient.java @@ -0,0 +1,140 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.fluent; + +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; +import com.azure.resourcemanager.cloudhealth.fluent.models.SignalDefinitionInner; +import java.time.OffsetDateTime; + +/** + * An instance of this class provides access to all the operations defined in SignalDefinitionsClient. + */ +public interface SignalDefinitionsClient { + /** + * Get a SignalDefinition. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param signalDefinitionName Name of the signal definition. Must be unique within a health model. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a SignalDefinition along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getWithResponse(String resourceGroupName, String healthModelName, + String signalDefinitionName, Context context); + + /** + * Get a SignalDefinition. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param signalDefinitionName Name of the signal definition. Must be unique within a health model. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a SignalDefinition. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + SignalDefinitionInner get(String resourceGroupName, String healthModelName, String signalDefinitionName); + + /** + * Create a SignalDefinition. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param signalDefinitionName Name of the signal definition. Must be unique within a health model. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a signal definition in a health model along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response createOrUpdateWithResponse(String resourceGroupName, String healthModelName, + String signalDefinitionName, SignalDefinitionInner resource, Context context); + + /** + * Create a SignalDefinition. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param signalDefinitionName Name of the signal definition. Must be unique within a health model. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a signal definition in a health model. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + SignalDefinitionInner createOrUpdate(String resourceGroupName, String healthModelName, String signalDefinitionName, + SignalDefinitionInner resource); + + /** + * Delete a SignalDefinition. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param signalDefinitionName Name of the signal definition. Must be unique within a health model. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response deleteWithResponse(String resourceGroupName, String healthModelName, String signalDefinitionName, + Context context); + + /** + * Delete a SignalDefinition. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param signalDefinitionName Name of the signal definition. Must be unique within a health model. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + void delete(String resourceGroupName, String healthModelName, String signalDefinitionName); + + /** + * List SignalDefinition resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a SignalDefinition list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByHealthModel(String resourceGroupName, String healthModelName); + + /** + * List SignalDefinition resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param timestamp Timestamp to use for the operation. When specified, the version of the resource at this point in + * time is retrieved. If not specified, the latest version is used. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a SignalDefinition list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByHealthModel(String resourceGroupName, String healthModelName, + OffsetDateTime timestamp, Context context); +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/models/AuthenticationSettingInner.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/models/AuthenticationSettingInner.java new file mode 100644 index 000000000000..6d62db0299fc --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/models/AuthenticationSettingInner.java @@ -0,0 +1,167 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.management.ProxyResource; +import com.azure.core.management.SystemData; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.cloudhealth.models.AuthenticationSettingProperties; +import java.io.IOException; + +/** + * An authentication setting in a health model. + */ +@Fluent +public final class AuthenticationSettingInner extends ProxyResource { + /* + * The resource-specific properties for this resource. + */ + private AuthenticationSettingProperties properties; + + /* + * Azure Resource Manager metadata containing createdBy and modifiedBy information. + */ + private SystemData systemData; + + /* + * The type of the resource. + */ + private String type; + + /* + * The name of the resource. + */ + private String name; + + /* + * Fully qualified resource Id for the resource. + */ + private String id; + + /** + * Creates an instance of AuthenticationSettingInner class. + */ + public AuthenticationSettingInner() { + } + + /** + * Get the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + public AuthenticationSettingProperties properties() { + return this.properties; + } + + /** + * Set the properties property: The resource-specific properties for this resource. + * + * @param properties the properties value to set. + * @return the AuthenticationSettingInner object itself. + */ + public AuthenticationSettingInner withProperties(AuthenticationSettingProperties properties) { + this.properties = properties; + return this; + } + + /** + * Get the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + public SystemData systemData() { + return this.systemData; + } + + /** + * Get the type property: The type of the resource. + * + * @return the type value. + */ + @Override + public String type() { + return this.type; + } + + /** + * Get the name property: The name of the resource. + * + * @return the name value. + */ + @Override + public String name() { + return this.name; + } + + /** + * Get the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + @Override + public String id() { + return this.id; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (properties() != null) { + properties().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("properties", this.properties); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of AuthenticationSettingInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of AuthenticationSettingInner if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the AuthenticationSettingInner. + */ + public static AuthenticationSettingInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + AuthenticationSettingInner deserializedAuthenticationSettingInner = new AuthenticationSettingInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedAuthenticationSettingInner.id = reader.getString(); + } else if ("name".equals(fieldName)) { + deserializedAuthenticationSettingInner.name = reader.getString(); + } else if ("type".equals(fieldName)) { + deserializedAuthenticationSettingInner.type = reader.getString(); + } else if ("properties".equals(fieldName)) { + deserializedAuthenticationSettingInner.properties + = AuthenticationSettingProperties.fromJson(reader); + } else if ("systemData".equals(fieldName)) { + deserializedAuthenticationSettingInner.systemData = SystemData.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedAuthenticationSettingInner; + }); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/models/DiscoveryRuleInner.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/models/DiscoveryRuleInner.java new file mode 100644 index 000000000000..9a4802b5f735 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/models/DiscoveryRuleInner.java @@ -0,0 +1,167 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.management.ProxyResource; +import com.azure.core.management.SystemData; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.cloudhealth.models.DiscoveryRuleProperties; +import java.io.IOException; + +/** + * A discovery rule which automatically finds entities and relationships in a health model based on an Azure Resource + * Graph query. + */ +@Fluent +public final class DiscoveryRuleInner extends ProxyResource { + /* + * The resource-specific properties for this resource. + */ + private DiscoveryRuleProperties properties; + + /* + * Azure Resource Manager metadata containing createdBy and modifiedBy information. + */ + private SystemData systemData; + + /* + * The type of the resource. + */ + private String type; + + /* + * The name of the resource. + */ + private String name; + + /* + * Fully qualified resource Id for the resource. + */ + private String id; + + /** + * Creates an instance of DiscoveryRuleInner class. + */ + public DiscoveryRuleInner() { + } + + /** + * Get the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + public DiscoveryRuleProperties properties() { + return this.properties; + } + + /** + * Set the properties property: The resource-specific properties for this resource. + * + * @param properties the properties value to set. + * @return the DiscoveryRuleInner object itself. + */ + public DiscoveryRuleInner withProperties(DiscoveryRuleProperties properties) { + this.properties = properties; + return this; + } + + /** + * Get the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + public SystemData systemData() { + return this.systemData; + } + + /** + * Get the type property: The type of the resource. + * + * @return the type value. + */ + @Override + public String type() { + return this.type; + } + + /** + * Get the name property: The name of the resource. + * + * @return the name value. + */ + @Override + public String name() { + return this.name; + } + + /** + * Get the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + @Override + public String id() { + return this.id; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (properties() != null) { + properties().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("properties", this.properties); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DiscoveryRuleInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DiscoveryRuleInner if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the DiscoveryRuleInner. + */ + public static DiscoveryRuleInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + DiscoveryRuleInner deserializedDiscoveryRuleInner = new DiscoveryRuleInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedDiscoveryRuleInner.id = reader.getString(); + } else if ("name".equals(fieldName)) { + deserializedDiscoveryRuleInner.name = reader.getString(); + } else if ("type".equals(fieldName)) { + deserializedDiscoveryRuleInner.type = reader.getString(); + } else if ("properties".equals(fieldName)) { + deserializedDiscoveryRuleInner.properties = DiscoveryRuleProperties.fromJson(reader); + } else if ("systemData".equals(fieldName)) { + deserializedDiscoveryRuleInner.systemData = SystemData.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedDiscoveryRuleInner; + }); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/models/EntityInner.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/models/EntityInner.java new file mode 100644 index 000000000000..96a86192ab15 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/models/EntityInner.java @@ -0,0 +1,166 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.management.ProxyResource; +import com.azure.core.management.SystemData; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.cloudhealth.models.EntityProperties; +import java.io.IOException; + +/** + * An entity (aka node) of a health model. + */ +@Fluent +public final class EntityInner extends ProxyResource { + /* + * The resource-specific properties for this resource. + */ + private EntityProperties properties; + + /* + * Azure Resource Manager metadata containing createdBy and modifiedBy information. + */ + private SystemData systemData; + + /* + * The type of the resource. + */ + private String type; + + /* + * The name of the resource. + */ + private String name; + + /* + * Fully qualified resource Id for the resource. + */ + private String id; + + /** + * Creates an instance of EntityInner class. + */ + public EntityInner() { + } + + /** + * Get the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + public EntityProperties properties() { + return this.properties; + } + + /** + * Set the properties property: The resource-specific properties for this resource. + * + * @param properties the properties value to set. + * @return the EntityInner object itself. + */ + public EntityInner withProperties(EntityProperties properties) { + this.properties = properties; + return this; + } + + /** + * Get the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + public SystemData systemData() { + return this.systemData; + } + + /** + * Get the type property: The type of the resource. + * + * @return the type value. + */ + @Override + public String type() { + return this.type; + } + + /** + * Get the name property: The name of the resource. + * + * @return the name value. + */ + @Override + public String name() { + return this.name; + } + + /** + * Get the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + @Override + public String id() { + return this.id; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (properties() != null) { + properties().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("properties", this.properties); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of EntityInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of EntityInner if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the EntityInner. + */ + public static EntityInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + EntityInner deserializedEntityInner = new EntityInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedEntityInner.id = reader.getString(); + } else if ("name".equals(fieldName)) { + deserializedEntityInner.name = reader.getString(); + } else if ("type".equals(fieldName)) { + deserializedEntityInner.type = reader.getString(); + } else if ("properties".equals(fieldName)) { + deserializedEntityInner.properties = EntityProperties.fromJson(reader); + } else if ("systemData".equals(fieldName)) { + deserializedEntityInner.systemData = SystemData.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedEntityInner; + }); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/models/HealthModelInner.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/models/HealthModelInner.java new file mode 100644 index 000000000000..44bb2bad3067 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/models/HealthModelInner.java @@ -0,0 +1,224 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.management.Resource; +import com.azure.core.management.SystemData; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.cloudhealth.models.HealthModelProperties; +import com.azure.resourcemanager.cloudhealth.models.ManagedServiceIdentity; +import java.io.IOException; +import java.util.Map; + +/** + * A HealthModel resource. + */ +@Fluent +public final class HealthModelInner extends Resource { + /* + * The resource-specific properties for this resource. + */ + private HealthModelProperties properties; + + /* + * The managed service identities assigned to this resource. + */ + private ManagedServiceIdentity identity; + + /* + * Azure Resource Manager metadata containing createdBy and modifiedBy information. + */ + private SystemData systemData; + + /* + * The type of the resource. + */ + private String type; + + /* + * The name of the resource. + */ + private String name; + + /* + * Fully qualified resource Id for the resource. + */ + private String id; + + /** + * Creates an instance of HealthModelInner class. + */ + public HealthModelInner() { + } + + /** + * Get the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + public HealthModelProperties properties() { + return this.properties; + } + + /** + * Set the properties property: The resource-specific properties for this resource. + * + * @param properties the properties value to set. + * @return the HealthModelInner object itself. + */ + public HealthModelInner withProperties(HealthModelProperties properties) { + this.properties = properties; + return this; + } + + /** + * Get the identity property: The managed service identities assigned to this resource. + * + * @return the identity value. + */ + public ManagedServiceIdentity identity() { + return this.identity; + } + + /** + * Set the identity property: The managed service identities assigned to this resource. + * + * @param identity the identity value to set. + * @return the HealthModelInner object itself. + */ + public HealthModelInner withIdentity(ManagedServiceIdentity identity) { + this.identity = identity; + return this; + } + + /** + * Get the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + public SystemData systemData() { + return this.systemData; + } + + /** + * Get the type property: The type of the resource. + * + * @return the type value. + */ + @Override + public String type() { + return this.type; + } + + /** + * Get the name property: The name of the resource. + * + * @return the name value. + */ + @Override + public String name() { + return this.name; + } + + /** + * Get the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + @Override + public String id() { + return this.id; + } + + /** + * {@inheritDoc} + */ + @Override + public HealthModelInner withLocation(String location) { + super.withLocation(location); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public HealthModelInner withTags(Map tags) { + super.withTags(tags); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (properties() != null) { + properties().validate(); + } + if (identity() != null) { + identity().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("location", location()); + jsonWriter.writeMapField("tags", tags(), (writer, element) -> writer.writeString(element)); + jsonWriter.writeJsonField("properties", this.properties); + jsonWriter.writeJsonField("identity", this.identity); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of HealthModelInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of HealthModelInner if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the HealthModelInner. + */ + public static HealthModelInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + HealthModelInner deserializedHealthModelInner = new HealthModelInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedHealthModelInner.id = reader.getString(); + } else if ("name".equals(fieldName)) { + deserializedHealthModelInner.name = reader.getString(); + } else if ("type".equals(fieldName)) { + deserializedHealthModelInner.type = reader.getString(); + } else if ("location".equals(fieldName)) { + deserializedHealthModelInner.withLocation(reader.getString()); + } else if ("tags".equals(fieldName)) { + Map tags = reader.readMap(reader1 -> reader1.getString()); + deserializedHealthModelInner.withTags(tags); + } else if ("properties".equals(fieldName)) { + deserializedHealthModelInner.properties = HealthModelProperties.fromJson(reader); + } else if ("identity".equals(fieldName)) { + deserializedHealthModelInner.identity = ManagedServiceIdentity.fromJson(reader); + } else if ("systemData".equals(fieldName)) { + deserializedHealthModelInner.systemData = SystemData.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedHealthModelInner; + }); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/models/OperationInner.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/models/OperationInner.java new file mode 100644 index 000000000000..b9f3fa018977 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/models/OperationInner.java @@ -0,0 +1,161 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.fluent.models; + +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.cloudhealth.models.ActionType; +import com.azure.resourcemanager.cloudhealth.models.OperationDisplay; +import com.azure.resourcemanager.cloudhealth.models.Origin; +import java.io.IOException; + +/** + * REST API Operation + * + * Details of a REST API operation, returned from the Resource Provider Operations API. + */ +@Immutable +public final class OperationInner implements JsonSerializable { + /* + * The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + * "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action" + */ + private String name; + + /* + * Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for Azure + * Resource Manager/control-plane operations. + */ + private Boolean isDataAction; + + /* + * Localized display information for this particular operation. + */ + private OperationDisplay display; + + /* + * The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default + * value is "user,system" + */ + private Origin origin; + + /* + * Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + */ + private ActionType actionType; + + /** + * Creates an instance of OperationInner class. + */ + private OperationInner() { + } + + /** + * Get the name property: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + * "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + * + * @return the name value. + */ + public String name() { + return this.name; + } + + /** + * Get the isDataAction property: Whether the operation applies to data-plane. This is "true" for data-plane + * operations and "false" for Azure Resource Manager/control-plane operations. + * + * @return the isDataAction value. + */ + public Boolean isDataAction() { + return this.isDataAction; + } + + /** + * Get the display property: Localized display information for this particular operation. + * + * @return the display value. + */ + public OperationDisplay display() { + return this.display; + } + + /** + * Get the origin property: The intended executor of the operation; as in Resource Based Access Control (RBAC) and + * audit logs UX. Default value is "user,system". + * + * @return the origin value. + */ + public Origin origin() { + return this.origin; + } + + /** + * Get the actionType property: Extensible enum. Indicates the action type. "Internal" refers to actions that are + * for internal only APIs. + * + * @return the actionType value. + */ + public ActionType actionType() { + return this.actionType; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (display() != null) { + display().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("display", this.display); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of OperationInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OperationInner if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the OperationInner. + */ + public static OperationInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OperationInner deserializedOperationInner = new OperationInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + deserializedOperationInner.name = reader.getString(); + } else if ("isDataAction".equals(fieldName)) { + deserializedOperationInner.isDataAction = reader.getNullable(JsonReader::getBoolean); + } else if ("display".equals(fieldName)) { + deserializedOperationInner.display = OperationDisplay.fromJson(reader); + } else if ("origin".equals(fieldName)) { + deserializedOperationInner.origin = Origin.fromString(reader.getString()); + } else if ("actionType".equals(fieldName)) { + deserializedOperationInner.actionType = ActionType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedOperationInner; + }); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/models/RelationshipInner.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/models/RelationshipInner.java new file mode 100644 index 000000000000..cb72bc372f7a --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/models/RelationshipInner.java @@ -0,0 +1,166 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.management.ProxyResource; +import com.azure.core.management.SystemData; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.cloudhealth.models.RelationshipProperties; +import java.io.IOException; + +/** + * A relationship (aka edge) between two entities in a health model. + */ +@Fluent +public final class RelationshipInner extends ProxyResource { + /* + * The resource-specific properties for this resource. + */ + private RelationshipProperties properties; + + /* + * Azure Resource Manager metadata containing createdBy and modifiedBy information. + */ + private SystemData systemData; + + /* + * The type of the resource. + */ + private String type; + + /* + * The name of the resource. + */ + private String name; + + /* + * Fully qualified resource Id for the resource. + */ + private String id; + + /** + * Creates an instance of RelationshipInner class. + */ + public RelationshipInner() { + } + + /** + * Get the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + public RelationshipProperties properties() { + return this.properties; + } + + /** + * Set the properties property: The resource-specific properties for this resource. + * + * @param properties the properties value to set. + * @return the RelationshipInner object itself. + */ + public RelationshipInner withProperties(RelationshipProperties properties) { + this.properties = properties; + return this; + } + + /** + * Get the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + public SystemData systemData() { + return this.systemData; + } + + /** + * Get the type property: The type of the resource. + * + * @return the type value. + */ + @Override + public String type() { + return this.type; + } + + /** + * Get the name property: The name of the resource. + * + * @return the name value. + */ + @Override + public String name() { + return this.name; + } + + /** + * Get the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + @Override + public String id() { + return this.id; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (properties() != null) { + properties().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("properties", this.properties); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RelationshipInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RelationshipInner if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the RelationshipInner. + */ + public static RelationshipInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + RelationshipInner deserializedRelationshipInner = new RelationshipInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedRelationshipInner.id = reader.getString(); + } else if ("name".equals(fieldName)) { + deserializedRelationshipInner.name = reader.getString(); + } else if ("type".equals(fieldName)) { + deserializedRelationshipInner.type = reader.getString(); + } else if ("properties".equals(fieldName)) { + deserializedRelationshipInner.properties = RelationshipProperties.fromJson(reader); + } else if ("systemData".equals(fieldName)) { + deserializedRelationshipInner.systemData = SystemData.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedRelationshipInner; + }); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/models/SignalDefinitionInner.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/models/SignalDefinitionInner.java new file mode 100644 index 000000000000..98c0137aa912 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/models/SignalDefinitionInner.java @@ -0,0 +1,166 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.management.ProxyResource; +import com.azure.core.management.SystemData; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.cloudhealth.models.SignalDefinitionProperties; +import java.io.IOException; + +/** + * A signal definition in a health model. + */ +@Fluent +public final class SignalDefinitionInner extends ProxyResource { + /* + * The resource-specific properties for this resource. + */ + private SignalDefinitionProperties properties; + + /* + * Azure Resource Manager metadata containing createdBy and modifiedBy information. + */ + private SystemData systemData; + + /* + * The type of the resource. + */ + private String type; + + /* + * The name of the resource. + */ + private String name; + + /* + * Fully qualified resource Id for the resource. + */ + private String id; + + /** + * Creates an instance of SignalDefinitionInner class. + */ + public SignalDefinitionInner() { + } + + /** + * Get the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + public SignalDefinitionProperties properties() { + return this.properties; + } + + /** + * Set the properties property: The resource-specific properties for this resource. + * + * @param properties the properties value to set. + * @return the SignalDefinitionInner object itself. + */ + public SignalDefinitionInner withProperties(SignalDefinitionProperties properties) { + this.properties = properties; + return this; + } + + /** + * Get the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + public SystemData systemData() { + return this.systemData; + } + + /** + * Get the type property: The type of the resource. + * + * @return the type value. + */ + @Override + public String type() { + return this.type; + } + + /** + * Get the name property: The name of the resource. + * + * @return the name value. + */ + @Override + public String name() { + return this.name; + } + + /** + * Get the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + @Override + public String id() { + return this.id; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (properties() != null) { + properties().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("properties", this.properties); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SignalDefinitionInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SignalDefinitionInner if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the SignalDefinitionInner. + */ + public static SignalDefinitionInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SignalDefinitionInner deserializedSignalDefinitionInner = new SignalDefinitionInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedSignalDefinitionInner.id = reader.getString(); + } else if ("name".equals(fieldName)) { + deserializedSignalDefinitionInner.name = reader.getString(); + } else if ("type".equals(fieldName)) { + deserializedSignalDefinitionInner.type = reader.getString(); + } else if ("properties".equals(fieldName)) { + deserializedSignalDefinitionInner.properties = SignalDefinitionProperties.fromJson(reader); + } else if ("systemData".equals(fieldName)) { + deserializedSignalDefinitionInner.systemData = SystemData.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedSignalDefinitionInner; + }); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/models/package-info.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/models/package-info.java new file mode 100644 index 000000000000..c5748a4ea987 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/models/package-info.java @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the inner data models for CloudHealth. + */ +package com.azure.resourcemanager.cloudhealth.fluent.models; diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/package-info.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/package-info.java new file mode 100644 index 000000000000..c05f236fc66a --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/fluent/package-info.java @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the service clients for CloudHealth. + */ +package com.azure.resourcemanager.cloudhealth.fluent; diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/AuthenticationSettingImpl.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/AuthenticationSettingImpl.java new file mode 100644 index 000000000000..fc93ed40dc1d --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/AuthenticationSettingImpl.java @@ -0,0 +1,139 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.implementation; + +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.azure.resourcemanager.cloudhealth.fluent.models.AuthenticationSettingInner; +import com.azure.resourcemanager.cloudhealth.models.AuthenticationSetting; +import com.azure.resourcemanager.cloudhealth.models.AuthenticationSettingProperties; + +public final class AuthenticationSettingImpl + implements AuthenticationSetting, AuthenticationSetting.Definition, AuthenticationSetting.Update { + private AuthenticationSettingInner innerObject; + + private final com.azure.resourcemanager.cloudhealth.CloudHealthManager serviceManager; + + public String id() { + return this.innerModel().id(); + } + + public String name() { + return this.innerModel().name(); + } + + public String type() { + return this.innerModel().type(); + } + + public AuthenticationSettingProperties properties() { + return this.innerModel().properties(); + } + + public SystemData systemData() { + return this.innerModel().systemData(); + } + + public String resourceGroupName() { + return resourceGroupName; + } + + public AuthenticationSettingInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.cloudhealth.CloudHealthManager manager() { + return this.serviceManager; + } + + private String resourceGroupName; + + private String healthModelName; + + private String authenticationSettingName; + + public AuthenticationSettingImpl withExistingHealthmodel(String resourceGroupName, String healthModelName) { + this.resourceGroupName = resourceGroupName; + this.healthModelName = healthModelName; + return this; + } + + public AuthenticationSetting create() { + this.innerObject = serviceManager.serviceClient() + .getAuthenticationSettings() + .createOrUpdateWithResponse(resourceGroupName, healthModelName, authenticationSettingName, + this.innerModel(), Context.NONE) + .getValue(); + return this; + } + + public AuthenticationSetting create(Context context) { + this.innerObject = serviceManager.serviceClient() + .getAuthenticationSettings() + .createOrUpdateWithResponse(resourceGroupName, healthModelName, authenticationSettingName, + this.innerModel(), context) + .getValue(); + return this; + } + + AuthenticationSettingImpl(String name, com.azure.resourcemanager.cloudhealth.CloudHealthManager serviceManager) { + this.innerObject = new AuthenticationSettingInner(); + this.serviceManager = serviceManager; + this.authenticationSettingName = name; + } + + public AuthenticationSettingImpl update() { + return this; + } + + public AuthenticationSetting apply() { + this.innerObject = serviceManager.serviceClient() + .getAuthenticationSettings() + .createOrUpdateWithResponse(resourceGroupName, healthModelName, authenticationSettingName, + this.innerModel(), Context.NONE) + .getValue(); + return this; + } + + public AuthenticationSetting apply(Context context) { + this.innerObject = serviceManager.serviceClient() + .getAuthenticationSettings() + .createOrUpdateWithResponse(resourceGroupName, healthModelName, authenticationSettingName, + this.innerModel(), context) + .getValue(); + return this; + } + + AuthenticationSettingImpl(AuthenticationSettingInner innerObject, + com.azure.resourcemanager.cloudhealth.CloudHealthManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + this.resourceGroupName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "resourceGroups"); + this.healthModelName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "healthmodels"); + this.authenticationSettingName + = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "authenticationsettings"); + } + + public AuthenticationSetting refresh() { + this.innerObject = serviceManager.serviceClient() + .getAuthenticationSettings() + .getWithResponse(resourceGroupName, healthModelName, authenticationSettingName, Context.NONE) + .getValue(); + return this; + } + + public AuthenticationSetting refresh(Context context) { + this.innerObject = serviceManager.serviceClient() + .getAuthenticationSettings() + .getWithResponse(resourceGroupName, healthModelName, authenticationSettingName, context) + .getValue(); + return this; + } + + public AuthenticationSettingImpl withProperties(AuthenticationSettingProperties properties) { + this.innerModel().withProperties(properties); + return this; + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/AuthenticationSettingsClientImpl.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/AuthenticationSettingsClientImpl.java new file mode 100644 index 000000000000..4843a068157d --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/AuthenticationSettingsClientImpl.java @@ -0,0 +1,750 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.implementation; + +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.Delete; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Headers; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Put; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.resourcemanager.cloudhealth.fluent.AuthenticationSettingsClient; +import com.azure.resourcemanager.cloudhealth.fluent.models.AuthenticationSettingInner; +import com.azure.resourcemanager.cloudhealth.implementation.models.AuthenticationSettingListResult; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in AuthenticationSettingsClient. + */ +public final class AuthenticationSettingsClientImpl implements AuthenticationSettingsClient { + /** + * The proxy service used to perform REST calls. + */ + private final AuthenticationSettingsService service; + + /** + * The service client containing this operation class. + */ + private final CloudHealthClientImpl client; + + /** + * Initializes an instance of AuthenticationSettingsClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + AuthenticationSettingsClientImpl(CloudHealthClientImpl client) { + this.service = RestProxy.create(AuthenticationSettingsService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for CloudHealthClientAuthenticationSettings to be used by the proxy + * service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "CloudHealthClientAut") + public interface AuthenticationSettingsService { + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CloudHealth/healthmodels/{healthModelName}/authenticationsettings/{authenticationSettingName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> get(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("healthModelName") String healthModelName, + @PathParam("authenticationSettingName") String authenticationSettingName, + @HeaderParam("Accept") String accept, Context context); + + @Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CloudHealth/healthmodels/{healthModelName}/authenticationsettings/{authenticationSettingName}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> createOrUpdate(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("healthModelName") String healthModelName, + @PathParam("authenticationSettingName") String authenticationSettingName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") AuthenticationSettingInner resource, Context context); + + @Headers({ "Content-Type: application/json" }) + @Delete("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CloudHealth/healthmodels/{healthModelName}/authenticationsettings/{authenticationSettingName}") + @ExpectedResponses({ 200, 204 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> delete(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("healthModelName") String healthModelName, + @PathParam("authenticationSettingName") String authenticationSettingName, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CloudHealth/healthmodels/{healthModelName}/authenticationsettings") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByHealthModel(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("healthModelName") String healthModelName, @HeaderParam("Accept") String accept, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByHealthModelNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, Context context); + } + + /** + * Get a AuthenticationSetting. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param authenticationSettingName Name of the authentication setting. Must be unique within a health model. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a AuthenticationSetting along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getWithResponseAsync(String resourceGroupName, + String healthModelName, String authenticationSettingName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (healthModelName == null) { + return Mono + .error(new IllegalArgumentException("Parameter healthModelName is required and cannot be null.")); + } + if (authenticationSettingName == null) { + return Mono.error( + new IllegalArgumentException("Parameter authenticationSettingName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.get(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, healthModelName, authenticationSettingName, accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get a AuthenticationSetting. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param authenticationSettingName Name of the authentication setting. Must be unique within a health model. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a AuthenticationSetting along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getWithResponseAsync(String resourceGroupName, + String healthModelName, String authenticationSettingName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (healthModelName == null) { + return Mono + .error(new IllegalArgumentException("Parameter healthModelName is required and cannot be null.")); + } + if (authenticationSettingName == null) { + return Mono.error( + new IllegalArgumentException("Parameter authenticationSettingName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.get(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, healthModelName, authenticationSettingName, accept, context); + } + + /** + * Get a AuthenticationSetting. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param authenticationSettingName Name of the authentication setting. Must be unique within a health model. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a AuthenticationSetting on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getAsync(String resourceGroupName, String healthModelName, + String authenticationSettingName) { + return getWithResponseAsync(resourceGroupName, healthModelName, authenticationSettingName) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Get a AuthenticationSetting. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param authenticationSettingName Name of the authentication setting. Must be unique within a health model. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a AuthenticationSetting along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(String resourceGroupName, String healthModelName, + String authenticationSettingName, Context context) { + return getWithResponseAsync(resourceGroupName, healthModelName, authenticationSettingName, context).block(); + } + + /** + * Get a AuthenticationSetting. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param authenticationSettingName Name of the authentication setting. Must be unique within a health model. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a AuthenticationSetting. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public AuthenticationSettingInner get(String resourceGroupName, String healthModelName, + String authenticationSettingName) { + return getWithResponse(resourceGroupName, healthModelName, authenticationSettingName, Context.NONE).getValue(); + } + + /** + * Create a AuthenticationSetting. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param authenticationSettingName Name of the authentication setting. Must be unique within a health model. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an authentication setting in a health model along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createOrUpdateWithResponseAsync(String resourceGroupName, + String healthModelName, String authenticationSettingName, AuthenticationSettingInner resource) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (healthModelName == null) { + return Mono + .error(new IllegalArgumentException("Parameter healthModelName is required and cannot be null.")); + } + if (authenticationSettingName == null) { + return Mono.error( + new IllegalArgumentException("Parameter authenticationSettingName is required and cannot be null.")); + } + if (resource == null) { + return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null.")); + } else { + resource.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.createOrUpdate(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, healthModelName, authenticationSettingName, + contentType, accept, resource, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Create a AuthenticationSetting. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param authenticationSettingName Name of the authentication setting. Must be unique within a health model. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an authentication setting in a health model along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createOrUpdateWithResponseAsync(String resourceGroupName, + String healthModelName, String authenticationSettingName, AuthenticationSettingInner resource, + Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (healthModelName == null) { + return Mono + .error(new IllegalArgumentException("Parameter healthModelName is required and cannot be null.")); + } + if (authenticationSettingName == null) { + return Mono.error( + new IllegalArgumentException("Parameter authenticationSettingName is required and cannot be null.")); + } + if (resource == null) { + return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null.")); + } else { + resource.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.createOrUpdate(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, healthModelName, authenticationSettingName, contentType, + accept, resource, context); + } + + /** + * Create a AuthenticationSetting. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param authenticationSettingName Name of the authentication setting. Must be unique within a health model. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an authentication setting in a health model on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrUpdateAsync(String resourceGroupName, String healthModelName, + String authenticationSettingName, AuthenticationSettingInner resource) { + return createOrUpdateWithResponseAsync(resourceGroupName, healthModelName, authenticationSettingName, resource) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Create a AuthenticationSetting. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param authenticationSettingName Name of the authentication setting. Must be unique within a health model. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an authentication setting in a health model along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createOrUpdateWithResponse(String resourceGroupName, + String healthModelName, String authenticationSettingName, AuthenticationSettingInner resource, + Context context) { + return createOrUpdateWithResponseAsync(resourceGroupName, healthModelName, authenticationSettingName, resource, + context).block(); + } + + /** + * Create a AuthenticationSetting. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param authenticationSettingName Name of the authentication setting. Must be unique within a health model. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an authentication setting in a health model. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public AuthenticationSettingInner createOrUpdate(String resourceGroupName, String healthModelName, + String authenticationSettingName, AuthenticationSettingInner resource) { + return createOrUpdateWithResponse(resourceGroupName, healthModelName, authenticationSettingName, resource, + Context.NONE).getValue(); + } + + /** + * Delete a AuthenticationSetting. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param authenticationSettingName Name of the authentication setting. Must be unique within a health model. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> deleteWithResponseAsync(String resourceGroupName, String healthModelName, + String authenticationSettingName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (healthModelName == null) { + return Mono + .error(new IllegalArgumentException("Parameter healthModelName is required and cannot be null.")); + } + if (authenticationSettingName == null) { + return Mono.error( + new IllegalArgumentException("Parameter authenticationSettingName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.delete(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, healthModelName, authenticationSettingName, accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Delete a AuthenticationSetting. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param authenticationSettingName Name of the authentication setting. Must be unique within a health model. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> deleteWithResponseAsync(String resourceGroupName, String healthModelName, + String authenticationSettingName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (healthModelName == null) { + return Mono + .error(new IllegalArgumentException("Parameter healthModelName is required and cannot be null.")); + } + if (authenticationSettingName == null) { + return Mono.error( + new IllegalArgumentException("Parameter authenticationSettingName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.delete(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, healthModelName, authenticationSettingName, accept, context); + } + + /** + * Delete a AuthenticationSetting. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param authenticationSettingName Name of the authentication setting. Must be unique within a health model. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono deleteAsync(String resourceGroupName, String healthModelName, String authenticationSettingName) { + return deleteWithResponseAsync(resourceGroupName, healthModelName, authenticationSettingName) + .flatMap(ignored -> Mono.empty()); + } + + /** + * Delete a AuthenticationSetting. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param authenticationSettingName Name of the authentication setting. Must be unique within a health model. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteWithResponse(String resourceGroupName, String healthModelName, + String authenticationSettingName, Context context) { + return deleteWithResponseAsync(resourceGroupName, healthModelName, authenticationSettingName, context).block(); + } + + /** + * Delete a AuthenticationSetting. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param authenticationSettingName Name of the authentication setting. Must be unique within a health model. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void delete(String resourceGroupName, String healthModelName, String authenticationSettingName) { + deleteWithResponse(resourceGroupName, healthModelName, authenticationSettingName, Context.NONE); + } + + /** + * List AuthenticationSetting resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a AuthenticationSetting list operation along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByHealthModelSinglePageAsync(String resourceGroupName, + String healthModelName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (healthModelName == null) { + return Mono + .error(new IllegalArgumentException("Parameter healthModelName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listByHealthModel(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, healthModelName, accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), + res.getStatusCode(), res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * List AuthenticationSetting resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a AuthenticationSetting list operation along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByHealthModelSinglePageAsync(String resourceGroupName, + String healthModelName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (healthModelName == null) { + return Mono + .error(new IllegalArgumentException("Parameter healthModelName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .listByHealthModel(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, healthModelName, accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } + + /** + * List AuthenticationSetting resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a AuthenticationSetting list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByHealthModelAsync(String resourceGroupName, + String healthModelName) { + return new PagedFlux<>(() -> listByHealthModelSinglePageAsync(resourceGroupName, healthModelName), + nextLink -> listByHealthModelNextSinglePageAsync(nextLink)); + } + + /** + * List AuthenticationSetting resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a AuthenticationSetting list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByHealthModelAsync(String resourceGroupName, + String healthModelName, Context context) { + return new PagedFlux<>(() -> listByHealthModelSinglePageAsync(resourceGroupName, healthModelName, context), + nextLink -> listByHealthModelNextSinglePageAsync(nextLink, context)); + } + + /** + * List AuthenticationSetting resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a AuthenticationSetting list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByHealthModel(String resourceGroupName, + String healthModelName) { + return new PagedIterable<>(listByHealthModelAsync(resourceGroupName, healthModelName)); + } + + /** + * List AuthenticationSetting resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a AuthenticationSetting list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByHealthModel(String resourceGroupName, String healthModelName, + Context context) { + return new PagedIterable<>(listByHealthModelAsync(resourceGroupName, healthModelName, context)); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a AuthenticationSetting list operation along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByHealthModelNextSinglePageAsync(String nextLink) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listByHealthModelNext(nextLink, this.client.getEndpoint(), accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), + res.getStatusCode(), res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a AuthenticationSetting list operation along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByHealthModelNextSinglePageAsync(String nextLink, + Context context) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.listByHealthModelNext(nextLink, this.client.getEndpoint(), accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/AuthenticationSettingsImpl.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/AuthenticationSettingsImpl.java new file mode 100644 index 000000000000..e4d8086c3c72 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/AuthenticationSettingsImpl.java @@ -0,0 +1,164 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.implementation; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.cloudhealth.fluent.AuthenticationSettingsClient; +import com.azure.resourcemanager.cloudhealth.fluent.models.AuthenticationSettingInner; +import com.azure.resourcemanager.cloudhealth.models.AuthenticationSetting; +import com.azure.resourcemanager.cloudhealth.models.AuthenticationSettings; + +public final class AuthenticationSettingsImpl implements AuthenticationSettings { + private static final ClientLogger LOGGER = new ClientLogger(AuthenticationSettingsImpl.class); + + private final AuthenticationSettingsClient innerClient; + + private final com.azure.resourcemanager.cloudhealth.CloudHealthManager serviceManager; + + public AuthenticationSettingsImpl(AuthenticationSettingsClient innerClient, + com.azure.resourcemanager.cloudhealth.CloudHealthManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public Response getWithResponse(String resourceGroupName, String healthModelName, + String authenticationSettingName, Context context) { + Response inner = this.serviceClient() + .getWithResponse(resourceGroupName, healthModelName, authenticationSettingName, context); + if (inner != null) { + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new AuthenticationSettingImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public AuthenticationSetting get(String resourceGroupName, String healthModelName, + String authenticationSettingName) { + AuthenticationSettingInner inner + = this.serviceClient().get(resourceGroupName, healthModelName, authenticationSettingName); + if (inner != null) { + return new AuthenticationSettingImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response deleteWithResponse(String resourceGroupName, String healthModelName, + String authenticationSettingName, Context context) { + return this.serviceClient() + .deleteWithResponse(resourceGroupName, healthModelName, authenticationSettingName, context); + } + + public void delete(String resourceGroupName, String healthModelName, String authenticationSettingName) { + this.serviceClient().delete(resourceGroupName, healthModelName, authenticationSettingName); + } + + public PagedIterable listByHealthModel(String resourceGroupName, String healthModelName) { + PagedIterable inner + = this.serviceClient().listByHealthModel(resourceGroupName, healthModelName); + return ResourceManagerUtils.mapPage(inner, inner1 -> new AuthenticationSettingImpl(inner1, this.manager())); + } + + public PagedIterable listByHealthModel(String resourceGroupName, String healthModelName, + Context context) { + PagedIterable inner + = this.serviceClient().listByHealthModel(resourceGroupName, healthModelName, context); + return ResourceManagerUtils.mapPage(inner, inner1 -> new AuthenticationSettingImpl(inner1, this.manager())); + } + + public AuthenticationSetting getById(String id) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String healthModelName = ResourceManagerUtils.getValueFromIdByName(id, "healthmodels"); + if (healthModelName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'healthmodels'.", id))); + } + String authenticationSettingName = ResourceManagerUtils.getValueFromIdByName(id, "authenticationsettings"); + if (authenticationSettingName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException(String + .format("The resource ID '%s' is not valid. Missing path segment 'authenticationsettings'.", id))); + } + return this.getWithResponse(resourceGroupName, healthModelName, authenticationSettingName, Context.NONE) + .getValue(); + } + + public Response getByIdWithResponse(String id, Context context) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String healthModelName = ResourceManagerUtils.getValueFromIdByName(id, "healthmodels"); + if (healthModelName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'healthmodels'.", id))); + } + String authenticationSettingName = ResourceManagerUtils.getValueFromIdByName(id, "authenticationsettings"); + if (authenticationSettingName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException(String + .format("The resource ID '%s' is not valid. Missing path segment 'authenticationsettings'.", id))); + } + return this.getWithResponse(resourceGroupName, healthModelName, authenticationSettingName, context); + } + + public void deleteById(String id) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String healthModelName = ResourceManagerUtils.getValueFromIdByName(id, "healthmodels"); + if (healthModelName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'healthmodels'.", id))); + } + String authenticationSettingName = ResourceManagerUtils.getValueFromIdByName(id, "authenticationsettings"); + if (authenticationSettingName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException(String + .format("The resource ID '%s' is not valid. Missing path segment 'authenticationsettings'.", id))); + } + this.deleteWithResponse(resourceGroupName, healthModelName, authenticationSettingName, Context.NONE); + } + + public Response deleteByIdWithResponse(String id, Context context) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String healthModelName = ResourceManagerUtils.getValueFromIdByName(id, "healthmodels"); + if (healthModelName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'healthmodels'.", id))); + } + String authenticationSettingName = ResourceManagerUtils.getValueFromIdByName(id, "authenticationsettings"); + if (authenticationSettingName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException(String + .format("The resource ID '%s' is not valid. Missing path segment 'authenticationsettings'.", id))); + } + return this.deleteWithResponse(resourceGroupName, healthModelName, authenticationSettingName, context); + } + + private AuthenticationSettingsClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.cloudhealth.CloudHealthManager manager() { + return this.serviceManager; + } + + public AuthenticationSettingImpl define(String name) { + return new AuthenticationSettingImpl(name, this.manager()); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/CloudHealthClientBuilder.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/CloudHealthClientBuilder.java new file mode 100644 index 000000000000..ccbd90f90ad9 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/CloudHealthClientBuilder.java @@ -0,0 +1,138 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.implementation; + +import com.azure.core.annotation.ServiceClientBuilder; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.management.AzureEnvironment; +import com.azure.core.management.serializer.SerializerFactory; +import com.azure.core.util.serializer.SerializerAdapter; +import java.time.Duration; + +/** + * A builder for creating a new instance of the CloudHealthClientImpl type. + */ +@ServiceClientBuilder(serviceClients = { CloudHealthClientImpl.class }) +public final class CloudHealthClientBuilder { + /* + * Service host + */ + private String endpoint; + + /** + * Sets Service host. + * + * @param endpoint the endpoint value. + * @return the CloudHealthClientBuilder. + */ + public CloudHealthClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * The ID of the target subscription. The value must be an UUID. + */ + private String subscriptionId; + + /** + * Sets The ID of the target subscription. The value must be an UUID. + * + * @param subscriptionId the subscriptionId value. + * @return the CloudHealthClientBuilder. + */ + public CloudHealthClientBuilder subscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + return this; + } + + /* + * The environment to connect to + */ + private AzureEnvironment environment; + + /** + * Sets The environment to connect to. + * + * @param environment the environment value. + * @return the CloudHealthClientBuilder. + */ + public CloudHealthClientBuilder environment(AzureEnvironment environment) { + this.environment = environment; + return this; + } + + /* + * The HTTP pipeline to send requests through + */ + private HttpPipeline pipeline; + + /** + * Sets The HTTP pipeline to send requests through. + * + * @param pipeline the pipeline value. + * @return the CloudHealthClientBuilder. + */ + public CloudHealthClientBuilder pipeline(HttpPipeline pipeline) { + this.pipeline = pipeline; + return this; + } + + /* + * The default poll interval for long-running operation + */ + private Duration defaultPollInterval; + + /** + * Sets The default poll interval for long-running operation. + * + * @param defaultPollInterval the defaultPollInterval value. + * @return the CloudHealthClientBuilder. + */ + public CloudHealthClientBuilder defaultPollInterval(Duration defaultPollInterval) { + this.defaultPollInterval = defaultPollInterval; + return this; + } + + /* + * The serializer to serialize an object into a string + */ + private SerializerAdapter serializerAdapter; + + /** + * Sets The serializer to serialize an object into a string. + * + * @param serializerAdapter the serializerAdapter value. + * @return the CloudHealthClientBuilder. + */ + public CloudHealthClientBuilder serializerAdapter(SerializerAdapter serializerAdapter) { + this.serializerAdapter = serializerAdapter; + return this; + } + + /** + * Builds an instance of CloudHealthClientImpl with the provided parameters. + * + * @return an instance of CloudHealthClientImpl. + */ + public CloudHealthClientImpl buildClient() { + String localEndpoint = (endpoint != null) ? endpoint : "https://management.azure.com"; + AzureEnvironment localEnvironment = (environment != null) ? environment : AzureEnvironment.AZURE; + HttpPipeline localPipeline = (pipeline != null) + ? pipeline + : new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(); + Duration localDefaultPollInterval + = (defaultPollInterval != null) ? defaultPollInterval : Duration.ofSeconds(30); + SerializerAdapter localSerializerAdapter = (serializerAdapter != null) + ? serializerAdapter + : SerializerFactory.createDefaultManagementSerializerAdapter(); + CloudHealthClientImpl client = new CloudHealthClientImpl(localPipeline, localSerializerAdapter, + localDefaultPollInterval, localEnvironment, localEndpoint, this.subscriptionId); + return client; + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/CloudHealthClientImpl.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/CloudHealthClientImpl.java new file mode 100644 index 000000000000..68380baa2fca --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/CloudHealthClientImpl.java @@ -0,0 +1,384 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.implementation; + +import com.azure.core.annotation.ServiceClient; +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.HttpHeaders; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpResponse; +import com.azure.core.http.rest.Response; +import com.azure.core.management.AzureEnvironment; +import com.azure.core.management.exception.ManagementError; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.management.polling.PollResult; +import com.azure.core.management.polling.PollerFactory; +import com.azure.core.util.Context; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.polling.AsyncPollResponse; +import com.azure.core.util.polling.LongRunningOperationStatus; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.serializer.SerializerAdapter; +import com.azure.core.util.serializer.SerializerEncoding; +import com.azure.resourcemanager.cloudhealth.fluent.AuthenticationSettingsClient; +import com.azure.resourcemanager.cloudhealth.fluent.CloudHealthClient; +import com.azure.resourcemanager.cloudhealth.fluent.DiscoveryRulesClient; +import com.azure.resourcemanager.cloudhealth.fluent.EntitiesClient; +import com.azure.resourcemanager.cloudhealth.fluent.HealthModelsClient; +import com.azure.resourcemanager.cloudhealth.fluent.OperationsClient; +import com.azure.resourcemanager.cloudhealth.fluent.RelationshipsClient; +import com.azure.resourcemanager.cloudhealth.fluent.SignalDefinitionsClient; +import java.io.IOException; +import java.lang.reflect.Type; +import java.nio.ByteBuffer; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.time.Duration; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the CloudHealthClientImpl type. + */ +@ServiceClient(builder = CloudHealthClientBuilder.class) +public final class CloudHealthClientImpl implements CloudHealthClient { + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Version parameter. + */ + private final String apiVersion; + + /** + * Gets Version parameter. + * + * @return the apiVersion value. + */ + public String getApiVersion() { + return this.apiVersion; + } + + /** + * The ID of the target subscription. The value must be an UUID. + */ + private final String subscriptionId; + + /** + * Gets The ID of the target subscription. The value must be an UUID. + * + * @return the subscriptionId value. + */ + public String getSubscriptionId() { + return this.subscriptionId; + } + + /** + * The HTTP pipeline to send requests through. + */ + private final HttpPipeline httpPipeline; + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + public HttpPipeline getHttpPipeline() { + return this.httpPipeline; + } + + /** + * The serializer to serialize an object into a string. + */ + private final SerializerAdapter serializerAdapter; + + /** + * Gets The serializer to serialize an object into a string. + * + * @return the serializerAdapter value. + */ + SerializerAdapter getSerializerAdapter() { + return this.serializerAdapter; + } + + /** + * The default poll interval for long-running operation. + */ + private final Duration defaultPollInterval; + + /** + * Gets The default poll interval for long-running operation. + * + * @return the defaultPollInterval value. + */ + public Duration getDefaultPollInterval() { + return this.defaultPollInterval; + } + + /** + * The OperationsClient object to access its operations. + */ + private final OperationsClient operations; + + /** + * Gets the OperationsClient object to access its operations. + * + * @return the OperationsClient object. + */ + public OperationsClient getOperations() { + return this.operations; + } + + /** + * The HealthModelsClient object to access its operations. + */ + private final HealthModelsClient healthModels; + + /** + * Gets the HealthModelsClient object to access its operations. + * + * @return the HealthModelsClient object. + */ + public HealthModelsClient getHealthModels() { + return this.healthModels; + } + + /** + * The SignalDefinitionsClient object to access its operations. + */ + private final SignalDefinitionsClient signalDefinitions; + + /** + * Gets the SignalDefinitionsClient object to access its operations. + * + * @return the SignalDefinitionsClient object. + */ + public SignalDefinitionsClient getSignalDefinitions() { + return this.signalDefinitions; + } + + /** + * The AuthenticationSettingsClient object to access its operations. + */ + private final AuthenticationSettingsClient authenticationSettings; + + /** + * Gets the AuthenticationSettingsClient object to access its operations. + * + * @return the AuthenticationSettingsClient object. + */ + public AuthenticationSettingsClient getAuthenticationSettings() { + return this.authenticationSettings; + } + + /** + * The EntitiesClient object to access its operations. + */ + private final EntitiesClient entities; + + /** + * Gets the EntitiesClient object to access its operations. + * + * @return the EntitiesClient object. + */ + public EntitiesClient getEntities() { + return this.entities; + } + + /** + * The RelationshipsClient object to access its operations. + */ + private final RelationshipsClient relationships; + + /** + * Gets the RelationshipsClient object to access its operations. + * + * @return the RelationshipsClient object. + */ + public RelationshipsClient getRelationships() { + return this.relationships; + } + + /** + * The DiscoveryRulesClient object to access its operations. + */ + private final DiscoveryRulesClient discoveryRules; + + /** + * Gets the DiscoveryRulesClient object to access its operations. + * + * @return the DiscoveryRulesClient object. + */ + public DiscoveryRulesClient getDiscoveryRules() { + return this.discoveryRules; + } + + /** + * Initializes an instance of CloudHealthClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param defaultPollInterval The default poll interval for long-running operation. + * @param environment The Azure environment. + * @param endpoint Service host. + * @param subscriptionId The ID of the target subscription. The value must be an UUID. + */ + CloudHealthClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, Duration defaultPollInterval, + AzureEnvironment environment, String endpoint, String subscriptionId) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.defaultPollInterval = defaultPollInterval; + this.endpoint = endpoint; + this.subscriptionId = subscriptionId; + this.apiVersion = "2023-10-01-preview"; + this.operations = new OperationsClientImpl(this); + this.healthModels = new HealthModelsClientImpl(this); + this.signalDefinitions = new SignalDefinitionsClientImpl(this); + this.authenticationSettings = new AuthenticationSettingsClientImpl(this); + this.entities = new EntitiesClientImpl(this); + this.relationships = new RelationshipsClientImpl(this); + this.discoveryRules = new DiscoveryRulesClientImpl(this); + } + + /** + * Gets default client context. + * + * @return the default client context. + */ + public Context getContext() { + return Context.NONE; + } + + /** + * Merges default client context with provided context. + * + * @param context the context to be merged with default client context. + * @return the merged context. + */ + public Context mergeContext(Context context) { + return CoreUtils.mergeContexts(this.getContext(), context); + } + + /** + * Gets long running operation result. + * + * @param activationResponse the response of activation operation. + * @param httpPipeline the http pipeline. + * @param pollResultType type of poll result. + * @param finalResultType type of final result. + * @param context the context shared by all requests. + * @param type of poll result. + * @param type of final result. + * @return poller flux for poll result and final result. + */ + public PollerFlux, U> getLroResult(Mono>> activationResponse, + HttpPipeline httpPipeline, Type pollResultType, Type finalResultType, Context context) { + return PollerFactory.create(serializerAdapter, httpPipeline, pollResultType, finalResultType, + defaultPollInterval, activationResponse, context); + } + + /** + * Gets the final result, or an error, based on last async poll response. + * + * @param response the last async poll response. + * @param type of poll result. + * @param type of final result. + * @return the final result, or an error. + */ + public Mono getLroFinalResultOrError(AsyncPollResponse, U> response) { + if (response.getStatus() != LongRunningOperationStatus.SUCCESSFULLY_COMPLETED) { + String errorMessage; + ManagementError managementError = null; + HttpResponse errorResponse = null; + PollResult.Error lroError = response.getValue().getError(); + if (lroError != null) { + errorResponse = new HttpResponseImpl(lroError.getResponseStatusCode(), lroError.getResponseHeaders(), + lroError.getResponseBody()); + + errorMessage = response.getValue().getError().getMessage(); + String errorBody = response.getValue().getError().getResponseBody(); + if (errorBody != null) { + // try to deserialize error body to ManagementError + try { + managementError = this.getSerializerAdapter() + .deserialize(errorBody, ManagementError.class, SerializerEncoding.JSON); + if (managementError.getCode() == null || managementError.getMessage() == null) { + managementError = null; + } + } catch (IOException | RuntimeException ioe) { + LOGGER.logThrowableAsWarning(ioe); + } + } + } else { + // fallback to default error message + errorMessage = "Long running operation failed."; + } + if (managementError == null) { + // fallback to default ManagementError + managementError = new ManagementError(response.getStatus().toString(), errorMessage); + } + return Mono.error(new ManagementException(errorMessage, errorResponse, managementError)); + } else { + return response.getFinalResult(); + } + } + + private static final class HttpResponseImpl extends HttpResponse { + private final int statusCode; + + private final byte[] responseBody; + + private final HttpHeaders httpHeaders; + + HttpResponseImpl(int statusCode, HttpHeaders httpHeaders, String responseBody) { + super(null); + this.statusCode = statusCode; + this.httpHeaders = httpHeaders; + this.responseBody = responseBody == null ? null : responseBody.getBytes(StandardCharsets.UTF_8); + } + + public int getStatusCode() { + return statusCode; + } + + public String getHeaderValue(String s) { + return httpHeaders.getValue(HttpHeaderName.fromString(s)); + } + + public HttpHeaders getHeaders() { + return httpHeaders; + } + + public Flux getBody() { + return Flux.just(ByteBuffer.wrap(responseBody)); + } + + public Mono getBodyAsByteArray() { + return Mono.just(responseBody); + } + + public Mono getBodyAsString() { + return Mono.just(new String(responseBody, StandardCharsets.UTF_8)); + } + + public Mono getBodyAsString(Charset charset) { + return Mono.just(new String(responseBody, charset)); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(CloudHealthClientImpl.class); +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/DiscoveryRuleImpl.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/DiscoveryRuleImpl.java new file mode 100644 index 000000000000..7402eebb0285 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/DiscoveryRuleImpl.java @@ -0,0 +1,137 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.implementation; + +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.azure.resourcemanager.cloudhealth.fluent.models.DiscoveryRuleInner; +import com.azure.resourcemanager.cloudhealth.models.DiscoveryRule; +import com.azure.resourcemanager.cloudhealth.models.DiscoveryRuleProperties; + +public final class DiscoveryRuleImpl implements DiscoveryRule, DiscoveryRule.Definition, DiscoveryRule.Update { + private DiscoveryRuleInner innerObject; + + private final com.azure.resourcemanager.cloudhealth.CloudHealthManager serviceManager; + + public String id() { + return this.innerModel().id(); + } + + public String name() { + return this.innerModel().name(); + } + + public String type() { + return this.innerModel().type(); + } + + public DiscoveryRuleProperties properties() { + return this.innerModel().properties(); + } + + public SystemData systemData() { + return this.innerModel().systemData(); + } + + public String resourceGroupName() { + return resourceGroupName; + } + + public DiscoveryRuleInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.cloudhealth.CloudHealthManager manager() { + return this.serviceManager; + } + + private String resourceGroupName; + + private String healthModelName; + + private String discoveryRuleName; + + public DiscoveryRuleImpl withExistingHealthmodel(String resourceGroupName, String healthModelName) { + this.resourceGroupName = resourceGroupName; + this.healthModelName = healthModelName; + return this; + } + + public DiscoveryRule create() { + this.innerObject = serviceManager.serviceClient() + .getDiscoveryRules() + .createOrUpdateWithResponse(resourceGroupName, healthModelName, discoveryRuleName, this.innerModel(), + Context.NONE) + .getValue(); + return this; + } + + public DiscoveryRule create(Context context) { + this.innerObject = serviceManager.serviceClient() + .getDiscoveryRules() + .createOrUpdateWithResponse(resourceGroupName, healthModelName, discoveryRuleName, this.innerModel(), + context) + .getValue(); + return this; + } + + DiscoveryRuleImpl(String name, com.azure.resourcemanager.cloudhealth.CloudHealthManager serviceManager) { + this.innerObject = new DiscoveryRuleInner(); + this.serviceManager = serviceManager; + this.discoveryRuleName = name; + } + + public DiscoveryRuleImpl update() { + return this; + } + + public DiscoveryRule apply() { + this.innerObject = serviceManager.serviceClient() + .getDiscoveryRules() + .createOrUpdateWithResponse(resourceGroupName, healthModelName, discoveryRuleName, this.innerModel(), + Context.NONE) + .getValue(); + return this; + } + + public DiscoveryRule apply(Context context) { + this.innerObject = serviceManager.serviceClient() + .getDiscoveryRules() + .createOrUpdateWithResponse(resourceGroupName, healthModelName, discoveryRuleName, this.innerModel(), + context) + .getValue(); + return this; + } + + DiscoveryRuleImpl(DiscoveryRuleInner innerObject, + com.azure.resourcemanager.cloudhealth.CloudHealthManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + this.resourceGroupName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "resourceGroups"); + this.healthModelName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "healthmodels"); + this.discoveryRuleName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "discoveryrules"); + } + + public DiscoveryRule refresh() { + this.innerObject = serviceManager.serviceClient() + .getDiscoveryRules() + .getWithResponse(resourceGroupName, healthModelName, discoveryRuleName, Context.NONE) + .getValue(); + return this; + } + + public DiscoveryRule refresh(Context context) { + this.innerObject = serviceManager.serviceClient() + .getDiscoveryRules() + .getWithResponse(resourceGroupName, healthModelName, discoveryRuleName, context) + .getValue(); + return this; + } + + public DiscoveryRuleImpl withProperties(DiscoveryRuleProperties properties) { + this.innerModel().withProperties(properties); + return this; + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/DiscoveryRulesClientImpl.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/DiscoveryRulesClientImpl.java new file mode 100644 index 000000000000..017a23117a13 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/DiscoveryRulesClientImpl.java @@ -0,0 +1,775 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.implementation; + +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.Delete; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Headers; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Put; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.resourcemanager.cloudhealth.fluent.DiscoveryRulesClient; +import com.azure.resourcemanager.cloudhealth.fluent.models.DiscoveryRuleInner; +import com.azure.resourcemanager.cloudhealth.implementation.models.DiscoveryRuleListResult; +import java.time.OffsetDateTime; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in DiscoveryRulesClient. + */ +public final class DiscoveryRulesClientImpl implements DiscoveryRulesClient { + /** + * The proxy service used to perform REST calls. + */ + private final DiscoveryRulesService service; + + /** + * The service client containing this operation class. + */ + private final CloudHealthClientImpl client; + + /** + * Initializes an instance of DiscoveryRulesClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + DiscoveryRulesClientImpl(CloudHealthClientImpl client) { + this.service + = RestProxy.create(DiscoveryRulesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for CloudHealthClientDiscoveryRules to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "CloudHealthClientDis") + public interface DiscoveryRulesService { + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CloudHealth/healthmodels/{healthModelName}/discoveryrules/{discoveryRuleName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> get(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("healthModelName") String healthModelName, + @PathParam("discoveryRuleName") String discoveryRuleName, @HeaderParam("Accept") String accept, + Context context); + + @Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CloudHealth/healthmodels/{healthModelName}/discoveryrules/{discoveryRuleName}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> createOrUpdate(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("healthModelName") String healthModelName, + @PathParam("discoveryRuleName") String discoveryRuleName, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") DiscoveryRuleInner resource, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Delete("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CloudHealth/healthmodels/{healthModelName}/discoveryrules/{discoveryRuleName}") + @ExpectedResponses({ 200, 204 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> delete(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("healthModelName") String healthModelName, + @PathParam("discoveryRuleName") String discoveryRuleName, @HeaderParam("Accept") String accept, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CloudHealth/healthmodels/{healthModelName}/discoveryrules") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByHealthModel(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @QueryParam("timestamp") OffsetDateTime timestamp, + @PathParam("healthModelName") String healthModelName, @HeaderParam("Accept") String accept, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByHealthModelNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, Context context); + } + + /** + * Get a DiscoveryRule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param discoveryRuleName Name of the discovery rule. Must be unique within a health model. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a DiscoveryRule along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getWithResponseAsync(String resourceGroupName, String healthModelName, + String discoveryRuleName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (healthModelName == null) { + return Mono + .error(new IllegalArgumentException("Parameter healthModelName is required and cannot be null.")); + } + if (discoveryRuleName == null) { + return Mono + .error(new IllegalArgumentException("Parameter discoveryRuleName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, healthModelName, discoveryRuleName, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get a DiscoveryRule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param discoveryRuleName Name of the discovery rule. Must be unique within a health model. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a DiscoveryRule along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getWithResponseAsync(String resourceGroupName, String healthModelName, + String discoveryRuleName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (healthModelName == null) { + return Mono + .error(new IllegalArgumentException("Parameter healthModelName is required and cannot be null.")); + } + if (discoveryRuleName == null) { + return Mono + .error(new IllegalArgumentException("Parameter discoveryRuleName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.get(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, healthModelName, discoveryRuleName, accept, context); + } + + /** + * Get a DiscoveryRule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param discoveryRuleName Name of the discovery rule. Must be unique within a health model. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a DiscoveryRule on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getAsync(String resourceGroupName, String healthModelName, + String discoveryRuleName) { + return getWithResponseAsync(resourceGroupName, healthModelName, discoveryRuleName) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Get a DiscoveryRule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param discoveryRuleName Name of the discovery rule. Must be unique within a health model. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a DiscoveryRule along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(String resourceGroupName, String healthModelName, + String discoveryRuleName, Context context) { + return getWithResponseAsync(resourceGroupName, healthModelName, discoveryRuleName, context).block(); + } + + /** + * Get a DiscoveryRule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param discoveryRuleName Name of the discovery rule. Must be unique within a health model. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a DiscoveryRule. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public DiscoveryRuleInner get(String resourceGroupName, String healthModelName, String discoveryRuleName) { + return getWithResponse(resourceGroupName, healthModelName, discoveryRuleName, Context.NONE).getValue(); + } + + /** + * Create a DiscoveryRule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param discoveryRuleName Name of the discovery rule. Must be unique within a health model. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a discovery rule which automatically finds entities and relationships in a health model based on an Azure + * Resource Graph query along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createOrUpdateWithResponseAsync(String resourceGroupName, + String healthModelName, String discoveryRuleName, DiscoveryRuleInner resource) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (healthModelName == null) { + return Mono + .error(new IllegalArgumentException("Parameter healthModelName is required and cannot be null.")); + } + if (discoveryRuleName == null) { + return Mono + .error(new IllegalArgumentException("Parameter discoveryRuleName is required and cannot be null.")); + } + if (resource == null) { + return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null.")); + } else { + resource.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.createOrUpdate(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, healthModelName, discoveryRuleName, contentType, + accept, resource, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Create a DiscoveryRule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param discoveryRuleName Name of the discovery rule. Must be unique within a health model. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a discovery rule which automatically finds entities and relationships in a health model based on an Azure + * Resource Graph query along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createOrUpdateWithResponseAsync(String resourceGroupName, + String healthModelName, String discoveryRuleName, DiscoveryRuleInner resource, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (healthModelName == null) { + return Mono + .error(new IllegalArgumentException("Parameter healthModelName is required and cannot be null.")); + } + if (discoveryRuleName == null) { + return Mono + .error(new IllegalArgumentException("Parameter discoveryRuleName is required and cannot be null.")); + } + if (resource == null) { + return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null.")); + } else { + resource.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.createOrUpdate(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, healthModelName, discoveryRuleName, contentType, accept, + resource, context); + } + + /** + * Create a DiscoveryRule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param discoveryRuleName Name of the discovery rule. Must be unique within a health model. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a discovery rule which automatically finds entities and relationships in a health model based on an Azure + * Resource Graph query on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrUpdateAsync(String resourceGroupName, String healthModelName, + String discoveryRuleName, DiscoveryRuleInner resource) { + return createOrUpdateWithResponseAsync(resourceGroupName, healthModelName, discoveryRuleName, resource) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Create a DiscoveryRule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param discoveryRuleName Name of the discovery rule. Must be unique within a health model. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a discovery rule which automatically finds entities and relationships in a health model based on an Azure + * Resource Graph query along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createOrUpdateWithResponse(String resourceGroupName, String healthModelName, + String discoveryRuleName, DiscoveryRuleInner resource, Context context) { + return createOrUpdateWithResponseAsync(resourceGroupName, healthModelName, discoveryRuleName, resource, context) + .block(); + } + + /** + * Create a DiscoveryRule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param discoveryRuleName Name of the discovery rule. Must be unique within a health model. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a discovery rule which automatically finds entities and relationships in a health model based on an Azure + * Resource Graph query. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public DiscoveryRuleInner createOrUpdate(String resourceGroupName, String healthModelName, String discoveryRuleName, + DiscoveryRuleInner resource) { + return createOrUpdateWithResponse(resourceGroupName, healthModelName, discoveryRuleName, resource, Context.NONE) + .getValue(); + } + + /** + * Delete a DiscoveryRule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param discoveryRuleName Name of the discovery rule. Must be unique within a health model. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> deleteWithResponseAsync(String resourceGroupName, String healthModelName, + String discoveryRuleName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (healthModelName == null) { + return Mono + .error(new IllegalArgumentException("Parameter healthModelName is required and cannot be null.")); + } + if (discoveryRuleName == null) { + return Mono + .error(new IllegalArgumentException("Parameter discoveryRuleName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.delete(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, healthModelName, discoveryRuleName, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Delete a DiscoveryRule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param discoveryRuleName Name of the discovery rule. Must be unique within a health model. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> deleteWithResponseAsync(String resourceGroupName, String healthModelName, + String discoveryRuleName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (healthModelName == null) { + return Mono + .error(new IllegalArgumentException("Parameter healthModelName is required and cannot be null.")); + } + if (discoveryRuleName == null) { + return Mono + .error(new IllegalArgumentException("Parameter discoveryRuleName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.delete(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, healthModelName, discoveryRuleName, accept, context); + } + + /** + * Delete a DiscoveryRule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param discoveryRuleName Name of the discovery rule. Must be unique within a health model. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono deleteAsync(String resourceGroupName, String healthModelName, String discoveryRuleName) { + return deleteWithResponseAsync(resourceGroupName, healthModelName, discoveryRuleName) + .flatMap(ignored -> Mono.empty()); + } + + /** + * Delete a DiscoveryRule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param discoveryRuleName Name of the discovery rule. Must be unique within a health model. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteWithResponse(String resourceGroupName, String healthModelName, String discoveryRuleName, + Context context) { + return deleteWithResponseAsync(resourceGroupName, healthModelName, discoveryRuleName, context).block(); + } + + /** + * Delete a DiscoveryRule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param discoveryRuleName Name of the discovery rule. Must be unique within a health model. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void delete(String resourceGroupName, String healthModelName, String discoveryRuleName) { + deleteWithResponse(resourceGroupName, healthModelName, discoveryRuleName, Context.NONE); + } + + /** + * List DiscoveryRule resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param timestamp Timestamp to use for the operation. When specified, the version of the resource at this point in + * time is retrieved. If not specified, the latest version is used. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a DiscoveryRule list operation along with {@link PagedResponse} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByHealthModelSinglePageAsync(String resourceGroupName, + String healthModelName, OffsetDateTime timestamp) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (healthModelName == null) { + return Mono + .error(new IllegalArgumentException("Parameter healthModelName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listByHealthModel(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, timestamp, healthModelName, accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), + res.getStatusCode(), res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * List DiscoveryRule resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param timestamp Timestamp to use for the operation. When specified, the version of the resource at this point in + * time is retrieved. If not specified, the latest version is used. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a DiscoveryRule list operation along with {@link PagedResponse} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByHealthModelSinglePageAsync(String resourceGroupName, + String healthModelName, OffsetDateTime timestamp, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (healthModelName == null) { + return Mono + .error(new IllegalArgumentException("Parameter healthModelName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .listByHealthModel(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, timestamp, healthModelName, accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } + + /** + * List DiscoveryRule resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param timestamp Timestamp to use for the operation. When specified, the version of the resource at this point in + * time is retrieved. If not specified, the latest version is used. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a DiscoveryRule list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByHealthModelAsync(String resourceGroupName, String healthModelName, + OffsetDateTime timestamp) { + return new PagedFlux<>(() -> listByHealthModelSinglePageAsync(resourceGroupName, healthModelName, timestamp), + nextLink -> listByHealthModelNextSinglePageAsync(nextLink)); + } + + /** + * List DiscoveryRule resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a DiscoveryRule list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByHealthModelAsync(String resourceGroupName, String healthModelName) { + final OffsetDateTime timestamp = null; + return new PagedFlux<>(() -> listByHealthModelSinglePageAsync(resourceGroupName, healthModelName, timestamp), + nextLink -> listByHealthModelNextSinglePageAsync(nextLink)); + } + + /** + * List DiscoveryRule resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param timestamp Timestamp to use for the operation. When specified, the version of the resource at this point in + * time is retrieved. If not specified, the latest version is used. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a DiscoveryRule list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByHealthModelAsync(String resourceGroupName, String healthModelName, + OffsetDateTime timestamp, Context context) { + return new PagedFlux<>( + () -> listByHealthModelSinglePageAsync(resourceGroupName, healthModelName, timestamp, context), + nextLink -> listByHealthModelNextSinglePageAsync(nextLink, context)); + } + + /** + * List DiscoveryRule resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a DiscoveryRule list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByHealthModel(String resourceGroupName, String healthModelName) { + final OffsetDateTime timestamp = null; + return new PagedIterable<>(listByHealthModelAsync(resourceGroupName, healthModelName, timestamp)); + } + + /** + * List DiscoveryRule resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param timestamp Timestamp to use for the operation. When specified, the version of the resource at this point in + * time is retrieved. If not specified, the latest version is used. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a DiscoveryRule list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByHealthModel(String resourceGroupName, String healthModelName, + OffsetDateTime timestamp, Context context) { + return new PagedIterable<>(listByHealthModelAsync(resourceGroupName, healthModelName, timestamp, context)); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a DiscoveryRule list operation along with {@link PagedResponse} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByHealthModelNextSinglePageAsync(String nextLink) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listByHealthModelNext(nextLink, this.client.getEndpoint(), accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), + res.getStatusCode(), res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a DiscoveryRule list operation along with {@link PagedResponse} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByHealthModelNextSinglePageAsync(String nextLink, + Context context) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.listByHealthModelNext(nextLink, this.client.getEndpoint(), accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/DiscoveryRulesImpl.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/DiscoveryRulesImpl.java new file mode 100644 index 000000000000..dd9e42a11620 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/DiscoveryRulesImpl.java @@ -0,0 +1,161 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.implementation; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.cloudhealth.fluent.DiscoveryRulesClient; +import com.azure.resourcemanager.cloudhealth.fluent.models.DiscoveryRuleInner; +import com.azure.resourcemanager.cloudhealth.models.DiscoveryRule; +import com.azure.resourcemanager.cloudhealth.models.DiscoveryRules; +import java.time.OffsetDateTime; + +public final class DiscoveryRulesImpl implements DiscoveryRules { + private static final ClientLogger LOGGER = new ClientLogger(DiscoveryRulesImpl.class); + + private final DiscoveryRulesClient innerClient; + + private final com.azure.resourcemanager.cloudhealth.CloudHealthManager serviceManager; + + public DiscoveryRulesImpl(DiscoveryRulesClient innerClient, + com.azure.resourcemanager.cloudhealth.CloudHealthManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public Response getWithResponse(String resourceGroupName, String healthModelName, + String discoveryRuleName, Context context) { + Response inner + = this.serviceClient().getWithResponse(resourceGroupName, healthModelName, discoveryRuleName, context); + if (inner != null) { + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new DiscoveryRuleImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public DiscoveryRule get(String resourceGroupName, String healthModelName, String discoveryRuleName) { + DiscoveryRuleInner inner = this.serviceClient().get(resourceGroupName, healthModelName, discoveryRuleName); + if (inner != null) { + return new DiscoveryRuleImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response deleteWithResponse(String resourceGroupName, String healthModelName, String discoveryRuleName, + Context context) { + return this.serviceClient().deleteWithResponse(resourceGroupName, healthModelName, discoveryRuleName, context); + } + + public void delete(String resourceGroupName, String healthModelName, String discoveryRuleName) { + this.serviceClient().delete(resourceGroupName, healthModelName, discoveryRuleName); + } + + public PagedIterable listByHealthModel(String resourceGroupName, String healthModelName) { + PagedIterable inner + = this.serviceClient().listByHealthModel(resourceGroupName, healthModelName); + return ResourceManagerUtils.mapPage(inner, inner1 -> new DiscoveryRuleImpl(inner1, this.manager())); + } + + public PagedIterable listByHealthModel(String resourceGroupName, String healthModelName, + OffsetDateTime timestamp, Context context) { + PagedIterable inner + = this.serviceClient().listByHealthModel(resourceGroupName, healthModelName, timestamp, context); + return ResourceManagerUtils.mapPage(inner, inner1 -> new DiscoveryRuleImpl(inner1, this.manager())); + } + + public DiscoveryRule getById(String id) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String healthModelName = ResourceManagerUtils.getValueFromIdByName(id, "healthmodels"); + if (healthModelName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'healthmodels'.", id))); + } + String discoveryRuleName = ResourceManagerUtils.getValueFromIdByName(id, "discoveryrules"); + if (discoveryRuleName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'discoveryrules'.", id))); + } + return this.getWithResponse(resourceGroupName, healthModelName, discoveryRuleName, Context.NONE).getValue(); + } + + public Response getByIdWithResponse(String id, Context context) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String healthModelName = ResourceManagerUtils.getValueFromIdByName(id, "healthmodels"); + if (healthModelName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'healthmodels'.", id))); + } + String discoveryRuleName = ResourceManagerUtils.getValueFromIdByName(id, "discoveryrules"); + if (discoveryRuleName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'discoveryrules'.", id))); + } + return this.getWithResponse(resourceGroupName, healthModelName, discoveryRuleName, context); + } + + public void deleteById(String id) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String healthModelName = ResourceManagerUtils.getValueFromIdByName(id, "healthmodels"); + if (healthModelName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'healthmodels'.", id))); + } + String discoveryRuleName = ResourceManagerUtils.getValueFromIdByName(id, "discoveryrules"); + if (discoveryRuleName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'discoveryrules'.", id))); + } + this.deleteWithResponse(resourceGroupName, healthModelName, discoveryRuleName, Context.NONE); + } + + public Response deleteByIdWithResponse(String id, Context context) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String healthModelName = ResourceManagerUtils.getValueFromIdByName(id, "healthmodels"); + if (healthModelName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'healthmodels'.", id))); + } + String discoveryRuleName = ResourceManagerUtils.getValueFromIdByName(id, "discoveryrules"); + if (discoveryRuleName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'discoveryrules'.", id))); + } + return this.deleteWithResponse(resourceGroupName, healthModelName, discoveryRuleName, context); + } + + private DiscoveryRulesClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.cloudhealth.CloudHealthManager manager() { + return this.serviceManager; + } + + public DiscoveryRuleImpl define(String name) { + return new DiscoveryRuleImpl(name, this.manager()); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/EntitiesClientImpl.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/EntitiesClientImpl.java new file mode 100644 index 000000000000..6f84962ab2f0 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/EntitiesClientImpl.java @@ -0,0 +1,761 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.implementation; + +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.Delete; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Headers; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Put; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.resourcemanager.cloudhealth.fluent.EntitiesClient; +import com.azure.resourcemanager.cloudhealth.fluent.models.EntityInner; +import com.azure.resourcemanager.cloudhealth.implementation.models.EntityListResult; +import java.time.OffsetDateTime; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in EntitiesClient. + */ +public final class EntitiesClientImpl implements EntitiesClient { + /** + * The proxy service used to perform REST calls. + */ + private final EntitiesService service; + + /** + * The service client containing this operation class. + */ + private final CloudHealthClientImpl client; + + /** + * Initializes an instance of EntitiesClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + EntitiesClientImpl(CloudHealthClientImpl client) { + this.service = RestProxy.create(EntitiesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for CloudHealthClientEntities to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "CloudHealthClientEnt") + public interface EntitiesService { + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CloudHealth/healthmodels/{healthModelName}/entities/{entityName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> get(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("healthModelName") String healthModelName, @PathParam("entityName") String entityName, + @HeaderParam("Accept") String accept, Context context); + + @Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CloudHealth/healthmodels/{healthModelName}/entities/{entityName}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> createOrUpdate(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("healthModelName") String healthModelName, @PathParam("entityName") String entityName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") EntityInner resource, Context context); + + @Headers({ "Content-Type: application/json" }) + @Delete("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CloudHealth/healthmodels/{healthModelName}/entities/{entityName}") + @ExpectedResponses({ 200, 204 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> delete(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("healthModelName") String healthModelName, @PathParam("entityName") String entityName, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CloudHealth/healthmodels/{healthModelName}/entities") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByHealthModel(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @QueryParam("timestamp") OffsetDateTime timestamp, + @PathParam("healthModelName") String healthModelName, @HeaderParam("Accept") String accept, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByHealthModelNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, Context context); + } + + /** + * Get a Entity. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param entityName Name of the entity. Must be unique within a health model. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Entity along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getWithResponseAsync(String resourceGroupName, String healthModelName, + String entityName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (healthModelName == null) { + return Mono + .error(new IllegalArgumentException("Parameter healthModelName is required and cannot be null.")); + } + if (entityName == null) { + return Mono.error(new IllegalArgumentException("Parameter entityName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.get(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, healthModelName, entityName, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get a Entity. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param entityName Name of the entity. Must be unique within a health model. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Entity along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getWithResponseAsync(String resourceGroupName, String healthModelName, + String entityName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (healthModelName == null) { + return Mono + .error(new IllegalArgumentException("Parameter healthModelName is required and cannot be null.")); + } + if (entityName == null) { + return Mono.error(new IllegalArgumentException("Parameter entityName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.get(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, healthModelName, entityName, accept, context); + } + + /** + * Get a Entity. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param entityName Name of the entity. Must be unique within a health model. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Entity on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getAsync(String resourceGroupName, String healthModelName, String entityName) { + return getWithResponseAsync(resourceGroupName, healthModelName, entityName) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Get a Entity. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param entityName Name of the entity. Must be unique within a health model. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Entity along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(String resourceGroupName, String healthModelName, String entityName, + Context context) { + return getWithResponseAsync(resourceGroupName, healthModelName, entityName, context).block(); + } + + /** + * Get a Entity. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param entityName Name of the entity. Must be unique within a health model. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Entity. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public EntityInner get(String resourceGroupName, String healthModelName, String entityName) { + return getWithResponse(resourceGroupName, healthModelName, entityName, Context.NONE).getValue(); + } + + /** + * Create a Entity. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param entityName Name of the entity. Must be unique within a health model. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an entity (aka node) of a health model along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createOrUpdateWithResponseAsync(String resourceGroupName, + String healthModelName, String entityName, EntityInner resource) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (healthModelName == null) { + return Mono + .error(new IllegalArgumentException("Parameter healthModelName is required and cannot be null.")); + } + if (entityName == null) { + return Mono.error(new IllegalArgumentException("Parameter entityName is required and cannot be null.")); + } + if (resource == null) { + return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null.")); + } else { + resource.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.createOrUpdate(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, healthModelName, entityName, contentType, accept, + resource, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Create a Entity. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param entityName Name of the entity. Must be unique within a health model. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an entity (aka node) of a health model along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createOrUpdateWithResponseAsync(String resourceGroupName, + String healthModelName, String entityName, EntityInner resource, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (healthModelName == null) { + return Mono + .error(new IllegalArgumentException("Parameter healthModelName is required and cannot be null.")); + } + if (entityName == null) { + return Mono.error(new IllegalArgumentException("Parameter entityName is required and cannot be null.")); + } + if (resource == null) { + return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null.")); + } else { + resource.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.createOrUpdate(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, healthModelName, entityName, contentType, accept, + resource, context); + } + + /** + * Create a Entity. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param entityName Name of the entity. Must be unique within a health model. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an entity (aka node) of a health model on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrUpdateAsync(String resourceGroupName, String healthModelName, String entityName, + EntityInner resource) { + return createOrUpdateWithResponseAsync(resourceGroupName, healthModelName, entityName, resource) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Create a Entity. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param entityName Name of the entity. Must be unique within a health model. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an entity (aka node) of a health model along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createOrUpdateWithResponse(String resourceGroupName, String healthModelName, + String entityName, EntityInner resource, Context context) { + return createOrUpdateWithResponseAsync(resourceGroupName, healthModelName, entityName, resource, context) + .block(); + } + + /** + * Create a Entity. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param entityName Name of the entity. Must be unique within a health model. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an entity (aka node) of a health model. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public EntityInner createOrUpdate(String resourceGroupName, String healthModelName, String entityName, + EntityInner resource) { + return createOrUpdateWithResponse(resourceGroupName, healthModelName, entityName, resource, Context.NONE) + .getValue(); + } + + /** + * Delete a Entity. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param entityName Name of the entity. Must be unique within a health model. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> deleteWithResponseAsync(String resourceGroupName, String healthModelName, + String entityName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (healthModelName == null) { + return Mono + .error(new IllegalArgumentException("Parameter healthModelName is required and cannot be null.")); + } + if (entityName == null) { + return Mono.error(new IllegalArgumentException("Parameter entityName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.delete(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, healthModelName, entityName, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Delete a Entity. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param entityName Name of the entity. Must be unique within a health model. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> deleteWithResponseAsync(String resourceGroupName, String healthModelName, + String entityName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (healthModelName == null) { + return Mono + .error(new IllegalArgumentException("Parameter healthModelName is required and cannot be null.")); + } + if (entityName == null) { + return Mono.error(new IllegalArgumentException("Parameter entityName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.delete(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, healthModelName, entityName, accept, context); + } + + /** + * Delete a Entity. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param entityName Name of the entity. Must be unique within a health model. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono deleteAsync(String resourceGroupName, String healthModelName, String entityName) { + return deleteWithResponseAsync(resourceGroupName, healthModelName, entityName).flatMap(ignored -> Mono.empty()); + } + + /** + * Delete a Entity. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param entityName Name of the entity. Must be unique within a health model. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteWithResponse(String resourceGroupName, String healthModelName, String entityName, + Context context) { + return deleteWithResponseAsync(resourceGroupName, healthModelName, entityName, context).block(); + } + + /** + * Delete a Entity. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param entityName Name of the entity. Must be unique within a health model. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void delete(String resourceGroupName, String healthModelName, String entityName) { + deleteWithResponse(resourceGroupName, healthModelName, entityName, Context.NONE); + } + + /** + * List Entity resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param timestamp Timestamp to use for the operation. When specified, the version of the resource at this point in + * time is retrieved. If not specified, the latest version is used. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Entity list operation along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByHealthModelSinglePageAsync(String resourceGroupName, + String healthModelName, OffsetDateTime timestamp) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (healthModelName == null) { + return Mono + .error(new IllegalArgumentException("Parameter healthModelName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listByHealthModel(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, timestamp, healthModelName, accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), + res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * List Entity resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param timestamp Timestamp to use for the operation. When specified, the version of the resource at this point in + * time is retrieved. If not specified, the latest version is used. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Entity list operation along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByHealthModelSinglePageAsync(String resourceGroupName, + String healthModelName, OffsetDateTime timestamp, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (healthModelName == null) { + return Mono + .error(new IllegalArgumentException("Parameter healthModelName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .listByHealthModel(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, timestamp, healthModelName, accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } + + /** + * List Entity resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param timestamp Timestamp to use for the operation. When specified, the version of the resource at this point in + * time is retrieved. If not specified, the latest version is used. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Entity list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByHealthModelAsync(String resourceGroupName, String healthModelName, + OffsetDateTime timestamp) { + return new PagedFlux<>(() -> listByHealthModelSinglePageAsync(resourceGroupName, healthModelName, timestamp), + nextLink -> listByHealthModelNextSinglePageAsync(nextLink)); + } + + /** + * List Entity resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Entity list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByHealthModelAsync(String resourceGroupName, String healthModelName) { + final OffsetDateTime timestamp = null; + return new PagedFlux<>(() -> listByHealthModelSinglePageAsync(resourceGroupName, healthModelName, timestamp), + nextLink -> listByHealthModelNextSinglePageAsync(nextLink)); + } + + /** + * List Entity resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param timestamp Timestamp to use for the operation. When specified, the version of the resource at this point in + * time is retrieved. If not specified, the latest version is used. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Entity list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByHealthModelAsync(String resourceGroupName, String healthModelName, + OffsetDateTime timestamp, Context context) { + return new PagedFlux<>( + () -> listByHealthModelSinglePageAsync(resourceGroupName, healthModelName, timestamp, context), + nextLink -> listByHealthModelNextSinglePageAsync(nextLink, context)); + } + + /** + * List Entity resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Entity list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByHealthModel(String resourceGroupName, String healthModelName) { + final OffsetDateTime timestamp = null; + return new PagedIterable<>(listByHealthModelAsync(resourceGroupName, healthModelName, timestamp)); + } + + /** + * List Entity resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param timestamp Timestamp to use for the operation. When specified, the version of the resource at this point in + * time is retrieved. If not specified, the latest version is used. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Entity list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByHealthModel(String resourceGroupName, String healthModelName, + OffsetDateTime timestamp, Context context) { + return new PagedIterable<>(listByHealthModelAsync(resourceGroupName, healthModelName, timestamp, context)); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Entity list operation along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByHealthModelNextSinglePageAsync(String nextLink) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listByHealthModelNext(nextLink, this.client.getEndpoint(), accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), + res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Entity list operation along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByHealthModelNextSinglePageAsync(String nextLink, Context context) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.listByHealthModelNext(nextLink, this.client.getEndpoint(), accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/EntitiesImpl.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/EntitiesImpl.java new file mode 100644 index 000000000000..929ec5d96155 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/EntitiesImpl.java @@ -0,0 +1,160 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.implementation; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.cloudhealth.fluent.EntitiesClient; +import com.azure.resourcemanager.cloudhealth.fluent.models.EntityInner; +import com.azure.resourcemanager.cloudhealth.models.Entities; +import com.azure.resourcemanager.cloudhealth.models.Entity; +import java.time.OffsetDateTime; + +public final class EntitiesImpl implements Entities { + private static final ClientLogger LOGGER = new ClientLogger(EntitiesImpl.class); + + private final EntitiesClient innerClient; + + private final com.azure.resourcemanager.cloudhealth.CloudHealthManager serviceManager; + + public EntitiesImpl(EntitiesClient innerClient, + com.azure.resourcemanager.cloudhealth.CloudHealthManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public Response getWithResponse(String resourceGroupName, String healthModelName, String entityName, + Context context) { + Response inner + = this.serviceClient().getWithResponse(resourceGroupName, healthModelName, entityName, context); + if (inner != null) { + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new EntityImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public Entity get(String resourceGroupName, String healthModelName, String entityName) { + EntityInner inner = this.serviceClient().get(resourceGroupName, healthModelName, entityName); + if (inner != null) { + return new EntityImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response deleteWithResponse(String resourceGroupName, String healthModelName, String entityName, + Context context) { + return this.serviceClient().deleteWithResponse(resourceGroupName, healthModelName, entityName, context); + } + + public void delete(String resourceGroupName, String healthModelName, String entityName) { + this.serviceClient().delete(resourceGroupName, healthModelName, entityName); + } + + public PagedIterable listByHealthModel(String resourceGroupName, String healthModelName) { + PagedIterable inner = this.serviceClient().listByHealthModel(resourceGroupName, healthModelName); + return ResourceManagerUtils.mapPage(inner, inner1 -> new EntityImpl(inner1, this.manager())); + } + + public PagedIterable listByHealthModel(String resourceGroupName, String healthModelName, + OffsetDateTime timestamp, Context context) { + PagedIterable inner + = this.serviceClient().listByHealthModel(resourceGroupName, healthModelName, timestamp, context); + return ResourceManagerUtils.mapPage(inner, inner1 -> new EntityImpl(inner1, this.manager())); + } + + public Entity getById(String id) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String healthModelName = ResourceManagerUtils.getValueFromIdByName(id, "healthmodels"); + if (healthModelName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'healthmodels'.", id))); + } + String entityName = ResourceManagerUtils.getValueFromIdByName(id, "entities"); + if (entityName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'entities'.", id))); + } + return this.getWithResponse(resourceGroupName, healthModelName, entityName, Context.NONE).getValue(); + } + + public Response getByIdWithResponse(String id, Context context) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String healthModelName = ResourceManagerUtils.getValueFromIdByName(id, "healthmodels"); + if (healthModelName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'healthmodels'.", id))); + } + String entityName = ResourceManagerUtils.getValueFromIdByName(id, "entities"); + if (entityName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'entities'.", id))); + } + return this.getWithResponse(resourceGroupName, healthModelName, entityName, context); + } + + public void deleteById(String id) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String healthModelName = ResourceManagerUtils.getValueFromIdByName(id, "healthmodels"); + if (healthModelName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'healthmodels'.", id))); + } + String entityName = ResourceManagerUtils.getValueFromIdByName(id, "entities"); + if (entityName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'entities'.", id))); + } + this.deleteWithResponse(resourceGroupName, healthModelName, entityName, Context.NONE); + } + + public Response deleteByIdWithResponse(String id, Context context) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String healthModelName = ResourceManagerUtils.getValueFromIdByName(id, "healthmodels"); + if (healthModelName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'healthmodels'.", id))); + } + String entityName = ResourceManagerUtils.getValueFromIdByName(id, "entities"); + if (entityName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'entities'.", id))); + } + return this.deleteWithResponse(resourceGroupName, healthModelName, entityName, context); + } + + private EntitiesClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.cloudhealth.CloudHealthManager manager() { + return this.serviceManager; + } + + public EntityImpl define(String name) { + return new EntityImpl(name, this.manager()); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/EntityImpl.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/EntityImpl.java new file mode 100644 index 000000000000..6aed37231a11 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/EntityImpl.java @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.implementation; + +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.azure.resourcemanager.cloudhealth.fluent.models.EntityInner; +import com.azure.resourcemanager.cloudhealth.models.Entity; +import com.azure.resourcemanager.cloudhealth.models.EntityProperties; + +public final class EntityImpl implements Entity, Entity.Definition, Entity.Update { + private EntityInner innerObject; + + private final com.azure.resourcemanager.cloudhealth.CloudHealthManager serviceManager; + + public String id() { + return this.innerModel().id(); + } + + public String name() { + return this.innerModel().name(); + } + + public String type() { + return this.innerModel().type(); + } + + public EntityProperties properties() { + return this.innerModel().properties(); + } + + public SystemData systemData() { + return this.innerModel().systemData(); + } + + public String resourceGroupName() { + return resourceGroupName; + } + + public EntityInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.cloudhealth.CloudHealthManager manager() { + return this.serviceManager; + } + + private String resourceGroupName; + + private String healthModelName; + + private String entityName; + + public EntityImpl withExistingHealthmodel(String resourceGroupName, String healthModelName) { + this.resourceGroupName = resourceGroupName; + this.healthModelName = healthModelName; + return this; + } + + public Entity create() { + this.innerObject = serviceManager.serviceClient() + .getEntities() + .createOrUpdateWithResponse(resourceGroupName, healthModelName, entityName, this.innerModel(), Context.NONE) + .getValue(); + return this; + } + + public Entity create(Context context) { + this.innerObject = serviceManager.serviceClient() + .getEntities() + .createOrUpdateWithResponse(resourceGroupName, healthModelName, entityName, this.innerModel(), context) + .getValue(); + return this; + } + + EntityImpl(String name, com.azure.resourcemanager.cloudhealth.CloudHealthManager serviceManager) { + this.innerObject = new EntityInner(); + this.serviceManager = serviceManager; + this.entityName = name; + } + + public EntityImpl update() { + return this; + } + + public Entity apply() { + this.innerObject = serviceManager.serviceClient() + .getEntities() + .createOrUpdateWithResponse(resourceGroupName, healthModelName, entityName, this.innerModel(), Context.NONE) + .getValue(); + return this; + } + + public Entity apply(Context context) { + this.innerObject = serviceManager.serviceClient() + .getEntities() + .createOrUpdateWithResponse(resourceGroupName, healthModelName, entityName, this.innerModel(), context) + .getValue(); + return this; + } + + EntityImpl(EntityInner innerObject, com.azure.resourcemanager.cloudhealth.CloudHealthManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + this.resourceGroupName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "resourceGroups"); + this.healthModelName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "healthmodels"); + this.entityName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "entities"); + } + + public Entity refresh() { + this.innerObject = serviceManager.serviceClient() + .getEntities() + .getWithResponse(resourceGroupName, healthModelName, entityName, Context.NONE) + .getValue(); + return this; + } + + public Entity refresh(Context context) { + this.innerObject = serviceManager.serviceClient() + .getEntities() + .getWithResponse(resourceGroupName, healthModelName, entityName, context) + .getValue(); + return this; + } + + public EntityImpl withProperties(EntityProperties properties) { + this.innerModel().withProperties(properties); + return this; + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/HealthModelImpl.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/HealthModelImpl.java new file mode 100644 index 000000000000..23c74b35bf03 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/HealthModelImpl.java @@ -0,0 +1,198 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.implementation; + +import com.azure.core.management.Region; +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.azure.resourcemanager.cloudhealth.fluent.models.HealthModelInner; +import com.azure.resourcemanager.cloudhealth.models.HealthModel; +import com.azure.resourcemanager.cloudhealth.models.HealthModelProperties; +import com.azure.resourcemanager.cloudhealth.models.HealthModelUpdate; +import com.azure.resourcemanager.cloudhealth.models.HealthModelUpdateProperties; +import com.azure.resourcemanager.cloudhealth.models.ManagedServiceIdentity; +import java.util.Collections; +import java.util.Map; + +public final class HealthModelImpl implements HealthModel, HealthModel.Definition, HealthModel.Update { + private HealthModelInner innerObject; + + private final com.azure.resourcemanager.cloudhealth.CloudHealthManager serviceManager; + + public String id() { + return this.innerModel().id(); + } + + public String name() { + return this.innerModel().name(); + } + + public String type() { + return this.innerModel().type(); + } + + public String location() { + return this.innerModel().location(); + } + + public Map tags() { + Map inner = this.innerModel().tags(); + if (inner != null) { + return Collections.unmodifiableMap(inner); + } else { + return Collections.emptyMap(); + } + } + + public HealthModelProperties properties() { + return this.innerModel().properties(); + } + + public ManagedServiceIdentity identity() { + return this.innerModel().identity(); + } + + public SystemData systemData() { + return this.innerModel().systemData(); + } + + public Region region() { + return Region.fromName(this.regionName()); + } + + public String regionName() { + return this.location(); + } + + public String resourceGroupName() { + return resourceGroupName; + } + + public HealthModelInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.cloudhealth.CloudHealthManager manager() { + return this.serviceManager; + } + + private String resourceGroupName; + + private String healthModelName; + + private HealthModelUpdate updateProperties; + + public HealthModelImpl withExistingResourceGroup(String resourceGroupName) { + this.resourceGroupName = resourceGroupName; + return this; + } + + public HealthModel create() { + this.innerObject = serviceManager.serviceClient() + .getHealthModels() + .create(resourceGroupName, healthModelName, this.innerModel(), Context.NONE); + return this; + } + + public HealthModel create(Context context) { + this.innerObject = serviceManager.serviceClient() + .getHealthModels() + .create(resourceGroupName, healthModelName, this.innerModel(), context); + return this; + } + + HealthModelImpl(String name, com.azure.resourcemanager.cloudhealth.CloudHealthManager serviceManager) { + this.innerObject = new HealthModelInner(); + this.serviceManager = serviceManager; + this.healthModelName = name; + } + + public HealthModelImpl update() { + this.updateProperties = new HealthModelUpdate(); + return this; + } + + public HealthModel apply() { + this.innerObject = serviceManager.serviceClient() + .getHealthModels() + .update(resourceGroupName, healthModelName, updateProperties, Context.NONE); + return this; + } + + public HealthModel apply(Context context) { + this.innerObject = serviceManager.serviceClient() + .getHealthModels() + .update(resourceGroupName, healthModelName, updateProperties, context); + return this; + } + + HealthModelImpl(HealthModelInner innerObject, + com.azure.resourcemanager.cloudhealth.CloudHealthManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + this.resourceGroupName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "resourceGroups"); + this.healthModelName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "healthmodels"); + } + + public HealthModel refresh() { + this.innerObject = serviceManager.serviceClient() + .getHealthModels() + .getByResourceGroupWithResponse(resourceGroupName, healthModelName, Context.NONE) + .getValue(); + return this; + } + + public HealthModel refresh(Context context) { + this.innerObject = serviceManager.serviceClient() + .getHealthModels() + .getByResourceGroupWithResponse(resourceGroupName, healthModelName, context) + .getValue(); + return this; + } + + public HealthModelImpl withRegion(Region location) { + this.innerModel().withLocation(location.toString()); + return this; + } + + public HealthModelImpl withRegion(String location) { + this.innerModel().withLocation(location); + return this; + } + + public HealthModelImpl withTags(Map tags) { + if (isInCreateMode()) { + this.innerModel().withTags(tags); + return this; + } else { + this.updateProperties.withTags(tags); + return this; + } + } + + public HealthModelImpl withProperties(HealthModelProperties properties) { + this.innerModel().withProperties(properties); + return this; + } + + public HealthModelImpl withIdentity(ManagedServiceIdentity identity) { + if (isInCreateMode()) { + this.innerModel().withIdentity(identity); + return this; + } else { + this.updateProperties.withIdentity(identity); + return this; + } + } + + public HealthModelImpl withProperties(HealthModelUpdateProperties properties) { + this.updateProperties.withProperties(properties); + return this; + } + + private boolean isInCreateMode() { + return this.innerModel().id() == null; + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/HealthModelsClientImpl.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/HealthModelsClientImpl.java new file mode 100644 index 000000000000..a99bd0597fcb --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/HealthModelsClientImpl.java @@ -0,0 +1,1288 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.implementation; + +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.Delete; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Headers; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Patch; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Put; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.management.polling.PollResult; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.SyncPoller; +import com.azure.resourcemanager.cloudhealth.fluent.HealthModelsClient; +import com.azure.resourcemanager.cloudhealth.fluent.models.HealthModelInner; +import com.azure.resourcemanager.cloudhealth.implementation.models.HealthModelListResult; +import com.azure.resourcemanager.cloudhealth.models.HealthModelUpdate; +import java.nio.ByteBuffer; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in HealthModelsClient. + */ +public final class HealthModelsClientImpl implements HealthModelsClient { + /** + * The proxy service used to perform REST calls. + */ + private final HealthModelsService service; + + /** + * The service client containing this operation class. + */ + private final CloudHealthClientImpl client; + + /** + * Initializes an instance of HealthModelsClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + HealthModelsClientImpl(CloudHealthClientImpl client) { + this.service + = RestProxy.create(HealthModelsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for CloudHealthClientHealthModels to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "CloudHealthClientHea") + public interface HealthModelsService { + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CloudHealth/healthmodels/{healthModelName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> getByResourceGroup(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("healthModelName") String healthModelName, @HeaderParam("Accept") String accept, + Context context); + + @Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CloudHealth/healthmodels/{healthModelName}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> create(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("healthModelName") String healthModelName, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") HealthModelInner resource, + Context context); + + @Patch("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CloudHealth/healthmodels/{healthModelName}") + @ExpectedResponses({ 200, 202 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> update(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("healthModelName") String healthModelName, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") HealthModelUpdate properties, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Delete("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CloudHealth/healthmodels/{healthModelName}") + @ExpectedResponses({ 202, 204 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> delete(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("healthModelName") String healthModelName, @HeaderParam("Accept") String accept, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CloudHealth/healthmodels") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByResourceGroup(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @HeaderParam("Accept") String accept, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/providers/Microsoft.CloudHealth/healthmodels") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> list(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByResourceGroupNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listBySubscriptionNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, Context context); + } + + /** + * Get a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a HealthModel along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getByResourceGroupWithResponseAsync(String resourceGroupName, + String healthModelName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (healthModelName == null) { + return Mono + .error(new IllegalArgumentException("Parameter healthModelName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getByResourceGroup(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, healthModelName, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a HealthModel along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getByResourceGroupWithResponseAsync(String resourceGroupName, + String healthModelName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (healthModelName == null) { + return Mono + .error(new IllegalArgumentException("Parameter healthModelName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.getByResourceGroup(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, healthModelName, accept, context); + } + + /** + * Get a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a HealthModel on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getByResourceGroupAsync(String resourceGroupName, String healthModelName) { + return getByResourceGroupWithResponseAsync(resourceGroupName, healthModelName) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Get a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a HealthModel along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getByResourceGroupWithResponse(String resourceGroupName, String healthModelName, + Context context) { + return getByResourceGroupWithResponseAsync(resourceGroupName, healthModelName, context).block(); + } + + /** + * Get a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a HealthModel. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public HealthModelInner getByResourceGroup(String resourceGroupName, String healthModelName) { + return getByResourceGroupWithResponse(resourceGroupName, healthModelName, Context.NONE).getValue(); + } + + /** + * Create a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a HealthModel resource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> createWithResponseAsync(String resourceGroupName, String healthModelName, + HealthModelInner resource) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (healthModelName == null) { + return Mono + .error(new IllegalArgumentException("Parameter healthModelName is required and cannot be null.")); + } + if (resource == null) { + return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null.")); + } else { + resource.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.create(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, healthModelName, contentType, accept, resource, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Create a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a HealthModel resource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> createWithResponseAsync(String resourceGroupName, String healthModelName, + HealthModelInner resource, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (healthModelName == null) { + return Mono + .error(new IllegalArgumentException("Parameter healthModelName is required and cannot be null.")); + } + if (resource == null) { + return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null.")); + } else { + resource.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.create(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, healthModelName, contentType, accept, resource, context); + } + + /** + * Create a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of a HealthModel resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, HealthModelInner> beginCreateAsync(String resourceGroupName, + String healthModelName, HealthModelInner resource) { + Mono>> mono = createWithResponseAsync(resourceGroupName, healthModelName, resource); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), + HealthModelInner.class, HealthModelInner.class, this.client.getContext()); + } + + /** + * Create a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of a HealthModel resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, HealthModelInner> beginCreateAsync(String resourceGroupName, + String healthModelName, HealthModelInner resource, Context context) { + context = this.client.mergeContext(context); + Mono>> mono + = createWithResponseAsync(resourceGroupName, healthModelName, resource, context); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), + HealthModelInner.class, HealthModelInner.class, context); + } + + /** + * Create a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of a HealthModel resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, HealthModelInner> beginCreate(String resourceGroupName, + String healthModelName, HealthModelInner resource) { + return this.beginCreateAsync(resourceGroupName, healthModelName, resource).getSyncPoller(); + } + + /** + * Create a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of a HealthModel resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, HealthModelInner> beginCreate(String resourceGroupName, + String healthModelName, HealthModelInner resource, Context context) { + return this.beginCreateAsync(resourceGroupName, healthModelName, resource, context).getSyncPoller(); + } + + /** + * Create a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a HealthModel resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createAsync(String resourceGroupName, String healthModelName, + HealthModelInner resource) { + return beginCreateAsync(resourceGroupName, healthModelName, resource).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Create a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a HealthModel resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createAsync(String resourceGroupName, String healthModelName, + HealthModelInner resource, Context context) { + return beginCreateAsync(resourceGroupName, healthModelName, resource, context).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Create a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a HealthModel resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public HealthModelInner create(String resourceGroupName, String healthModelName, HealthModelInner resource) { + return createAsync(resourceGroupName, healthModelName, resource).block(); + } + + /** + * Create a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a HealthModel resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public HealthModelInner create(String resourceGroupName, String healthModelName, HealthModelInner resource, + Context context) { + return createAsync(resourceGroupName, healthModelName, resource, context).block(); + } + + /** + * Update a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param properties The resource properties to be updated. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a HealthModel resource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> updateWithResponseAsync(String resourceGroupName, String healthModelName, + HealthModelUpdate properties) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (healthModelName == null) { + return Mono + .error(new IllegalArgumentException("Parameter healthModelName is required and cannot be null.")); + } + if (properties == null) { + return Mono.error(new IllegalArgumentException("Parameter properties is required and cannot be null.")); + } else { + properties.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.update(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, healthModelName, contentType, accept, properties, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Update a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param properties The resource properties to be updated. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a HealthModel resource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> updateWithResponseAsync(String resourceGroupName, String healthModelName, + HealthModelUpdate properties, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (healthModelName == null) { + return Mono + .error(new IllegalArgumentException("Parameter healthModelName is required and cannot be null.")); + } + if (properties == null) { + return Mono.error(new IllegalArgumentException("Parameter properties is required and cannot be null.")); + } else { + properties.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.update(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, healthModelName, contentType, accept, properties, context); + } + + /** + * Update a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param properties The resource properties to be updated. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of a HealthModel resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, HealthModelInner> beginUpdateAsync(String resourceGroupName, + String healthModelName, HealthModelUpdate properties) { + Mono>> mono = updateWithResponseAsync(resourceGroupName, healthModelName, properties); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), + HealthModelInner.class, HealthModelInner.class, this.client.getContext()); + } + + /** + * Update a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param properties The resource properties to be updated. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of a HealthModel resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, HealthModelInner> beginUpdateAsync(String resourceGroupName, + String healthModelName, HealthModelUpdate properties, Context context) { + context = this.client.mergeContext(context); + Mono>> mono + = updateWithResponseAsync(resourceGroupName, healthModelName, properties, context); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), + HealthModelInner.class, HealthModelInner.class, context); + } + + /** + * Update a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param properties The resource properties to be updated. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of a HealthModel resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, HealthModelInner> beginUpdate(String resourceGroupName, + String healthModelName, HealthModelUpdate properties) { + return this.beginUpdateAsync(resourceGroupName, healthModelName, properties).getSyncPoller(); + } + + /** + * Update a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param properties The resource properties to be updated. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of a HealthModel resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, HealthModelInner> beginUpdate(String resourceGroupName, + String healthModelName, HealthModelUpdate properties, Context context) { + return this.beginUpdateAsync(resourceGroupName, healthModelName, properties, context).getSyncPoller(); + } + + /** + * Update a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param properties The resource properties to be updated. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a HealthModel resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono updateAsync(String resourceGroupName, String healthModelName, + HealthModelUpdate properties) { + return beginUpdateAsync(resourceGroupName, healthModelName, properties).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Update a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param properties The resource properties to be updated. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a HealthModel resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono updateAsync(String resourceGroupName, String healthModelName, + HealthModelUpdate properties, Context context) { + return beginUpdateAsync(resourceGroupName, healthModelName, properties, context).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Update a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param properties The resource properties to be updated. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a HealthModel resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public HealthModelInner update(String resourceGroupName, String healthModelName, HealthModelUpdate properties) { + return updateAsync(resourceGroupName, healthModelName, properties).block(); + } + + /** + * Update a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param properties The resource properties to be updated. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a HealthModel resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public HealthModelInner update(String resourceGroupName, String healthModelName, HealthModelUpdate properties, + Context context) { + return updateAsync(resourceGroupName, healthModelName, properties, context).block(); + } + + /** + * Delete a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> deleteWithResponseAsync(String resourceGroupName, String healthModelName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (healthModelName == null) { + return Mono + .error(new IllegalArgumentException("Parameter healthModelName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.delete(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, healthModelName, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Delete a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> deleteWithResponseAsync(String resourceGroupName, String healthModelName, + Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (healthModelName == null) { + return Mono + .error(new IllegalArgumentException("Parameter healthModelName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.delete(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, healthModelName, accept, context); + } + + /** + * Delete a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, Void> beginDeleteAsync(String resourceGroupName, String healthModelName) { + Mono>> mono = deleteWithResponseAsync(resourceGroupName, healthModelName); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, + this.client.getContext()); + } + + /** + * Delete a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, Void> beginDeleteAsync(String resourceGroupName, String healthModelName, + Context context) { + context = this.client.mergeContext(context); + Mono>> mono = deleteWithResponseAsync(resourceGroupName, healthModelName, context); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, + context); + } + + /** + * Delete a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, Void> beginDelete(String resourceGroupName, String healthModelName) { + return this.beginDeleteAsync(resourceGroupName, healthModelName).getSyncPoller(); + } + + /** + * Delete a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, Void> beginDelete(String resourceGroupName, String healthModelName, + Context context) { + return this.beginDeleteAsync(resourceGroupName, healthModelName, context).getSyncPoller(); + } + + /** + * Delete a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono deleteAsync(String resourceGroupName, String healthModelName) { + return beginDeleteAsync(resourceGroupName, healthModelName).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Delete a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono deleteAsync(String resourceGroupName, String healthModelName, Context context) { + return beginDeleteAsync(resourceGroupName, healthModelName, context).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Delete a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void delete(String resourceGroupName, String healthModelName) { + deleteAsync(resourceGroupName, healthModelName).block(); + } + + /** + * Delete a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void delete(String resourceGroupName, String healthModelName, Context context) { + deleteAsync(resourceGroupName, healthModelName, context).block(); + } + + /** + * List HealthModel resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a HealthModel list operation along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByResourceGroupSinglePageAsync(String resourceGroupName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listByResourceGroup(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), + res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * List HealthModel resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a HealthModel list operation along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByResourceGroupSinglePageAsync(String resourceGroupName, + Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .listByResourceGroup(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } + + /** + * List HealthModel resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a HealthModel list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByResourceGroupAsync(String resourceGroupName) { + return new PagedFlux<>(() -> listByResourceGroupSinglePageAsync(resourceGroupName), + nextLink -> listByResourceGroupNextSinglePageAsync(nextLink)); + } + + /** + * List HealthModel resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a HealthModel list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByResourceGroupAsync(String resourceGroupName, Context context) { + return new PagedFlux<>(() -> listByResourceGroupSinglePageAsync(resourceGroupName, context), + nextLink -> listByResourceGroupNextSinglePageAsync(nextLink, context)); + } + + /** + * List HealthModel resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a HealthModel list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByResourceGroup(String resourceGroupName) { + return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName)); + } + + /** + * List HealthModel resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a HealthModel list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByResourceGroup(String resourceGroupName, Context context) { + return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName, context)); + } + + /** + * List HealthModel resources by subscription ID. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a HealthModel list operation along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync() { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.list(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), + res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * List HealthModel resources by subscription ID. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a HealthModel list operation along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync(Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .list(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), accept, + context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } + + /** + * List HealthModel resources by subscription ID. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a HealthModel list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync() { + return new PagedFlux<>(() -> listSinglePageAsync(), + nextLink -> listBySubscriptionNextSinglePageAsync(nextLink)); + } + + /** + * List HealthModel resources by subscription ID. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a HealthModel list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(Context context) { + return new PagedFlux<>(() -> listSinglePageAsync(context), + nextLink -> listBySubscriptionNextSinglePageAsync(nextLink, context)); + } + + /** + * List HealthModel resources by subscription ID. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a HealthModel list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list() { + return new PagedIterable<>(listAsync()); + } + + /** + * List HealthModel resources by subscription ID. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a HealthModel list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(Context context) { + return new PagedIterable<>(listAsync(context)); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a HealthModel list operation along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByResourceGroupNextSinglePageAsync(String nextLink) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.listByResourceGroupNext(nextLink, this.client.getEndpoint(), accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), + res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a HealthModel list operation along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByResourceGroupNextSinglePageAsync(String nextLink, + Context context) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.listByResourceGroupNext(nextLink, this.client.getEndpoint(), accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a HealthModel list operation along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listBySubscriptionNextSinglePageAsync(String nextLink) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.listBySubscriptionNext(nextLink, this.client.getEndpoint(), accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), + res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a HealthModel list operation along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listBySubscriptionNextSinglePageAsync(String nextLink, + Context context) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.listBySubscriptionNext(nextLink, this.client.getEndpoint(), accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/HealthModelsImpl.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/HealthModelsImpl.java new file mode 100644 index 000000000000..ebdbb3507d67 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/HealthModelsImpl.java @@ -0,0 +1,146 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.implementation; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.cloudhealth.fluent.HealthModelsClient; +import com.azure.resourcemanager.cloudhealth.fluent.models.HealthModelInner; +import com.azure.resourcemanager.cloudhealth.models.HealthModel; +import com.azure.resourcemanager.cloudhealth.models.HealthModels; + +public final class HealthModelsImpl implements HealthModels { + private static final ClientLogger LOGGER = new ClientLogger(HealthModelsImpl.class); + + private final HealthModelsClient innerClient; + + private final com.azure.resourcemanager.cloudhealth.CloudHealthManager serviceManager; + + public HealthModelsImpl(HealthModelsClient innerClient, + com.azure.resourcemanager.cloudhealth.CloudHealthManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public Response getByResourceGroupWithResponse(String resourceGroupName, String healthModelName, + Context context) { + Response inner + = this.serviceClient().getByResourceGroupWithResponse(resourceGroupName, healthModelName, context); + if (inner != null) { + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new HealthModelImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public HealthModel getByResourceGroup(String resourceGroupName, String healthModelName) { + HealthModelInner inner = this.serviceClient().getByResourceGroup(resourceGroupName, healthModelName); + if (inner != null) { + return new HealthModelImpl(inner, this.manager()); + } else { + return null; + } + } + + public void deleteByResourceGroup(String resourceGroupName, String healthModelName) { + this.serviceClient().delete(resourceGroupName, healthModelName); + } + + public void delete(String resourceGroupName, String healthModelName, Context context) { + this.serviceClient().delete(resourceGroupName, healthModelName, context); + } + + public PagedIterable listByResourceGroup(String resourceGroupName) { + PagedIterable inner = this.serviceClient().listByResourceGroup(resourceGroupName); + return ResourceManagerUtils.mapPage(inner, inner1 -> new HealthModelImpl(inner1, this.manager())); + } + + public PagedIterable listByResourceGroup(String resourceGroupName, Context context) { + PagedIterable inner = this.serviceClient().listByResourceGroup(resourceGroupName, context); + return ResourceManagerUtils.mapPage(inner, inner1 -> new HealthModelImpl(inner1, this.manager())); + } + + public PagedIterable list() { + PagedIterable inner = this.serviceClient().list(); + return ResourceManagerUtils.mapPage(inner, inner1 -> new HealthModelImpl(inner1, this.manager())); + } + + public PagedIterable list(Context context) { + PagedIterable inner = this.serviceClient().list(context); + return ResourceManagerUtils.mapPage(inner, inner1 -> new HealthModelImpl(inner1, this.manager())); + } + + public HealthModel getById(String id) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String healthModelName = ResourceManagerUtils.getValueFromIdByName(id, "healthmodels"); + if (healthModelName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'healthmodels'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, healthModelName, Context.NONE).getValue(); + } + + public Response getByIdWithResponse(String id, Context context) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String healthModelName = ResourceManagerUtils.getValueFromIdByName(id, "healthmodels"); + if (healthModelName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'healthmodels'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, healthModelName, context); + } + + public void deleteById(String id) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String healthModelName = ResourceManagerUtils.getValueFromIdByName(id, "healthmodels"); + if (healthModelName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'healthmodels'.", id))); + } + this.delete(resourceGroupName, healthModelName, Context.NONE); + } + + public void deleteByIdWithResponse(String id, Context context) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String healthModelName = ResourceManagerUtils.getValueFromIdByName(id, "healthmodels"); + if (healthModelName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'healthmodels'.", id))); + } + this.delete(resourceGroupName, healthModelName, context); + } + + private HealthModelsClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.cloudhealth.CloudHealthManager manager() { + return this.serviceManager; + } + + public HealthModelImpl define(String name) { + return new HealthModelImpl(name, this.manager()); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/OperationImpl.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/OperationImpl.java new file mode 100644 index 000000000000..328b9a46c92c --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/OperationImpl.java @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.implementation; + +import com.azure.resourcemanager.cloudhealth.fluent.models.OperationInner; +import com.azure.resourcemanager.cloudhealth.models.ActionType; +import com.azure.resourcemanager.cloudhealth.models.Operation; +import com.azure.resourcemanager.cloudhealth.models.OperationDisplay; +import com.azure.resourcemanager.cloudhealth.models.Origin; + +public final class OperationImpl implements Operation { + private OperationInner innerObject; + + private final com.azure.resourcemanager.cloudhealth.CloudHealthManager serviceManager; + + OperationImpl(OperationInner innerObject, com.azure.resourcemanager.cloudhealth.CloudHealthManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + } + + public String name() { + return this.innerModel().name(); + } + + public Boolean isDataAction() { + return this.innerModel().isDataAction(); + } + + public OperationDisplay display() { + return this.innerModel().display(); + } + + public Origin origin() { + return this.innerModel().origin(); + } + + public ActionType actionType() { + return this.innerModel().actionType(); + } + + public OperationInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.cloudhealth.CloudHealthManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/OperationsClientImpl.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/OperationsClientImpl.java new file mode 100644 index 000000000000..de509492225c --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/OperationsClientImpl.java @@ -0,0 +1,235 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.implementation; + +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Headers; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.resourcemanager.cloudhealth.fluent.OperationsClient; +import com.azure.resourcemanager.cloudhealth.fluent.models.OperationInner; +import com.azure.resourcemanager.cloudhealth.implementation.models.OperationListResult; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in OperationsClient. + */ +public final class OperationsClientImpl implements OperationsClient { + /** + * The proxy service used to perform REST calls. + */ + private final OperationsService service; + + /** + * The service client containing this operation class. + */ + private final CloudHealthClientImpl client; + + /** + * Initializes an instance of OperationsClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + OperationsClientImpl(CloudHealthClientImpl client) { + this.service + = RestProxy.create(OperationsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for CloudHealthClientOperations to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "CloudHealthClientOpe") + public interface OperationsService { + @Headers({ "Content-Type: application/json" }) + @Get("/providers/Microsoft.CloudHealth/operations") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> list(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listNext(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, Context context); + } + + /** + * List the operations for the provider. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider along with {@link PagedResponse} on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync() { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.list(this.client.getEndpoint(), this.client.getApiVersion(), accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), + res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * List the operations for the provider. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider along with {@link PagedResponse} on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync(Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.list(this.client.getEndpoint(), this.client.getApiVersion(), accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } + + /** + * List the operations for the provider. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync() { + return new PagedFlux<>(() -> listSinglePageAsync(), nextLink -> listNextSinglePageAsync(nextLink)); + } + + /** + * List the operations for the provider. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(Context context) { + return new PagedFlux<>(() -> listSinglePageAsync(context), + nextLink -> listNextSinglePageAsync(nextLink, context)); + } + + /** + * List the operations for the provider. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list() { + return new PagedIterable<>(listAsync()); + } + + /** + * List the operations for the provider. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(Context context) { + return new PagedIterable<>(listAsync(context)); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider along with {@link PagedResponse} on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listNextSinglePageAsync(String nextLink) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.listNext(nextLink, this.client.getEndpoint(), accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), + res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider along with {@link PagedResponse} on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listNextSinglePageAsync(String nextLink, Context context) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.listNext(nextLink, this.client.getEndpoint(), accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/OperationsImpl.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/OperationsImpl.java new file mode 100644 index 000000000000..96353690b9f1 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/OperationsImpl.java @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.implementation; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.cloudhealth.fluent.OperationsClient; +import com.azure.resourcemanager.cloudhealth.fluent.models.OperationInner; +import com.azure.resourcemanager.cloudhealth.models.Operation; +import com.azure.resourcemanager.cloudhealth.models.Operations; + +public final class OperationsImpl implements Operations { + private static final ClientLogger LOGGER = new ClientLogger(OperationsImpl.class); + + private final OperationsClient innerClient; + + private final com.azure.resourcemanager.cloudhealth.CloudHealthManager serviceManager; + + public OperationsImpl(OperationsClient innerClient, + com.azure.resourcemanager.cloudhealth.CloudHealthManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public PagedIterable list() { + PagedIterable inner = this.serviceClient().list(); + return ResourceManagerUtils.mapPage(inner, inner1 -> new OperationImpl(inner1, this.manager())); + } + + public PagedIterable list(Context context) { + PagedIterable inner = this.serviceClient().list(context); + return ResourceManagerUtils.mapPage(inner, inner1 -> new OperationImpl(inner1, this.manager())); + } + + private OperationsClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.cloudhealth.CloudHealthManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/RelationshipImpl.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/RelationshipImpl.java new file mode 100644 index 000000000000..bc8fb4d1a8eb --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/RelationshipImpl.java @@ -0,0 +1,137 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.implementation; + +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.azure.resourcemanager.cloudhealth.fluent.models.RelationshipInner; +import com.azure.resourcemanager.cloudhealth.models.Relationship; +import com.azure.resourcemanager.cloudhealth.models.RelationshipProperties; + +public final class RelationshipImpl implements Relationship, Relationship.Definition, Relationship.Update { + private RelationshipInner innerObject; + + private final com.azure.resourcemanager.cloudhealth.CloudHealthManager serviceManager; + + public String id() { + return this.innerModel().id(); + } + + public String name() { + return this.innerModel().name(); + } + + public String type() { + return this.innerModel().type(); + } + + public RelationshipProperties properties() { + return this.innerModel().properties(); + } + + public SystemData systemData() { + return this.innerModel().systemData(); + } + + public String resourceGroupName() { + return resourceGroupName; + } + + public RelationshipInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.cloudhealth.CloudHealthManager manager() { + return this.serviceManager; + } + + private String resourceGroupName; + + private String healthModelName; + + private String relationshipName; + + public RelationshipImpl withExistingHealthmodel(String resourceGroupName, String healthModelName) { + this.resourceGroupName = resourceGroupName; + this.healthModelName = healthModelName; + return this; + } + + public Relationship create() { + this.innerObject = serviceManager.serviceClient() + .getRelationships() + .createOrUpdateWithResponse(resourceGroupName, healthModelName, relationshipName, this.innerModel(), + Context.NONE) + .getValue(); + return this; + } + + public Relationship create(Context context) { + this.innerObject = serviceManager.serviceClient() + .getRelationships() + .createOrUpdateWithResponse(resourceGroupName, healthModelName, relationshipName, this.innerModel(), + context) + .getValue(); + return this; + } + + RelationshipImpl(String name, com.azure.resourcemanager.cloudhealth.CloudHealthManager serviceManager) { + this.innerObject = new RelationshipInner(); + this.serviceManager = serviceManager; + this.relationshipName = name; + } + + public RelationshipImpl update() { + return this; + } + + public Relationship apply() { + this.innerObject = serviceManager.serviceClient() + .getRelationships() + .createOrUpdateWithResponse(resourceGroupName, healthModelName, relationshipName, this.innerModel(), + Context.NONE) + .getValue(); + return this; + } + + public Relationship apply(Context context) { + this.innerObject = serviceManager.serviceClient() + .getRelationships() + .createOrUpdateWithResponse(resourceGroupName, healthModelName, relationshipName, this.innerModel(), + context) + .getValue(); + return this; + } + + RelationshipImpl(RelationshipInner innerObject, + com.azure.resourcemanager.cloudhealth.CloudHealthManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + this.resourceGroupName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "resourceGroups"); + this.healthModelName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "healthmodels"); + this.relationshipName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "relationships"); + } + + public Relationship refresh() { + this.innerObject = serviceManager.serviceClient() + .getRelationships() + .getWithResponse(resourceGroupName, healthModelName, relationshipName, Context.NONE) + .getValue(); + return this; + } + + public Relationship refresh(Context context) { + this.innerObject = serviceManager.serviceClient() + .getRelationships() + .getWithResponse(resourceGroupName, healthModelName, relationshipName, context) + .getValue(); + return this; + } + + public RelationshipImpl withProperties(RelationshipProperties properties) { + this.innerModel().withProperties(properties); + return this; + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/RelationshipsClientImpl.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/RelationshipsClientImpl.java new file mode 100644 index 000000000000..7342371b8e90 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/RelationshipsClientImpl.java @@ -0,0 +1,790 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.implementation; + +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.Delete; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Headers; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Put; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.resourcemanager.cloudhealth.fluent.RelationshipsClient; +import com.azure.resourcemanager.cloudhealth.fluent.models.RelationshipInner; +import com.azure.resourcemanager.cloudhealth.implementation.models.RelationshipListResult; +import java.time.OffsetDateTime; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in RelationshipsClient. + */ +public final class RelationshipsClientImpl implements RelationshipsClient { + /** + * The proxy service used to perform REST calls. + */ + private final RelationshipsService service; + + /** + * The service client containing this operation class. + */ + private final CloudHealthClientImpl client; + + /** + * Initializes an instance of RelationshipsClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + RelationshipsClientImpl(CloudHealthClientImpl client) { + this.service + = RestProxy.create(RelationshipsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for CloudHealthClientRelationships to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "CloudHealthClientRel") + public interface RelationshipsService { + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CloudHealth/healthmodels/{healthModelName}/relationships/{relationshipName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> get(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("healthModelName") String healthModelName, + @PathParam("relationshipName") String relationshipName, @HeaderParam("Accept") String accept, + Context context); + + @Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CloudHealth/healthmodels/{healthModelName}/relationships/{relationshipName}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> createOrUpdate(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("healthModelName") String healthModelName, + @PathParam("relationshipName") String relationshipName, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") RelationshipInner resource, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Delete("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CloudHealth/healthmodels/{healthModelName}/relationships/{relationshipName}") + @ExpectedResponses({ 200, 204 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> delete(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("healthModelName") String healthModelName, + @PathParam("relationshipName") String relationshipName, @HeaderParam("Accept") String accept, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CloudHealth/healthmodels/{healthModelName}/relationships") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByHealthModel(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @QueryParam("timestamp") OffsetDateTime timestamp, + @PathParam("healthModelName") String healthModelName, @HeaderParam("Accept") String accept, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByHealthModelNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, Context context); + } + + /** + * Get a Relationship. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param relationshipName Name of the relationship. Must be unique within a health model. For example, a + * concatenation of parentEntityName and childEntityName can be used as the name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Relationship along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getWithResponseAsync(String resourceGroupName, String healthModelName, + String relationshipName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (healthModelName == null) { + return Mono + .error(new IllegalArgumentException("Parameter healthModelName is required and cannot be null.")); + } + if (relationshipName == null) { + return Mono + .error(new IllegalArgumentException("Parameter relationshipName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.get(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, healthModelName, relationshipName, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get a Relationship. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param relationshipName Name of the relationship. Must be unique within a health model. For example, a + * concatenation of parentEntityName and childEntityName can be used as the name. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Relationship along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getWithResponseAsync(String resourceGroupName, String healthModelName, + String relationshipName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (healthModelName == null) { + return Mono + .error(new IllegalArgumentException("Parameter healthModelName is required and cannot be null.")); + } + if (relationshipName == null) { + return Mono + .error(new IllegalArgumentException("Parameter relationshipName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.get(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, healthModelName, relationshipName, accept, context); + } + + /** + * Get a Relationship. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param relationshipName Name of the relationship. Must be unique within a health model. For example, a + * concatenation of parentEntityName and childEntityName can be used as the name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Relationship on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getAsync(String resourceGroupName, String healthModelName, + String relationshipName) { + return getWithResponseAsync(resourceGroupName, healthModelName, relationshipName) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Get a Relationship. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param relationshipName Name of the relationship. Must be unique within a health model. For example, a + * concatenation of parentEntityName and childEntityName can be used as the name. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Relationship along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(String resourceGroupName, String healthModelName, + String relationshipName, Context context) { + return getWithResponseAsync(resourceGroupName, healthModelName, relationshipName, context).block(); + } + + /** + * Get a Relationship. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param relationshipName Name of the relationship. Must be unique within a health model. For example, a + * concatenation of parentEntityName and childEntityName can be used as the name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Relationship. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public RelationshipInner get(String resourceGroupName, String healthModelName, String relationshipName) { + return getWithResponse(resourceGroupName, healthModelName, relationshipName, Context.NONE).getValue(); + } + + /** + * Create a Relationship. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param relationshipName Name of the relationship. Must be unique within a health model. For example, a + * concatenation of parentEntityName and childEntityName can be used as the name. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a relationship (aka edge) between two entities in a health model along with {@link Response} on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createOrUpdateWithResponseAsync(String resourceGroupName, + String healthModelName, String relationshipName, RelationshipInner resource) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (healthModelName == null) { + return Mono + .error(new IllegalArgumentException("Parameter healthModelName is required and cannot be null.")); + } + if (relationshipName == null) { + return Mono + .error(new IllegalArgumentException("Parameter relationshipName is required and cannot be null.")); + } + if (resource == null) { + return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null.")); + } else { + resource.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.createOrUpdate(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, healthModelName, relationshipName, contentType, + accept, resource, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Create a Relationship. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param relationshipName Name of the relationship. Must be unique within a health model. For example, a + * concatenation of parentEntityName and childEntityName can be used as the name. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a relationship (aka edge) between two entities in a health model along with {@link Response} on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createOrUpdateWithResponseAsync(String resourceGroupName, + String healthModelName, String relationshipName, RelationshipInner resource, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (healthModelName == null) { + return Mono + .error(new IllegalArgumentException("Parameter healthModelName is required and cannot be null.")); + } + if (relationshipName == null) { + return Mono + .error(new IllegalArgumentException("Parameter relationshipName is required and cannot be null.")); + } + if (resource == null) { + return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null.")); + } else { + resource.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.createOrUpdate(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, healthModelName, relationshipName, contentType, accept, + resource, context); + } + + /** + * Create a Relationship. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param relationshipName Name of the relationship. Must be unique within a health model. For example, a + * concatenation of parentEntityName and childEntityName can be used as the name. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a relationship (aka edge) between two entities in a health model on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrUpdateAsync(String resourceGroupName, String healthModelName, + String relationshipName, RelationshipInner resource) { + return createOrUpdateWithResponseAsync(resourceGroupName, healthModelName, relationshipName, resource) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Create a Relationship. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param relationshipName Name of the relationship. Must be unique within a health model. For example, a + * concatenation of parentEntityName and childEntityName can be used as the name. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a relationship (aka edge) between two entities in a health model along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createOrUpdateWithResponse(String resourceGroupName, String healthModelName, + String relationshipName, RelationshipInner resource, Context context) { + return createOrUpdateWithResponseAsync(resourceGroupName, healthModelName, relationshipName, resource, context) + .block(); + } + + /** + * Create a Relationship. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param relationshipName Name of the relationship. Must be unique within a health model. For example, a + * concatenation of parentEntityName and childEntityName can be used as the name. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a relationship (aka edge) between two entities in a health model. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public RelationshipInner createOrUpdate(String resourceGroupName, String healthModelName, String relationshipName, + RelationshipInner resource) { + return createOrUpdateWithResponse(resourceGroupName, healthModelName, relationshipName, resource, Context.NONE) + .getValue(); + } + + /** + * Delete a Relationship. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param relationshipName Name of the relationship. Must be unique within a health model. For example, a + * concatenation of parentEntityName and childEntityName can be used as the name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> deleteWithResponseAsync(String resourceGroupName, String healthModelName, + String relationshipName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (healthModelName == null) { + return Mono + .error(new IllegalArgumentException("Parameter healthModelName is required and cannot be null.")); + } + if (relationshipName == null) { + return Mono + .error(new IllegalArgumentException("Parameter relationshipName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.delete(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, healthModelName, relationshipName, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Delete a Relationship. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param relationshipName Name of the relationship. Must be unique within a health model. For example, a + * concatenation of parentEntityName and childEntityName can be used as the name. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> deleteWithResponseAsync(String resourceGroupName, String healthModelName, + String relationshipName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (healthModelName == null) { + return Mono + .error(new IllegalArgumentException("Parameter healthModelName is required and cannot be null.")); + } + if (relationshipName == null) { + return Mono + .error(new IllegalArgumentException("Parameter relationshipName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.delete(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, healthModelName, relationshipName, accept, context); + } + + /** + * Delete a Relationship. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param relationshipName Name of the relationship. Must be unique within a health model. For example, a + * concatenation of parentEntityName and childEntityName can be used as the name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono deleteAsync(String resourceGroupName, String healthModelName, String relationshipName) { + return deleteWithResponseAsync(resourceGroupName, healthModelName, relationshipName) + .flatMap(ignored -> Mono.empty()); + } + + /** + * Delete a Relationship. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param relationshipName Name of the relationship. Must be unique within a health model. For example, a + * concatenation of parentEntityName and childEntityName can be used as the name. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteWithResponse(String resourceGroupName, String healthModelName, String relationshipName, + Context context) { + return deleteWithResponseAsync(resourceGroupName, healthModelName, relationshipName, context).block(); + } + + /** + * Delete a Relationship. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param relationshipName Name of the relationship. Must be unique within a health model. For example, a + * concatenation of parentEntityName and childEntityName can be used as the name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void delete(String resourceGroupName, String healthModelName, String relationshipName) { + deleteWithResponse(resourceGroupName, healthModelName, relationshipName, Context.NONE); + } + + /** + * List Relationship resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param timestamp Timestamp to use for the operation. When specified, the version of the resource at this point in + * time is retrieved. If not specified, the latest version is used. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Relationship list operation along with {@link PagedResponse} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByHealthModelSinglePageAsync(String resourceGroupName, + String healthModelName, OffsetDateTime timestamp) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (healthModelName == null) { + return Mono + .error(new IllegalArgumentException("Parameter healthModelName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listByHealthModel(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, timestamp, healthModelName, accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), + res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * List Relationship resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param timestamp Timestamp to use for the operation. When specified, the version of the resource at this point in + * time is retrieved. If not specified, the latest version is used. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Relationship list operation along with {@link PagedResponse} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByHealthModelSinglePageAsync(String resourceGroupName, + String healthModelName, OffsetDateTime timestamp, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (healthModelName == null) { + return Mono + .error(new IllegalArgumentException("Parameter healthModelName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .listByHealthModel(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, timestamp, healthModelName, accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } + + /** + * List Relationship resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param timestamp Timestamp to use for the operation. When specified, the version of the resource at this point in + * time is retrieved. If not specified, the latest version is used. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Relationship list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByHealthModelAsync(String resourceGroupName, String healthModelName, + OffsetDateTime timestamp) { + return new PagedFlux<>(() -> listByHealthModelSinglePageAsync(resourceGroupName, healthModelName, timestamp), + nextLink -> listByHealthModelNextSinglePageAsync(nextLink)); + } + + /** + * List Relationship resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Relationship list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByHealthModelAsync(String resourceGroupName, String healthModelName) { + final OffsetDateTime timestamp = null; + return new PagedFlux<>(() -> listByHealthModelSinglePageAsync(resourceGroupName, healthModelName, timestamp), + nextLink -> listByHealthModelNextSinglePageAsync(nextLink)); + } + + /** + * List Relationship resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param timestamp Timestamp to use for the operation. When specified, the version of the resource at this point in + * time is retrieved. If not specified, the latest version is used. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Relationship list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByHealthModelAsync(String resourceGroupName, String healthModelName, + OffsetDateTime timestamp, Context context) { + return new PagedFlux<>( + () -> listByHealthModelSinglePageAsync(resourceGroupName, healthModelName, timestamp, context), + nextLink -> listByHealthModelNextSinglePageAsync(nextLink, context)); + } + + /** + * List Relationship resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Relationship list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByHealthModel(String resourceGroupName, String healthModelName) { + final OffsetDateTime timestamp = null; + return new PagedIterable<>(listByHealthModelAsync(resourceGroupName, healthModelName, timestamp)); + } + + /** + * List Relationship resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param timestamp Timestamp to use for the operation. When specified, the version of the resource at this point in + * time is retrieved. If not specified, the latest version is used. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Relationship list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByHealthModel(String resourceGroupName, String healthModelName, + OffsetDateTime timestamp, Context context) { + return new PagedIterable<>(listByHealthModelAsync(resourceGroupName, healthModelName, timestamp, context)); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Relationship list operation along with {@link PagedResponse} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByHealthModelNextSinglePageAsync(String nextLink) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listByHealthModelNext(nextLink, this.client.getEndpoint(), accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), + res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Relationship list operation along with {@link PagedResponse} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByHealthModelNextSinglePageAsync(String nextLink, + Context context) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.listByHealthModelNext(nextLink, this.client.getEndpoint(), accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/RelationshipsImpl.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/RelationshipsImpl.java new file mode 100644 index 000000000000..559b5ddfd41c --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/RelationshipsImpl.java @@ -0,0 +1,161 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.implementation; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.cloudhealth.fluent.RelationshipsClient; +import com.azure.resourcemanager.cloudhealth.fluent.models.RelationshipInner; +import com.azure.resourcemanager.cloudhealth.models.Relationship; +import com.azure.resourcemanager.cloudhealth.models.Relationships; +import java.time.OffsetDateTime; + +public final class RelationshipsImpl implements Relationships { + private static final ClientLogger LOGGER = new ClientLogger(RelationshipsImpl.class); + + private final RelationshipsClient innerClient; + + private final com.azure.resourcemanager.cloudhealth.CloudHealthManager serviceManager; + + public RelationshipsImpl(RelationshipsClient innerClient, + com.azure.resourcemanager.cloudhealth.CloudHealthManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public Response getWithResponse(String resourceGroupName, String healthModelName, + String relationshipName, Context context) { + Response inner + = this.serviceClient().getWithResponse(resourceGroupName, healthModelName, relationshipName, context); + if (inner != null) { + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new RelationshipImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public Relationship get(String resourceGroupName, String healthModelName, String relationshipName) { + RelationshipInner inner = this.serviceClient().get(resourceGroupName, healthModelName, relationshipName); + if (inner != null) { + return new RelationshipImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response deleteWithResponse(String resourceGroupName, String healthModelName, String relationshipName, + Context context) { + return this.serviceClient().deleteWithResponse(resourceGroupName, healthModelName, relationshipName, context); + } + + public void delete(String resourceGroupName, String healthModelName, String relationshipName) { + this.serviceClient().delete(resourceGroupName, healthModelName, relationshipName); + } + + public PagedIterable listByHealthModel(String resourceGroupName, String healthModelName) { + PagedIterable inner + = this.serviceClient().listByHealthModel(resourceGroupName, healthModelName); + return ResourceManagerUtils.mapPage(inner, inner1 -> new RelationshipImpl(inner1, this.manager())); + } + + public PagedIterable listByHealthModel(String resourceGroupName, String healthModelName, + OffsetDateTime timestamp, Context context) { + PagedIterable inner + = this.serviceClient().listByHealthModel(resourceGroupName, healthModelName, timestamp, context); + return ResourceManagerUtils.mapPage(inner, inner1 -> new RelationshipImpl(inner1, this.manager())); + } + + public Relationship getById(String id) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String healthModelName = ResourceManagerUtils.getValueFromIdByName(id, "healthmodels"); + if (healthModelName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'healthmodels'.", id))); + } + String relationshipName = ResourceManagerUtils.getValueFromIdByName(id, "relationships"); + if (relationshipName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'relationships'.", id))); + } + return this.getWithResponse(resourceGroupName, healthModelName, relationshipName, Context.NONE).getValue(); + } + + public Response getByIdWithResponse(String id, Context context) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String healthModelName = ResourceManagerUtils.getValueFromIdByName(id, "healthmodels"); + if (healthModelName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'healthmodels'.", id))); + } + String relationshipName = ResourceManagerUtils.getValueFromIdByName(id, "relationships"); + if (relationshipName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'relationships'.", id))); + } + return this.getWithResponse(resourceGroupName, healthModelName, relationshipName, context); + } + + public void deleteById(String id) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String healthModelName = ResourceManagerUtils.getValueFromIdByName(id, "healthmodels"); + if (healthModelName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'healthmodels'.", id))); + } + String relationshipName = ResourceManagerUtils.getValueFromIdByName(id, "relationships"); + if (relationshipName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'relationships'.", id))); + } + this.deleteWithResponse(resourceGroupName, healthModelName, relationshipName, Context.NONE); + } + + public Response deleteByIdWithResponse(String id, Context context) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String healthModelName = ResourceManagerUtils.getValueFromIdByName(id, "healthmodels"); + if (healthModelName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'healthmodels'.", id))); + } + String relationshipName = ResourceManagerUtils.getValueFromIdByName(id, "relationships"); + if (relationshipName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'relationships'.", id))); + } + return this.deleteWithResponse(resourceGroupName, healthModelName, relationshipName, context); + } + + private RelationshipsClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.cloudhealth.CloudHealthManager manager() { + return this.serviceManager; + } + + public RelationshipImpl define(String name) { + return new RelationshipImpl(name, this.manager()); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/ResourceManagerUtils.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/ResourceManagerUtils.java new file mode 100644 index 000000000000..0eb4342d997a --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/ResourceManagerUtils.java @@ -0,0 +1,195 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.implementation; + +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.util.CoreUtils; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.function.Function; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import reactor.core.publisher.Flux; + +final class ResourceManagerUtils { + private ResourceManagerUtils() { + } + + static String getValueFromIdByName(String id, String name) { + if (id == null) { + return null; + } + Iterator itr = Arrays.stream(id.split("/")).iterator(); + while (itr.hasNext()) { + String part = itr.next(); + if (part != null && !part.trim().isEmpty()) { + if (part.equalsIgnoreCase(name)) { + if (itr.hasNext()) { + return itr.next(); + } else { + return null; + } + } + } + } + return null; + } + + static String getValueFromIdByParameterName(String id, String pathTemplate, String parameterName) { + if (id == null || pathTemplate == null) { + return null; + } + String parameterNameParentheses = "{" + parameterName + "}"; + List idSegmentsReverted = Arrays.asList(id.split("/")); + List pathSegments = Arrays.asList(pathTemplate.split("/")); + Collections.reverse(idSegmentsReverted); + Iterator idItrReverted = idSegmentsReverted.iterator(); + int pathIndex = pathSegments.size(); + while (idItrReverted.hasNext() && pathIndex > 0) { + String idSegment = idItrReverted.next(); + String pathSegment = pathSegments.get(--pathIndex); + if (!CoreUtils.isNullOrEmpty(idSegment) && !CoreUtils.isNullOrEmpty(pathSegment)) { + if (pathSegment.equalsIgnoreCase(parameterNameParentheses)) { + if (pathIndex == 0 || (pathIndex == 1 && pathSegments.get(0).isEmpty())) { + List segments = new ArrayList<>(); + segments.add(idSegment); + idItrReverted.forEachRemaining(segments::add); + Collections.reverse(segments); + if (!segments.isEmpty() && segments.get(0).isEmpty()) { + segments.remove(0); + } + return String.join("/", segments); + } else { + return idSegment; + } + } + } + } + return null; + } + + static PagedIterable mapPage(PagedIterable pageIterable, Function mapper) { + return new PagedIterableImpl<>(pageIterable, mapper); + } + + private static final class PagedIterableImpl extends PagedIterable { + + private final PagedIterable pagedIterable; + private final Function mapper; + private final Function, PagedResponse> pageMapper; + + private PagedIterableImpl(PagedIterable pagedIterable, Function mapper) { + super(PagedFlux.create(() -> (continuationToken, pageSize) -> Flux + .fromStream(pagedIterable.streamByPage().map(getPageMapper(mapper))))); + this.pagedIterable = pagedIterable; + this.mapper = mapper; + this.pageMapper = getPageMapper(mapper); + } + + private static Function, PagedResponse> getPageMapper(Function mapper) { + return page -> new PagedResponseBase(page.getRequest(), page.getStatusCode(), page.getHeaders(), + page.getElements().stream().map(mapper).collect(Collectors.toList()), page.getContinuationToken(), + null); + } + + @Override + public Stream stream() { + return pagedIterable.stream().map(mapper); + } + + @Override + public Stream> streamByPage() { + return pagedIterable.streamByPage().map(pageMapper); + } + + @Override + public Stream> streamByPage(String continuationToken) { + return pagedIterable.streamByPage(continuationToken).map(pageMapper); + } + + @Override + public Stream> streamByPage(int preferredPageSize) { + return pagedIterable.streamByPage(preferredPageSize).map(pageMapper); + } + + @Override + public Stream> streamByPage(String continuationToken, int preferredPageSize) { + return pagedIterable.streamByPage(continuationToken, preferredPageSize).map(pageMapper); + } + + @Override + public Iterator iterator() { + return new IteratorImpl<>(pagedIterable.iterator(), mapper); + } + + @Override + public Iterable> iterableByPage() { + return new IterableImpl<>(pagedIterable.iterableByPage(), pageMapper); + } + + @Override + public Iterable> iterableByPage(String continuationToken) { + return new IterableImpl<>(pagedIterable.iterableByPage(continuationToken), pageMapper); + } + + @Override + public Iterable> iterableByPage(int preferredPageSize) { + return new IterableImpl<>(pagedIterable.iterableByPage(preferredPageSize), pageMapper); + } + + @Override + public Iterable> iterableByPage(String continuationToken, int preferredPageSize) { + return new IterableImpl<>(pagedIterable.iterableByPage(continuationToken, preferredPageSize), pageMapper); + } + } + + private static final class IteratorImpl implements Iterator { + + private final Iterator iterator; + private final Function mapper; + + private IteratorImpl(Iterator iterator, Function mapper) { + this.iterator = iterator; + this.mapper = mapper; + } + + @Override + public boolean hasNext() { + return iterator.hasNext(); + } + + @Override + public S next() { + return mapper.apply(iterator.next()); + } + + @Override + public void remove() { + iterator.remove(); + } + } + + private static final class IterableImpl implements Iterable { + + private final Iterable iterable; + private final Function mapper; + + private IterableImpl(Iterable iterable, Function mapper) { + this.iterable = iterable; + this.mapper = mapper; + } + + @Override + public Iterator iterator() { + return new IteratorImpl<>(iterable.iterator(), mapper); + } + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/SignalDefinitionImpl.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/SignalDefinitionImpl.java new file mode 100644 index 000000000000..b11b8be4d69a --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/SignalDefinitionImpl.java @@ -0,0 +1,138 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.implementation; + +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.azure.resourcemanager.cloudhealth.fluent.models.SignalDefinitionInner; +import com.azure.resourcemanager.cloudhealth.models.SignalDefinition; +import com.azure.resourcemanager.cloudhealth.models.SignalDefinitionProperties; + +public final class SignalDefinitionImpl + implements SignalDefinition, SignalDefinition.Definition, SignalDefinition.Update { + private SignalDefinitionInner innerObject; + + private final com.azure.resourcemanager.cloudhealth.CloudHealthManager serviceManager; + + public String id() { + return this.innerModel().id(); + } + + public String name() { + return this.innerModel().name(); + } + + public String type() { + return this.innerModel().type(); + } + + public SignalDefinitionProperties properties() { + return this.innerModel().properties(); + } + + public SystemData systemData() { + return this.innerModel().systemData(); + } + + public String resourceGroupName() { + return resourceGroupName; + } + + public SignalDefinitionInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.cloudhealth.CloudHealthManager manager() { + return this.serviceManager; + } + + private String resourceGroupName; + + private String healthModelName; + + private String signalDefinitionName; + + public SignalDefinitionImpl withExistingHealthmodel(String resourceGroupName, String healthModelName) { + this.resourceGroupName = resourceGroupName; + this.healthModelName = healthModelName; + return this; + } + + public SignalDefinition create() { + this.innerObject = serviceManager.serviceClient() + .getSignalDefinitions() + .createOrUpdateWithResponse(resourceGroupName, healthModelName, signalDefinitionName, this.innerModel(), + Context.NONE) + .getValue(); + return this; + } + + public SignalDefinition create(Context context) { + this.innerObject = serviceManager.serviceClient() + .getSignalDefinitions() + .createOrUpdateWithResponse(resourceGroupName, healthModelName, signalDefinitionName, this.innerModel(), + context) + .getValue(); + return this; + } + + SignalDefinitionImpl(String name, com.azure.resourcemanager.cloudhealth.CloudHealthManager serviceManager) { + this.innerObject = new SignalDefinitionInner(); + this.serviceManager = serviceManager; + this.signalDefinitionName = name; + } + + public SignalDefinitionImpl update() { + return this; + } + + public SignalDefinition apply() { + this.innerObject = serviceManager.serviceClient() + .getSignalDefinitions() + .createOrUpdateWithResponse(resourceGroupName, healthModelName, signalDefinitionName, this.innerModel(), + Context.NONE) + .getValue(); + return this; + } + + public SignalDefinition apply(Context context) { + this.innerObject = serviceManager.serviceClient() + .getSignalDefinitions() + .createOrUpdateWithResponse(resourceGroupName, healthModelName, signalDefinitionName, this.innerModel(), + context) + .getValue(); + return this; + } + + SignalDefinitionImpl(SignalDefinitionInner innerObject, + com.azure.resourcemanager.cloudhealth.CloudHealthManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + this.resourceGroupName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "resourceGroups"); + this.healthModelName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "healthmodels"); + this.signalDefinitionName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "signaldefinitions"); + } + + public SignalDefinition refresh() { + this.innerObject = serviceManager.serviceClient() + .getSignalDefinitions() + .getWithResponse(resourceGroupName, healthModelName, signalDefinitionName, Context.NONE) + .getValue(); + return this; + } + + public SignalDefinition refresh(Context context) { + this.innerObject = serviceManager.serviceClient() + .getSignalDefinitions() + .getWithResponse(resourceGroupName, healthModelName, signalDefinitionName, context) + .getValue(); + return this; + } + + public SignalDefinitionImpl withProperties(SignalDefinitionProperties properties) { + this.innerModel().withProperties(properties); + return this; + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/SignalDefinitionsClientImpl.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/SignalDefinitionsClientImpl.java new file mode 100644 index 000000000000..c11687e1bc5a --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/SignalDefinitionsClientImpl.java @@ -0,0 +1,772 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.implementation; + +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.Delete; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Headers; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Put; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.resourcemanager.cloudhealth.fluent.SignalDefinitionsClient; +import com.azure.resourcemanager.cloudhealth.fluent.models.SignalDefinitionInner; +import com.azure.resourcemanager.cloudhealth.implementation.models.SignalDefinitionListResult; +import java.time.OffsetDateTime; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in SignalDefinitionsClient. + */ +public final class SignalDefinitionsClientImpl implements SignalDefinitionsClient { + /** + * The proxy service used to perform REST calls. + */ + private final SignalDefinitionsService service; + + /** + * The service client containing this operation class. + */ + private final CloudHealthClientImpl client; + + /** + * Initializes an instance of SignalDefinitionsClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + SignalDefinitionsClientImpl(CloudHealthClientImpl client) { + this.service + = RestProxy.create(SignalDefinitionsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for CloudHealthClientSignalDefinitions to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "CloudHealthClientSig") + public interface SignalDefinitionsService { + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CloudHealth/healthmodels/{healthModelName}/signaldefinitions/{signalDefinitionName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> get(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("healthModelName") String healthModelName, + @PathParam("signalDefinitionName") String signalDefinitionName, @HeaderParam("Accept") String accept, + Context context); + + @Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CloudHealth/healthmodels/{healthModelName}/signaldefinitions/{signalDefinitionName}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> createOrUpdate(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("healthModelName") String healthModelName, + @PathParam("signalDefinitionName") String signalDefinitionName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") SignalDefinitionInner resource, Context context); + + @Headers({ "Content-Type: application/json" }) + @Delete("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CloudHealth/healthmodels/{healthModelName}/signaldefinitions/{signalDefinitionName}") + @ExpectedResponses({ 200, 204 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> delete(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("healthModelName") String healthModelName, + @PathParam("signalDefinitionName") String signalDefinitionName, @HeaderParam("Accept") String accept, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CloudHealth/healthmodels/{healthModelName}/signaldefinitions") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByHealthModel(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @QueryParam("timestamp") OffsetDateTime timestamp, + @PathParam("healthModelName") String healthModelName, @HeaderParam("Accept") String accept, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByHealthModelNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, Context context); + } + + /** + * Get a SignalDefinition. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param signalDefinitionName Name of the signal definition. Must be unique within a health model. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a SignalDefinition along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getWithResponseAsync(String resourceGroupName, String healthModelName, + String signalDefinitionName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (healthModelName == null) { + return Mono + .error(new IllegalArgumentException("Parameter healthModelName is required and cannot be null.")); + } + if (signalDefinitionName == null) { + return Mono + .error(new IllegalArgumentException("Parameter signalDefinitionName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.get(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, healthModelName, signalDefinitionName, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get a SignalDefinition. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param signalDefinitionName Name of the signal definition. Must be unique within a health model. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a SignalDefinition along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getWithResponseAsync(String resourceGroupName, String healthModelName, + String signalDefinitionName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (healthModelName == null) { + return Mono + .error(new IllegalArgumentException("Parameter healthModelName is required and cannot be null.")); + } + if (signalDefinitionName == null) { + return Mono + .error(new IllegalArgumentException("Parameter signalDefinitionName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.get(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, healthModelName, signalDefinitionName, accept, context); + } + + /** + * Get a SignalDefinition. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param signalDefinitionName Name of the signal definition. Must be unique within a health model. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a SignalDefinition on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getAsync(String resourceGroupName, String healthModelName, + String signalDefinitionName) { + return getWithResponseAsync(resourceGroupName, healthModelName, signalDefinitionName) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Get a SignalDefinition. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param signalDefinitionName Name of the signal definition. Must be unique within a health model. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a SignalDefinition along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(String resourceGroupName, String healthModelName, + String signalDefinitionName, Context context) { + return getWithResponseAsync(resourceGroupName, healthModelName, signalDefinitionName, context).block(); + } + + /** + * Get a SignalDefinition. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param signalDefinitionName Name of the signal definition. Must be unique within a health model. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a SignalDefinition. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public SignalDefinitionInner get(String resourceGroupName, String healthModelName, String signalDefinitionName) { + return getWithResponse(resourceGroupName, healthModelName, signalDefinitionName, Context.NONE).getValue(); + } + + /** + * Create a SignalDefinition. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param signalDefinitionName Name of the signal definition. Must be unique within a health model. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a signal definition in a health model along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createOrUpdateWithResponseAsync(String resourceGroupName, + String healthModelName, String signalDefinitionName, SignalDefinitionInner resource) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (healthModelName == null) { + return Mono + .error(new IllegalArgumentException("Parameter healthModelName is required and cannot be null.")); + } + if (signalDefinitionName == null) { + return Mono + .error(new IllegalArgumentException("Parameter signalDefinitionName is required and cannot be null.")); + } + if (resource == null) { + return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null.")); + } else { + resource.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.createOrUpdate(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, healthModelName, signalDefinitionName, contentType, + accept, resource, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Create a SignalDefinition. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param signalDefinitionName Name of the signal definition. Must be unique within a health model. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a signal definition in a health model along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createOrUpdateWithResponseAsync(String resourceGroupName, + String healthModelName, String signalDefinitionName, SignalDefinitionInner resource, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (healthModelName == null) { + return Mono + .error(new IllegalArgumentException("Parameter healthModelName is required and cannot be null.")); + } + if (signalDefinitionName == null) { + return Mono + .error(new IllegalArgumentException("Parameter signalDefinitionName is required and cannot be null.")); + } + if (resource == null) { + return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null.")); + } else { + resource.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.createOrUpdate(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, healthModelName, signalDefinitionName, contentType, + accept, resource, context); + } + + /** + * Create a SignalDefinition. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param signalDefinitionName Name of the signal definition. Must be unique within a health model. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a signal definition in a health model on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrUpdateAsync(String resourceGroupName, String healthModelName, + String signalDefinitionName, SignalDefinitionInner resource) { + return createOrUpdateWithResponseAsync(resourceGroupName, healthModelName, signalDefinitionName, resource) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Create a SignalDefinition. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param signalDefinitionName Name of the signal definition. Must be unique within a health model. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a signal definition in a health model along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createOrUpdateWithResponse(String resourceGroupName, String healthModelName, + String signalDefinitionName, SignalDefinitionInner resource, Context context) { + return createOrUpdateWithResponseAsync(resourceGroupName, healthModelName, signalDefinitionName, resource, + context).block(); + } + + /** + * Create a SignalDefinition. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param signalDefinitionName Name of the signal definition. Must be unique within a health model. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a signal definition in a health model. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public SignalDefinitionInner createOrUpdate(String resourceGroupName, String healthModelName, + String signalDefinitionName, SignalDefinitionInner resource) { + return createOrUpdateWithResponse(resourceGroupName, healthModelName, signalDefinitionName, resource, + Context.NONE).getValue(); + } + + /** + * Delete a SignalDefinition. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param signalDefinitionName Name of the signal definition. Must be unique within a health model. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> deleteWithResponseAsync(String resourceGroupName, String healthModelName, + String signalDefinitionName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (healthModelName == null) { + return Mono + .error(new IllegalArgumentException("Parameter healthModelName is required and cannot be null.")); + } + if (signalDefinitionName == null) { + return Mono + .error(new IllegalArgumentException("Parameter signalDefinitionName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.delete(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, healthModelName, signalDefinitionName, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Delete a SignalDefinition. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param signalDefinitionName Name of the signal definition. Must be unique within a health model. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> deleteWithResponseAsync(String resourceGroupName, String healthModelName, + String signalDefinitionName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (healthModelName == null) { + return Mono + .error(new IllegalArgumentException("Parameter healthModelName is required and cannot be null.")); + } + if (signalDefinitionName == null) { + return Mono + .error(new IllegalArgumentException("Parameter signalDefinitionName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.delete(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, healthModelName, signalDefinitionName, accept, context); + } + + /** + * Delete a SignalDefinition. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param signalDefinitionName Name of the signal definition. Must be unique within a health model. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono deleteAsync(String resourceGroupName, String healthModelName, String signalDefinitionName) { + return deleteWithResponseAsync(resourceGroupName, healthModelName, signalDefinitionName) + .flatMap(ignored -> Mono.empty()); + } + + /** + * Delete a SignalDefinition. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param signalDefinitionName Name of the signal definition. Must be unique within a health model. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteWithResponse(String resourceGroupName, String healthModelName, + String signalDefinitionName, Context context) { + return deleteWithResponseAsync(resourceGroupName, healthModelName, signalDefinitionName, context).block(); + } + + /** + * Delete a SignalDefinition. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param signalDefinitionName Name of the signal definition. Must be unique within a health model. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void delete(String resourceGroupName, String healthModelName, String signalDefinitionName) { + deleteWithResponse(resourceGroupName, healthModelName, signalDefinitionName, Context.NONE); + } + + /** + * List SignalDefinition resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param timestamp Timestamp to use for the operation. When specified, the version of the resource at this point in + * time is retrieved. If not specified, the latest version is used. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a SignalDefinition list operation along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByHealthModelSinglePageAsync(String resourceGroupName, + String healthModelName, OffsetDateTime timestamp) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (healthModelName == null) { + return Mono + .error(new IllegalArgumentException("Parameter healthModelName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listByHealthModel(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, timestamp, healthModelName, accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), + res.getStatusCode(), res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * List SignalDefinition resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param timestamp Timestamp to use for the operation. When specified, the version of the resource at this point in + * time is retrieved. If not specified, the latest version is used. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a SignalDefinition list operation along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByHealthModelSinglePageAsync(String resourceGroupName, + String healthModelName, OffsetDateTime timestamp, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (healthModelName == null) { + return Mono + .error(new IllegalArgumentException("Parameter healthModelName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .listByHealthModel(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, timestamp, healthModelName, accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } + + /** + * List SignalDefinition resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param timestamp Timestamp to use for the operation. When specified, the version of the resource at this point in + * time is retrieved. If not specified, the latest version is used. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a SignalDefinition list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByHealthModelAsync(String resourceGroupName, String healthModelName, + OffsetDateTime timestamp) { + return new PagedFlux<>(() -> listByHealthModelSinglePageAsync(resourceGroupName, healthModelName, timestamp), + nextLink -> listByHealthModelNextSinglePageAsync(nextLink)); + } + + /** + * List SignalDefinition resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a SignalDefinition list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByHealthModelAsync(String resourceGroupName, String healthModelName) { + final OffsetDateTime timestamp = null; + return new PagedFlux<>(() -> listByHealthModelSinglePageAsync(resourceGroupName, healthModelName, timestamp), + nextLink -> listByHealthModelNextSinglePageAsync(nextLink)); + } + + /** + * List SignalDefinition resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param timestamp Timestamp to use for the operation. When specified, the version of the resource at this point in + * time is retrieved. If not specified, the latest version is used. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a SignalDefinition list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByHealthModelAsync(String resourceGroupName, String healthModelName, + OffsetDateTime timestamp, Context context) { + return new PagedFlux<>( + () -> listByHealthModelSinglePageAsync(resourceGroupName, healthModelName, timestamp, context), + nextLink -> listByHealthModelNextSinglePageAsync(nextLink, context)); + } + + /** + * List SignalDefinition resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a SignalDefinition list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByHealthModel(String resourceGroupName, String healthModelName) { + final OffsetDateTime timestamp = null; + return new PagedIterable<>(listByHealthModelAsync(resourceGroupName, healthModelName, timestamp)); + } + + /** + * List SignalDefinition resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param timestamp Timestamp to use for the operation. When specified, the version of the resource at this point in + * time is retrieved. If not specified, the latest version is used. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a SignalDefinition list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByHealthModel(String resourceGroupName, String healthModelName, + OffsetDateTime timestamp, Context context) { + return new PagedIterable<>(listByHealthModelAsync(resourceGroupName, healthModelName, timestamp, context)); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a SignalDefinition list operation along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByHealthModelNextSinglePageAsync(String nextLink) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listByHealthModelNext(nextLink, this.client.getEndpoint(), accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), + res.getStatusCode(), res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a SignalDefinition list operation along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByHealthModelNextSinglePageAsync(String nextLink, + Context context) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.listByHealthModelNext(nextLink, this.client.getEndpoint(), accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/SignalDefinitionsImpl.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/SignalDefinitionsImpl.java new file mode 100644 index 000000000000..eafe572129f3 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/SignalDefinitionsImpl.java @@ -0,0 +1,163 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.implementation; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.cloudhealth.fluent.SignalDefinitionsClient; +import com.azure.resourcemanager.cloudhealth.fluent.models.SignalDefinitionInner; +import com.azure.resourcemanager.cloudhealth.models.SignalDefinition; +import com.azure.resourcemanager.cloudhealth.models.SignalDefinitions; +import java.time.OffsetDateTime; + +public final class SignalDefinitionsImpl implements SignalDefinitions { + private static final ClientLogger LOGGER = new ClientLogger(SignalDefinitionsImpl.class); + + private final SignalDefinitionsClient innerClient; + + private final com.azure.resourcemanager.cloudhealth.CloudHealthManager serviceManager; + + public SignalDefinitionsImpl(SignalDefinitionsClient innerClient, + com.azure.resourcemanager.cloudhealth.CloudHealthManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public Response getWithResponse(String resourceGroupName, String healthModelName, + String signalDefinitionName, Context context) { + Response inner + = this.serviceClient().getWithResponse(resourceGroupName, healthModelName, signalDefinitionName, context); + if (inner != null) { + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new SignalDefinitionImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public SignalDefinition get(String resourceGroupName, String healthModelName, String signalDefinitionName) { + SignalDefinitionInner inner + = this.serviceClient().get(resourceGroupName, healthModelName, signalDefinitionName); + if (inner != null) { + return new SignalDefinitionImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response deleteWithResponse(String resourceGroupName, String healthModelName, + String signalDefinitionName, Context context) { + return this.serviceClient() + .deleteWithResponse(resourceGroupName, healthModelName, signalDefinitionName, context); + } + + public void delete(String resourceGroupName, String healthModelName, String signalDefinitionName) { + this.serviceClient().delete(resourceGroupName, healthModelName, signalDefinitionName); + } + + public PagedIterable listByHealthModel(String resourceGroupName, String healthModelName) { + PagedIterable inner + = this.serviceClient().listByHealthModel(resourceGroupName, healthModelName); + return ResourceManagerUtils.mapPage(inner, inner1 -> new SignalDefinitionImpl(inner1, this.manager())); + } + + public PagedIterable listByHealthModel(String resourceGroupName, String healthModelName, + OffsetDateTime timestamp, Context context) { + PagedIterable inner + = this.serviceClient().listByHealthModel(resourceGroupName, healthModelName, timestamp, context); + return ResourceManagerUtils.mapPage(inner, inner1 -> new SignalDefinitionImpl(inner1, this.manager())); + } + + public SignalDefinition getById(String id) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String healthModelName = ResourceManagerUtils.getValueFromIdByName(id, "healthmodels"); + if (healthModelName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'healthmodels'.", id))); + } + String signalDefinitionName = ResourceManagerUtils.getValueFromIdByName(id, "signaldefinitions"); + if (signalDefinitionName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'signaldefinitions'.", id))); + } + return this.getWithResponse(resourceGroupName, healthModelName, signalDefinitionName, Context.NONE).getValue(); + } + + public Response getByIdWithResponse(String id, Context context) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String healthModelName = ResourceManagerUtils.getValueFromIdByName(id, "healthmodels"); + if (healthModelName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'healthmodels'.", id))); + } + String signalDefinitionName = ResourceManagerUtils.getValueFromIdByName(id, "signaldefinitions"); + if (signalDefinitionName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'signaldefinitions'.", id))); + } + return this.getWithResponse(resourceGroupName, healthModelName, signalDefinitionName, context); + } + + public void deleteById(String id) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String healthModelName = ResourceManagerUtils.getValueFromIdByName(id, "healthmodels"); + if (healthModelName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'healthmodels'.", id))); + } + String signalDefinitionName = ResourceManagerUtils.getValueFromIdByName(id, "signaldefinitions"); + if (signalDefinitionName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'signaldefinitions'.", id))); + } + this.deleteWithResponse(resourceGroupName, healthModelName, signalDefinitionName, Context.NONE); + } + + public Response deleteByIdWithResponse(String id, Context context) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String healthModelName = ResourceManagerUtils.getValueFromIdByName(id, "healthmodels"); + if (healthModelName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'healthmodels'.", id))); + } + String signalDefinitionName = ResourceManagerUtils.getValueFromIdByName(id, "signaldefinitions"); + if (signalDefinitionName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'signaldefinitions'.", id))); + } + return this.deleteWithResponse(resourceGroupName, healthModelName, signalDefinitionName, context); + } + + private SignalDefinitionsClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.cloudhealth.CloudHealthManager manager() { + return this.serviceManager; + } + + public SignalDefinitionImpl define(String name) { + return new SignalDefinitionImpl(name, this.manager()); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/models/AuthenticationSettingListResult.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/models/AuthenticationSettingListResult.java new file mode 100644 index 000000000000..0e3f1b71e306 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/models/AuthenticationSettingListResult.java @@ -0,0 +1,115 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.implementation.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.cloudhealth.fluent.models.AuthenticationSettingInner; +import java.io.IOException; +import java.util.List; + +/** + * The response of a AuthenticationSetting list operation. + */ +@Immutable +public final class AuthenticationSettingListResult implements JsonSerializable { + /* + * The AuthenticationSetting items on this page + */ + private List value; + + /* + * The link to the next page of items + */ + private String nextLink; + + /** + * Creates an instance of AuthenticationSettingListResult class. + */ + private AuthenticationSettingListResult() { + } + + /** + * Get the value property: The AuthenticationSetting items on this page. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Get the nextLink property: The link to the next page of items. + * + * @return the nextLink value. + */ + public String nextLink() { + return this.nextLink; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (value() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property value in model AuthenticationSettingListResult")); + } else { + value().forEach(e -> e.validate()); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(AuthenticationSettingListResult.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("value", this.value, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeStringField("nextLink", this.nextLink); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of AuthenticationSettingListResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of AuthenticationSettingListResult if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the AuthenticationSettingListResult. + */ + public static AuthenticationSettingListResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + AuthenticationSettingListResult deserializedAuthenticationSettingListResult + = new AuthenticationSettingListResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + List value + = reader.readArray(reader1 -> AuthenticationSettingInner.fromJson(reader1)); + deserializedAuthenticationSettingListResult.value = value; + } else if ("nextLink".equals(fieldName)) { + deserializedAuthenticationSettingListResult.nextLink = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedAuthenticationSettingListResult; + }); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/models/DiscoveryRuleListResult.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/models/DiscoveryRuleListResult.java new file mode 100644 index 000000000000..6d283fdb4857 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/models/DiscoveryRuleListResult.java @@ -0,0 +1,112 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.implementation.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.cloudhealth.fluent.models.DiscoveryRuleInner; +import java.io.IOException; +import java.util.List; + +/** + * The response of a DiscoveryRule list operation. + */ +@Immutable +public final class DiscoveryRuleListResult implements JsonSerializable { + /* + * The DiscoveryRule items on this page + */ + private List value; + + /* + * The link to the next page of items + */ + private String nextLink; + + /** + * Creates an instance of DiscoveryRuleListResult class. + */ + private DiscoveryRuleListResult() { + } + + /** + * Get the value property: The DiscoveryRule items on this page. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Get the nextLink property: The link to the next page of items. + * + * @return the nextLink value. + */ + public String nextLink() { + return this.nextLink; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (value() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property value in model DiscoveryRuleListResult")); + } else { + value().forEach(e -> e.validate()); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(DiscoveryRuleListResult.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("value", this.value, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeStringField("nextLink", this.nextLink); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DiscoveryRuleListResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DiscoveryRuleListResult if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the DiscoveryRuleListResult. + */ + public static DiscoveryRuleListResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + DiscoveryRuleListResult deserializedDiscoveryRuleListResult = new DiscoveryRuleListResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + List value = reader.readArray(reader1 -> DiscoveryRuleInner.fromJson(reader1)); + deserializedDiscoveryRuleListResult.value = value; + } else if ("nextLink".equals(fieldName)) { + deserializedDiscoveryRuleListResult.nextLink = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedDiscoveryRuleListResult; + }); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/models/EntityListResult.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/models/EntityListResult.java new file mode 100644 index 000000000000..9568ed48d712 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/models/EntityListResult.java @@ -0,0 +1,112 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.implementation.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.cloudhealth.fluent.models.EntityInner; +import java.io.IOException; +import java.util.List; + +/** + * The response of a Entity list operation. + */ +@Immutable +public final class EntityListResult implements JsonSerializable { + /* + * The Entity items on this page + */ + private List value; + + /* + * The link to the next page of items + */ + private String nextLink; + + /** + * Creates an instance of EntityListResult class. + */ + private EntityListResult() { + } + + /** + * Get the value property: The Entity items on this page. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Get the nextLink property: The link to the next page of items. + * + * @return the nextLink value. + */ + public String nextLink() { + return this.nextLink; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (value() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property value in model EntityListResult")); + } else { + value().forEach(e -> e.validate()); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(EntityListResult.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("value", this.value, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeStringField("nextLink", this.nextLink); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of EntityListResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of EntityListResult if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the EntityListResult. + */ + public static EntityListResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + EntityListResult deserializedEntityListResult = new EntityListResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + List value = reader.readArray(reader1 -> EntityInner.fromJson(reader1)); + deserializedEntityListResult.value = value; + } else if ("nextLink".equals(fieldName)) { + deserializedEntityListResult.nextLink = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedEntityListResult; + }); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/models/HealthModelListResult.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/models/HealthModelListResult.java new file mode 100644 index 000000000000..25eb2063244a --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/models/HealthModelListResult.java @@ -0,0 +1,112 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.implementation.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.cloudhealth.fluent.models.HealthModelInner; +import java.io.IOException; +import java.util.List; + +/** + * The response of a HealthModel list operation. + */ +@Immutable +public final class HealthModelListResult implements JsonSerializable { + /* + * The HealthModel items on this page + */ + private List value; + + /* + * The link to the next page of items + */ + private String nextLink; + + /** + * Creates an instance of HealthModelListResult class. + */ + private HealthModelListResult() { + } + + /** + * Get the value property: The HealthModel items on this page. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Get the nextLink property: The link to the next page of items. + * + * @return the nextLink value. + */ + public String nextLink() { + return this.nextLink; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (value() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property value in model HealthModelListResult")); + } else { + value().forEach(e -> e.validate()); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(HealthModelListResult.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("value", this.value, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeStringField("nextLink", this.nextLink); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of HealthModelListResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of HealthModelListResult if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the HealthModelListResult. + */ + public static HealthModelListResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + HealthModelListResult deserializedHealthModelListResult = new HealthModelListResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + List value = reader.readArray(reader1 -> HealthModelInner.fromJson(reader1)); + deserializedHealthModelListResult.value = value; + } else if ("nextLink".equals(fieldName)) { + deserializedHealthModelListResult.nextLink = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedHealthModelListResult; + }); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/models/OperationListResult.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/models/OperationListResult.java new file mode 100644 index 000000000000..f50718201658 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/models/OperationListResult.java @@ -0,0 +1,113 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.implementation.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.cloudhealth.fluent.models.OperationInner; +import java.io.IOException; +import java.util.List; + +/** + * A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of + * results. + */ +@Immutable +public final class OperationListResult implements JsonSerializable { + /* + * The Operation items on this page + */ + private List value; + + /* + * The link to the next page of items + */ + private String nextLink; + + /** + * Creates an instance of OperationListResult class. + */ + private OperationListResult() { + } + + /** + * Get the value property: The Operation items on this page. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Get the nextLink property: The link to the next page of items. + * + * @return the nextLink value. + */ + public String nextLink() { + return this.nextLink; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (value() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property value in model OperationListResult")); + } else { + value().forEach(e -> e.validate()); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(OperationListResult.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("value", this.value, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeStringField("nextLink", this.nextLink); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of OperationListResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OperationListResult if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the OperationListResult. + */ + public static OperationListResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OperationListResult deserializedOperationListResult = new OperationListResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + List value = reader.readArray(reader1 -> OperationInner.fromJson(reader1)); + deserializedOperationListResult.value = value; + } else if ("nextLink".equals(fieldName)) { + deserializedOperationListResult.nextLink = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedOperationListResult; + }); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/models/RelationshipListResult.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/models/RelationshipListResult.java new file mode 100644 index 000000000000..27df9c23dfe1 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/models/RelationshipListResult.java @@ -0,0 +1,112 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.implementation.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.cloudhealth.fluent.models.RelationshipInner; +import java.io.IOException; +import java.util.List; + +/** + * The response of a Relationship list operation. + */ +@Immutable +public final class RelationshipListResult implements JsonSerializable { + /* + * The Relationship items on this page + */ + private List value; + + /* + * The link to the next page of items + */ + private String nextLink; + + /** + * Creates an instance of RelationshipListResult class. + */ + private RelationshipListResult() { + } + + /** + * Get the value property: The Relationship items on this page. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Get the nextLink property: The link to the next page of items. + * + * @return the nextLink value. + */ + public String nextLink() { + return this.nextLink; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (value() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property value in model RelationshipListResult")); + } else { + value().forEach(e -> e.validate()); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(RelationshipListResult.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("value", this.value, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeStringField("nextLink", this.nextLink); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RelationshipListResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RelationshipListResult if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the RelationshipListResult. + */ + public static RelationshipListResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + RelationshipListResult deserializedRelationshipListResult = new RelationshipListResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + List value = reader.readArray(reader1 -> RelationshipInner.fromJson(reader1)); + deserializedRelationshipListResult.value = value; + } else if ("nextLink".equals(fieldName)) { + deserializedRelationshipListResult.nextLink = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedRelationshipListResult; + }); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/models/SignalDefinitionListResult.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/models/SignalDefinitionListResult.java new file mode 100644 index 000000000000..2f20a3c937ef --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/models/SignalDefinitionListResult.java @@ -0,0 +1,114 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.implementation.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.cloudhealth.fluent.models.SignalDefinitionInner; +import java.io.IOException; +import java.util.List; + +/** + * The response of a SignalDefinition list operation. + */ +@Immutable +public final class SignalDefinitionListResult implements JsonSerializable { + /* + * The SignalDefinition items on this page + */ + private List value; + + /* + * The link to the next page of items + */ + private String nextLink; + + /** + * Creates an instance of SignalDefinitionListResult class. + */ + private SignalDefinitionListResult() { + } + + /** + * Get the value property: The SignalDefinition items on this page. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Get the nextLink property: The link to the next page of items. + * + * @return the nextLink value. + */ + public String nextLink() { + return this.nextLink; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (value() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property value in model SignalDefinitionListResult")); + } else { + value().forEach(e -> e.validate()); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(SignalDefinitionListResult.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("value", this.value, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeStringField("nextLink", this.nextLink); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SignalDefinitionListResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SignalDefinitionListResult if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the SignalDefinitionListResult. + */ + public static SignalDefinitionListResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SignalDefinitionListResult deserializedSignalDefinitionListResult = new SignalDefinitionListResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + List value + = reader.readArray(reader1 -> SignalDefinitionInner.fromJson(reader1)); + deserializedSignalDefinitionListResult.value = value; + } else if ("nextLink".equals(fieldName)) { + deserializedSignalDefinitionListResult.nextLink = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedSignalDefinitionListResult; + }); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/package-info.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/package-info.java new file mode 100644 index 000000000000..86d60aef1885 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/implementation/package-info.java @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for CloudHealth. + */ +package com.azure.resourcemanager.cloudhealth.implementation; diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/ActionType.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/ActionType.java new file mode 100644 index 000000000000..b42ab9de889b --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/ActionType.java @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + */ +public final class ActionType extends ExpandableStringEnum { + /** + * Actions are for internal-only APIs. + */ + public static final ActionType INTERNAL = fromString("Internal"); + + /** + * Creates a new instance of ActionType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public ActionType() { + } + + /** + * Creates or finds a ActionType from its string representation. + * + * @param name a name to look for. + * @return the corresponding ActionType. + */ + public static ActionType fromString(String name) { + return fromString(name, ActionType.class); + } + + /** + * Gets known ActionType values. + * + * @return known ActionType values. + */ + public static Collection values() { + return values(ActionType.class); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/AlertConfiguration.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/AlertConfiguration.java new file mode 100644 index 000000000000..07ec4e71d55c --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/AlertConfiguration.java @@ -0,0 +1,162 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * Alert configuration details. + */ +@Fluent +public final class AlertConfiguration implements JsonSerializable { + /* + * The severity of triggered alert. + */ + private AlertSeverity severity; + + /* + * The alert rule description. + */ + private String description; + + /* + * Optional list of action group resource IDs to be notified when the alert is triggered. + */ + private List actionGroupIds; + + /** + * Creates an instance of AlertConfiguration class. + */ + public AlertConfiguration() { + } + + /** + * Get the severity property: The severity of triggered alert. + * + * @return the severity value. + */ + public AlertSeverity severity() { + return this.severity; + } + + /** + * Set the severity property: The severity of triggered alert. + * + * @param severity the severity value to set. + * @return the AlertConfiguration object itself. + */ + public AlertConfiguration withSeverity(AlertSeverity severity) { + this.severity = severity; + return this; + } + + /** + * Get the description property: The alert rule description. + * + * @return the description value. + */ + public String description() { + return this.description; + } + + /** + * Set the description property: The alert rule description. + * + * @param description the description value to set. + * @return the AlertConfiguration object itself. + */ + public AlertConfiguration withDescription(String description) { + this.description = description; + return this; + } + + /** + * Get the actionGroupIds property: Optional list of action group resource IDs to be notified when the alert is + * triggered. + * + * @return the actionGroupIds value. + */ + public List actionGroupIds() { + return this.actionGroupIds; + } + + /** + * Set the actionGroupIds property: Optional list of action group resource IDs to be notified when the alert is + * triggered. + * + * @param actionGroupIds the actionGroupIds value to set. + * @return the AlertConfiguration object itself. + */ + public AlertConfiguration withActionGroupIds(List actionGroupIds) { + this.actionGroupIds = actionGroupIds; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (severity() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property severity in model AlertConfiguration")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(AlertConfiguration.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("severity", this.severity == null ? null : this.severity.toString()); + jsonWriter.writeStringField("description", this.description); + jsonWriter.writeArrayField("actionGroupIds", this.actionGroupIds, + (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of AlertConfiguration from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of AlertConfiguration if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the AlertConfiguration. + */ + public static AlertConfiguration fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + AlertConfiguration deserializedAlertConfiguration = new AlertConfiguration(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("severity".equals(fieldName)) { + deserializedAlertConfiguration.severity = AlertSeverity.fromString(reader.getString()); + } else if ("description".equals(fieldName)) { + deserializedAlertConfiguration.description = reader.getString(); + } else if ("actionGroupIds".equals(fieldName)) { + List actionGroupIds = reader.readArray(reader1 -> reader1.getString()); + deserializedAlertConfiguration.actionGroupIds = actionGroupIds; + } else { + reader.skipChildren(); + } + } + + return deserializedAlertConfiguration; + }); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/AlertSeverity.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/AlertSeverity.java new file mode 100644 index 000000000000..7fe49b018376 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/AlertSeverity.java @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Severity of an alert. + */ +public final class AlertSeverity extends ExpandableStringEnum { + /** + * Critical. + */ + public static final AlertSeverity SEV0 = fromString("Sev0"); + + /** + * Error. + */ + public static final AlertSeverity SEV1 = fromString("Sev1"); + + /** + * Warning. + */ + public static final AlertSeverity SEV2 = fromString("Sev2"); + + /** + * Informational. + */ + public static final AlertSeverity SEV3 = fromString("Sev3"); + + /** + * Verbose. + */ + public static final AlertSeverity SEV4 = fromString("Sev4"); + + /** + * Creates a new instance of AlertSeverity value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public AlertSeverity() { + } + + /** + * Creates or finds a AlertSeverity from its string representation. + * + * @param name a name to look for. + * @return the corresponding AlertSeverity. + */ + public static AlertSeverity fromString(String name) { + return fromString(name, AlertSeverity.class); + } + + /** + * Gets known AlertSeverity values. + * + * @return known AlertSeverity values. + */ + public static Collection values() { + return values(AlertSeverity.class); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/AuthenticationKind.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/AuthenticationKind.java new file mode 100644 index 000000000000..3a92357cb1e2 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/AuthenticationKind.java @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Supported kinds of authentication settings as discriminator. + */ +public final class AuthenticationKind extends ExpandableStringEnum { + /** + * Static value ManagedIdentity for AuthenticationKind. + */ + public static final AuthenticationKind MANAGED_IDENTITY = fromString("ManagedIdentity"); + + /** + * Creates a new instance of AuthenticationKind value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public AuthenticationKind() { + } + + /** + * Creates or finds a AuthenticationKind from its string representation. + * + * @param name a name to look for. + * @return the corresponding AuthenticationKind. + */ + public static AuthenticationKind fromString(String name) { + return fromString(name, AuthenticationKind.class); + } + + /** + * Gets known AuthenticationKind values. + * + * @return known AuthenticationKind values. + */ + public static Collection values() { + return values(AuthenticationKind.class); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/AuthenticationSetting.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/AuthenticationSetting.java new file mode 100644 index 000000000000..5c5f57d98265 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/AuthenticationSetting.java @@ -0,0 +1,189 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.azure.resourcemanager.cloudhealth.fluent.models.AuthenticationSettingInner; + +/** + * An immutable client-side representation of AuthenticationSetting. + */ +public interface AuthenticationSetting { + /** + * Gets the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + String id(); + + /** + * Gets the name property: The name of the resource. + * + * @return the name value. + */ + String name(); + + /** + * Gets the type property: The type of the resource. + * + * @return the type value. + */ + String type(); + + /** + * Gets the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + AuthenticationSettingProperties properties(); + + /** + * Gets the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + SystemData systemData(); + + /** + * Gets the name of the resource group. + * + * @return the name of the resource group. + */ + String resourceGroupName(); + + /** + * Gets the inner com.azure.resourcemanager.cloudhealth.fluent.models.AuthenticationSettingInner object. + * + * @return the inner object. + */ + AuthenticationSettingInner innerModel(); + + /** + * The entirety of the AuthenticationSetting definition. + */ + interface Definition + extends DefinitionStages.Blank, DefinitionStages.WithParentResource, DefinitionStages.WithCreate { + } + + /** + * The AuthenticationSetting definition stages. + */ + interface DefinitionStages { + /** + * The first stage of the AuthenticationSetting definition. + */ + interface Blank extends WithParentResource { + } + + /** + * The stage of the AuthenticationSetting definition allowing to specify parent resource. + */ + interface WithParentResource { + /** + * Specifies resourceGroupName, healthModelName. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @return the next definition stage. + */ + WithCreate withExistingHealthmodel(String resourceGroupName, String healthModelName); + } + + /** + * The stage of the AuthenticationSetting definition which contains all the minimum required properties for the + * resource to be created, but also allows for any other optional properties to be specified. + */ + interface WithCreate extends DefinitionStages.WithProperties { + /** + * Executes the create request. + * + * @return the created resource. + */ + AuthenticationSetting create(); + + /** + * Executes the create request. + * + * @param context The context to associate with this operation. + * @return the created resource. + */ + AuthenticationSetting create(Context context); + } + + /** + * The stage of the AuthenticationSetting definition allowing to specify properties. + */ + interface WithProperties { + /** + * Specifies the properties property: The resource-specific properties for this resource.. + * + * @param properties The resource-specific properties for this resource. + * @return the next definition stage. + */ + WithCreate withProperties(AuthenticationSettingProperties properties); + } + } + + /** + * Begins update for the AuthenticationSetting resource. + * + * @return the stage of resource update. + */ + AuthenticationSetting.Update update(); + + /** + * The template for AuthenticationSetting update. + */ + interface Update extends UpdateStages.WithProperties { + /** + * Executes the update request. + * + * @return the updated resource. + */ + AuthenticationSetting apply(); + + /** + * Executes the update request. + * + * @param context The context to associate with this operation. + * @return the updated resource. + */ + AuthenticationSetting apply(Context context); + } + + /** + * The AuthenticationSetting update stages. + */ + interface UpdateStages { + /** + * The stage of the AuthenticationSetting update allowing to specify properties. + */ + interface WithProperties { + /** + * Specifies the properties property: The resource-specific properties for this resource.. + * + * @param properties The resource-specific properties for this resource. + * @return the next definition stage. + */ + Update withProperties(AuthenticationSettingProperties properties); + } + } + + /** + * Refreshes the resource to sync with Azure. + * + * @return the refreshed resource. + */ + AuthenticationSetting refresh(); + + /** + * Refreshes the resource to sync with Azure. + * + * @param context The context to associate with this operation. + * @return the refreshed resource. + */ + AuthenticationSetting refresh(Context context); +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/AuthenticationSettingProperties.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/AuthenticationSettingProperties.java new file mode 100644 index 000000000000..64d28f7bbcc1 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/AuthenticationSettingProperties.java @@ -0,0 +1,166 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Authentication setting properties. + */ +@Fluent +public class AuthenticationSettingProperties implements JsonSerializable { + /* + * Kind of the authentication setting + */ + private AuthenticationKind authenticationKind = AuthenticationKind.fromString("AuthenticationSettingProperties"); + + /* + * The status of the last operation. + */ + private HealthModelProvisioningState provisioningState; + + /* + * Display name + */ + private String displayName; + + /** + * Creates an instance of AuthenticationSettingProperties class. + */ + public AuthenticationSettingProperties() { + } + + /** + * Get the authenticationKind property: Kind of the authentication setting. + * + * @return the authenticationKind value. + */ + public AuthenticationKind authenticationKind() { + return this.authenticationKind; + } + + /** + * Get the provisioningState property: The status of the last operation. + * + * @return the provisioningState value. + */ + public HealthModelProvisioningState provisioningState() { + return this.provisioningState; + } + + /** + * Set the provisioningState property: The status of the last operation. + * + * @param provisioningState the provisioningState value to set. + * @return the AuthenticationSettingProperties object itself. + */ + AuthenticationSettingProperties withProvisioningState(HealthModelProvisioningState provisioningState) { + this.provisioningState = provisioningState; + return this; + } + + /** + * Get the displayName property: Display name. + * + * @return the displayName value. + */ + public String displayName() { + return this.displayName; + } + + /** + * Set the displayName property: Display name. + * + * @param displayName the displayName value to set. + * @return the AuthenticationSettingProperties object itself. + */ + public AuthenticationSettingProperties withDisplayName(String displayName) { + this.displayName = displayName; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("authenticationKind", + this.authenticationKind == null ? null : this.authenticationKind.toString()); + jsonWriter.writeStringField("displayName", this.displayName); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of AuthenticationSettingProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of AuthenticationSettingProperties if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the AuthenticationSettingProperties. + */ + public static AuthenticationSettingProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + readerToUse.nextToken(); // Prepare for reading + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("authenticationKind".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("ManagedIdentity".equals(discriminatorValue)) { + return ManagedIdentityAuthenticationSettingProperties.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + static AuthenticationSettingProperties fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + AuthenticationSettingProperties deserializedAuthenticationSettingProperties + = new AuthenticationSettingProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("authenticationKind".equals(fieldName)) { + deserializedAuthenticationSettingProperties.authenticationKind + = AuthenticationKind.fromString(reader.getString()); + } else if ("provisioningState".equals(fieldName)) { + deserializedAuthenticationSettingProperties.provisioningState + = HealthModelProvisioningState.fromString(reader.getString()); + } else if ("displayName".equals(fieldName)) { + deserializedAuthenticationSettingProperties.displayName = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedAuthenticationSettingProperties; + }); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/AuthenticationSettings.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/AuthenticationSettings.java new file mode 100644 index 000000000000..31111a176a9b --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/AuthenticationSettings.java @@ -0,0 +1,148 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; + +/** + * Resource collection API of AuthenticationSettings. + */ +public interface AuthenticationSettings { + /** + * Get a AuthenticationSetting. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param authenticationSettingName Name of the authentication setting. Must be unique within a health model. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a AuthenticationSetting along with {@link Response}. + */ + Response getWithResponse(String resourceGroupName, String healthModelName, + String authenticationSettingName, Context context); + + /** + * Get a AuthenticationSetting. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param authenticationSettingName Name of the authentication setting. Must be unique within a health model. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a AuthenticationSetting. + */ + AuthenticationSetting get(String resourceGroupName, String healthModelName, String authenticationSettingName); + + /** + * Delete a AuthenticationSetting. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param authenticationSettingName Name of the authentication setting. Must be unique within a health model. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + Response deleteWithResponse(String resourceGroupName, String healthModelName, + String authenticationSettingName, Context context); + + /** + * Delete a AuthenticationSetting. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param authenticationSettingName Name of the authentication setting. Must be unique within a health model. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void delete(String resourceGroupName, String healthModelName, String authenticationSettingName); + + /** + * List AuthenticationSetting resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a AuthenticationSetting list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable listByHealthModel(String resourceGroupName, String healthModelName); + + /** + * List AuthenticationSetting resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a AuthenticationSetting list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable listByHealthModel(String resourceGroupName, String healthModelName, + Context context); + + /** + * Get a AuthenticationSetting. + * + * @param id the resource ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a AuthenticationSetting along with {@link Response}. + */ + AuthenticationSetting getById(String id); + + /** + * Get a AuthenticationSetting. + * + * @param id the resource ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a AuthenticationSetting along with {@link Response}. + */ + Response getByIdWithResponse(String id, Context context); + + /** + * Delete a AuthenticationSetting. + * + * @param id the resource ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void deleteById(String id); + + /** + * Delete a AuthenticationSetting. + * + * @param id the resource ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + Response deleteByIdWithResponse(String id, Context context); + + /** + * Begins definition for a new AuthenticationSetting resource. + * + * @param name resource name. + * @return the first stage of the new AuthenticationSetting definition. + */ + AuthenticationSetting.DefinitionStages.Blank define(String name); +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/AzureMonitorWorkspaceSignalGroup.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/AzureMonitorWorkspaceSignalGroup.java new file mode 100644 index 000000000000..3689ba95170e --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/AzureMonitorWorkspaceSignalGroup.java @@ -0,0 +1,176 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * A grouping of signal assignments for a Azure Monitor Workspace. + */ +@Fluent +public final class AzureMonitorWorkspaceSignalGroup implements JsonSerializable { + /* + * Signal definitions which are assigned to this signal group. All assignments are combined with an OR operator. + */ + private List signalAssignments; + + /* + * Reference to the name of the authentication setting which is used for querying the data source + */ + private String authenticationSetting; + + /* + * Azure Monitor workspace resource ID + */ + private String azureMonitorWorkspaceResourceId; + + /** + * Creates an instance of AzureMonitorWorkspaceSignalGroup class. + */ + public AzureMonitorWorkspaceSignalGroup() { + } + + /** + * Get the signalAssignments property: Signal definitions which are assigned to this signal group. All assignments + * are combined with an OR operator. + * + * @return the signalAssignments value. + */ + public List signalAssignments() { + return this.signalAssignments; + } + + /** + * Set the signalAssignments property: Signal definitions which are assigned to this signal group. All assignments + * are combined with an OR operator. + * + * @param signalAssignments the signalAssignments value to set. + * @return the AzureMonitorWorkspaceSignalGroup object itself. + */ + public AzureMonitorWorkspaceSignalGroup withSignalAssignments(List signalAssignments) { + this.signalAssignments = signalAssignments; + return this; + } + + /** + * Get the authenticationSetting property: Reference to the name of the authentication setting which is used for + * querying the data source. + * + * @return the authenticationSetting value. + */ + public String authenticationSetting() { + return this.authenticationSetting; + } + + /** + * Set the authenticationSetting property: Reference to the name of the authentication setting which is used for + * querying the data source. + * + * @param authenticationSetting the authenticationSetting value to set. + * @return the AzureMonitorWorkspaceSignalGroup object itself. + */ + public AzureMonitorWorkspaceSignalGroup withAuthenticationSetting(String authenticationSetting) { + this.authenticationSetting = authenticationSetting; + return this; + } + + /** + * Get the azureMonitorWorkspaceResourceId property: Azure Monitor workspace resource ID. + * + * @return the azureMonitorWorkspaceResourceId value. + */ + public String azureMonitorWorkspaceResourceId() { + return this.azureMonitorWorkspaceResourceId; + } + + /** + * Set the azureMonitorWorkspaceResourceId property: Azure Monitor workspace resource ID. + * + * @param azureMonitorWorkspaceResourceId the azureMonitorWorkspaceResourceId value to set. + * @return the AzureMonitorWorkspaceSignalGroup object itself. + */ + public AzureMonitorWorkspaceSignalGroup + withAzureMonitorWorkspaceResourceId(String azureMonitorWorkspaceResourceId) { + this.azureMonitorWorkspaceResourceId = azureMonitorWorkspaceResourceId; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (signalAssignments() != null) { + signalAssignments().forEach(e -> e.validate()); + } + if (authenticationSetting() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property authenticationSetting in model AzureMonitorWorkspaceSignalGroup")); + } + if (azureMonitorWorkspaceResourceId() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property azureMonitorWorkspaceResourceId in model AzureMonitorWorkspaceSignalGroup")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(AzureMonitorWorkspaceSignalGroup.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("authenticationSetting", this.authenticationSetting); + jsonWriter.writeStringField("azureMonitorWorkspaceResourceId", this.azureMonitorWorkspaceResourceId); + jsonWriter.writeArrayField("signalAssignments", this.signalAssignments, + (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of AzureMonitorWorkspaceSignalGroup from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of AzureMonitorWorkspaceSignalGroup if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the AzureMonitorWorkspaceSignalGroup. + */ + public static AzureMonitorWorkspaceSignalGroup fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + AzureMonitorWorkspaceSignalGroup deserializedAzureMonitorWorkspaceSignalGroup + = new AzureMonitorWorkspaceSignalGroup(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("authenticationSetting".equals(fieldName)) { + deserializedAzureMonitorWorkspaceSignalGroup.authenticationSetting = reader.getString(); + } else if ("azureMonitorWorkspaceResourceId".equals(fieldName)) { + deserializedAzureMonitorWorkspaceSignalGroup.azureMonitorWorkspaceResourceId = reader.getString(); + } else if ("signalAssignments".equals(fieldName)) { + List signalAssignments + = reader.readArray(reader1 -> SignalAssignment.fromJson(reader1)); + deserializedAzureMonitorWorkspaceSignalGroup.signalAssignments = signalAssignments; + } else { + reader.skipChildren(); + } + } + + return deserializedAzureMonitorWorkspaceSignalGroup; + }); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/AzureResourceSignalGroup.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/AzureResourceSignalGroup.java new file mode 100644 index 000000000000..41b6589e2b7f --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/AzureResourceSignalGroup.java @@ -0,0 +1,174 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * A grouping of signal assignments for an Azure resource. + */ +@Fluent +public final class AzureResourceSignalGroup implements JsonSerializable { + /* + * Signal definitions which are assigned to this signal group. All assignments are combined with an OR operator. + */ + private List signalAssignments; + + /* + * Reference to the name of the authentication setting which is used for querying the data source + */ + private String authenticationSetting; + + /* + * Azure resource ID + */ + private String azureResourceId; + + /** + * Creates an instance of AzureResourceSignalGroup class. + */ + public AzureResourceSignalGroup() { + } + + /** + * Get the signalAssignments property: Signal definitions which are assigned to this signal group. All assignments + * are combined with an OR operator. + * + * @return the signalAssignments value. + */ + public List signalAssignments() { + return this.signalAssignments; + } + + /** + * Set the signalAssignments property: Signal definitions which are assigned to this signal group. All assignments + * are combined with an OR operator. + * + * @param signalAssignments the signalAssignments value to set. + * @return the AzureResourceSignalGroup object itself. + */ + public AzureResourceSignalGroup withSignalAssignments(List signalAssignments) { + this.signalAssignments = signalAssignments; + return this; + } + + /** + * Get the authenticationSetting property: Reference to the name of the authentication setting which is used for + * querying the data source. + * + * @return the authenticationSetting value. + */ + public String authenticationSetting() { + return this.authenticationSetting; + } + + /** + * Set the authenticationSetting property: Reference to the name of the authentication setting which is used for + * querying the data source. + * + * @param authenticationSetting the authenticationSetting value to set. + * @return the AzureResourceSignalGroup object itself. + */ + public AzureResourceSignalGroup withAuthenticationSetting(String authenticationSetting) { + this.authenticationSetting = authenticationSetting; + return this; + } + + /** + * Get the azureResourceId property: Azure resource ID. + * + * @return the azureResourceId value. + */ + public String azureResourceId() { + return this.azureResourceId; + } + + /** + * Set the azureResourceId property: Azure resource ID. + * + * @param azureResourceId the azureResourceId value to set. + * @return the AzureResourceSignalGroup object itself. + */ + public AzureResourceSignalGroup withAzureResourceId(String azureResourceId) { + this.azureResourceId = azureResourceId; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (signalAssignments() != null) { + signalAssignments().forEach(e -> e.validate()); + } + if (authenticationSetting() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property authenticationSetting in model AzureResourceSignalGroup")); + } + if (azureResourceId() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property azureResourceId in model AzureResourceSignalGroup")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(AzureResourceSignalGroup.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("authenticationSetting", this.authenticationSetting); + jsonWriter.writeStringField("azureResourceId", this.azureResourceId); + jsonWriter.writeArrayField("signalAssignments", this.signalAssignments, + (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of AzureResourceSignalGroup from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of AzureResourceSignalGroup if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the AzureResourceSignalGroup. + */ + public static AzureResourceSignalGroup fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + AzureResourceSignalGroup deserializedAzureResourceSignalGroup = new AzureResourceSignalGroup(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("authenticationSetting".equals(fieldName)) { + deserializedAzureResourceSignalGroup.authenticationSetting = reader.getString(); + } else if ("azureResourceId".equals(fieldName)) { + deserializedAzureResourceSignalGroup.azureResourceId = reader.getString(); + } else if ("signalAssignments".equals(fieldName)) { + List signalAssignments + = reader.readArray(reader1 -> SignalAssignment.fromJson(reader1)); + deserializedAzureResourceSignalGroup.signalAssignments = signalAssignments; + } else { + reader.skipChildren(); + } + } + + return deserializedAzureResourceSignalGroup; + }); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/DependenciesAggregationType.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/DependenciesAggregationType.java new file mode 100644 index 000000000000..f1865a35e45b --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/DependenciesAggregationType.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Aggregation type for child dependencies. + */ +public final class DependenciesAggregationType extends ExpandableStringEnum { + /** + * Default behavior: Worst child health state is propagated. + */ + public static final DependenciesAggregationType WORST_OF = fromString("WorstOf"); + + /** + * Based on configurable thresholds. + */ + public static final DependenciesAggregationType THRESHOLDS = fromString("Thresholds"); + + /** + * Creates a new instance of DependenciesAggregationType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public DependenciesAggregationType() { + } + + /** + * Creates or finds a DependenciesAggregationType from its string representation. + * + * @param name a name to look for. + * @return the corresponding DependenciesAggregationType. + */ + public static DependenciesAggregationType fromString(String name) { + return fromString(name, DependenciesAggregationType.class); + } + + /** + * Gets known DependenciesAggregationType values. + * + * @return known DependenciesAggregationType values. + */ + public static Collection values() { + return values(DependenciesAggregationType.class); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/DependenciesSignalGroup.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/DependenciesSignalGroup.java new file mode 100644 index 000000000000..af174569562f --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/DependenciesSignalGroup.java @@ -0,0 +1,178 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Properties for dependent entities, i.e. child entities. + */ +@Fluent +public final class DependenciesSignalGroup implements JsonSerializable { + /* + * Aggregation type for child dependencies. + */ + private DependenciesAggregationType aggregationType; + + /* + * Degraded threshold for aggregating the propagated health state of child dependencies. Can be either an absolute + * number that is greater than 0, or a percentage between 1-100%. The entity will be considered degraded when the + * number of not healthy child dependents (unhealthy, degraded, unknown) is equal to or above the threshold value. + * Must only be set when AggregationType is 'Thresholds'. + */ + private String degradedThreshold; + + /* + * Unhealthy threshold for aggregating the propagated health state of child dependencies. Can be either an absolute + * number that is greater than 0, or a percentage between 1-100%. The entity will be considered unhealthy when the + * number of not healthy child dependents (unhealthy, degraded, unknown) is equal to or above the threshold value. + * Must only be set when AggregationType is 'Thresholds'. + */ + private String unhealthyThreshold; + + /** + * Creates an instance of DependenciesSignalGroup class. + */ + public DependenciesSignalGroup() { + } + + /** + * Get the aggregationType property: Aggregation type for child dependencies. + * + * @return the aggregationType value. + */ + public DependenciesAggregationType aggregationType() { + return this.aggregationType; + } + + /** + * Set the aggregationType property: Aggregation type for child dependencies. + * + * @param aggregationType the aggregationType value to set. + * @return the DependenciesSignalGroup object itself. + */ + public DependenciesSignalGroup withAggregationType(DependenciesAggregationType aggregationType) { + this.aggregationType = aggregationType; + return this; + } + + /** + * Get the degradedThreshold property: Degraded threshold for aggregating the propagated health state of child + * dependencies. Can be either an absolute number that is greater than 0, or a percentage between 1-100%. The entity + * will be considered degraded when the number of not healthy child dependents (unhealthy, degraded, unknown) is + * equal to or above the threshold value. Must only be set when AggregationType is 'Thresholds'. + * + * @return the degradedThreshold value. + */ + public String degradedThreshold() { + return this.degradedThreshold; + } + + /** + * Set the degradedThreshold property: Degraded threshold for aggregating the propagated health state of child + * dependencies. Can be either an absolute number that is greater than 0, or a percentage between 1-100%. The entity + * will be considered degraded when the number of not healthy child dependents (unhealthy, degraded, unknown) is + * equal to or above the threshold value. Must only be set when AggregationType is 'Thresholds'. + * + * @param degradedThreshold the degradedThreshold value to set. + * @return the DependenciesSignalGroup object itself. + */ + public DependenciesSignalGroup withDegradedThreshold(String degradedThreshold) { + this.degradedThreshold = degradedThreshold; + return this; + } + + /** + * Get the unhealthyThreshold property: Unhealthy threshold for aggregating the propagated health state of child + * dependencies. Can be either an absolute number that is greater than 0, or a percentage between 1-100%. The entity + * will be considered unhealthy when the number of not healthy child dependents (unhealthy, degraded, unknown) is + * equal to or above the threshold value. Must only be set when AggregationType is 'Thresholds'. + * + * @return the unhealthyThreshold value. + */ + public String unhealthyThreshold() { + return this.unhealthyThreshold; + } + + /** + * Set the unhealthyThreshold property: Unhealthy threshold for aggregating the propagated health state of child + * dependencies. Can be either an absolute number that is greater than 0, or a percentage between 1-100%. The entity + * will be considered unhealthy when the number of not healthy child dependents (unhealthy, degraded, unknown) is + * equal to or above the threshold value. Must only be set when AggregationType is 'Thresholds'. + * + * @param unhealthyThreshold the unhealthyThreshold value to set. + * @return the DependenciesSignalGroup object itself. + */ + public DependenciesSignalGroup withUnhealthyThreshold(String unhealthyThreshold) { + this.unhealthyThreshold = unhealthyThreshold; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (aggregationType() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property aggregationType in model DependenciesSignalGroup")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(DependenciesSignalGroup.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("aggregationType", + this.aggregationType == null ? null : this.aggregationType.toString()); + jsonWriter.writeStringField("degradedThreshold", this.degradedThreshold); + jsonWriter.writeStringField("unhealthyThreshold", this.unhealthyThreshold); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DependenciesSignalGroup from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DependenciesSignalGroup if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the DependenciesSignalGroup. + */ + public static DependenciesSignalGroup fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + DependenciesSignalGroup deserializedDependenciesSignalGroup = new DependenciesSignalGroup(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("aggregationType".equals(fieldName)) { + deserializedDependenciesSignalGroup.aggregationType + = DependenciesAggregationType.fromString(reader.getString()); + } else if ("degradedThreshold".equals(fieldName)) { + deserializedDependenciesSignalGroup.degradedThreshold = reader.getString(); + } else if ("unhealthyThreshold".equals(fieldName)) { + deserializedDependenciesSignalGroup.unhealthyThreshold = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedDependenciesSignalGroup; + }); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/DiscoveryRule.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/DiscoveryRule.java new file mode 100644 index 000000000000..6f54d0a852c3 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/DiscoveryRule.java @@ -0,0 +1,189 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.azure.resourcemanager.cloudhealth.fluent.models.DiscoveryRuleInner; + +/** + * An immutable client-side representation of DiscoveryRule. + */ +public interface DiscoveryRule { + /** + * Gets the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + String id(); + + /** + * Gets the name property: The name of the resource. + * + * @return the name value. + */ + String name(); + + /** + * Gets the type property: The type of the resource. + * + * @return the type value. + */ + String type(); + + /** + * Gets the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + DiscoveryRuleProperties properties(); + + /** + * Gets the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + SystemData systemData(); + + /** + * Gets the name of the resource group. + * + * @return the name of the resource group. + */ + String resourceGroupName(); + + /** + * Gets the inner com.azure.resourcemanager.cloudhealth.fluent.models.DiscoveryRuleInner object. + * + * @return the inner object. + */ + DiscoveryRuleInner innerModel(); + + /** + * The entirety of the DiscoveryRule definition. + */ + interface Definition + extends DefinitionStages.Blank, DefinitionStages.WithParentResource, DefinitionStages.WithCreate { + } + + /** + * The DiscoveryRule definition stages. + */ + interface DefinitionStages { + /** + * The first stage of the DiscoveryRule definition. + */ + interface Blank extends WithParentResource { + } + + /** + * The stage of the DiscoveryRule definition allowing to specify parent resource. + */ + interface WithParentResource { + /** + * Specifies resourceGroupName, healthModelName. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @return the next definition stage. + */ + WithCreate withExistingHealthmodel(String resourceGroupName, String healthModelName); + } + + /** + * The stage of the DiscoveryRule definition which contains all the minimum required properties for the resource + * to be created, but also allows for any other optional properties to be specified. + */ + interface WithCreate extends DefinitionStages.WithProperties { + /** + * Executes the create request. + * + * @return the created resource. + */ + DiscoveryRule create(); + + /** + * Executes the create request. + * + * @param context The context to associate with this operation. + * @return the created resource. + */ + DiscoveryRule create(Context context); + } + + /** + * The stage of the DiscoveryRule definition allowing to specify properties. + */ + interface WithProperties { + /** + * Specifies the properties property: The resource-specific properties for this resource.. + * + * @param properties The resource-specific properties for this resource. + * @return the next definition stage. + */ + WithCreate withProperties(DiscoveryRuleProperties properties); + } + } + + /** + * Begins update for the DiscoveryRule resource. + * + * @return the stage of resource update. + */ + DiscoveryRule.Update update(); + + /** + * The template for DiscoveryRule update. + */ + interface Update extends UpdateStages.WithProperties { + /** + * Executes the update request. + * + * @return the updated resource. + */ + DiscoveryRule apply(); + + /** + * Executes the update request. + * + * @param context The context to associate with this operation. + * @return the updated resource. + */ + DiscoveryRule apply(Context context); + } + + /** + * The DiscoveryRule update stages. + */ + interface UpdateStages { + /** + * The stage of the DiscoveryRule update allowing to specify properties. + */ + interface WithProperties { + /** + * Specifies the properties property: The resource-specific properties for this resource.. + * + * @param properties The resource-specific properties for this resource. + * @return the next definition stage. + */ + Update withProperties(DiscoveryRuleProperties properties); + } + } + + /** + * Refreshes the resource to sync with Azure. + * + * @return the refreshed resource. + */ + DiscoveryRule refresh(); + + /** + * Refreshes the resource to sync with Azure. + * + * @param context The context to associate with this operation. + * @return the refreshed resource. + */ + DiscoveryRule refresh(Context context); +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/DiscoveryRuleProperties.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/DiscoveryRuleProperties.java new file mode 100644 index 000000000000..e84c5dd7f658 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/DiscoveryRuleProperties.java @@ -0,0 +1,331 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; + +/** + * Discovery rule properties. + */ +@Fluent +public final class DiscoveryRuleProperties implements JsonSerializable { + /* + * The status of the last operation. + */ + private HealthModelProvisioningState provisioningState; + + /* + * Display name + */ + private String displayName; + + /* + * Azure Resource Graph query text in KQL syntax. The query must return at least a column named 'id' which contains + * the resource ID of the discovered resources. + */ + private String resourceGraphQuery; + + /* + * Reference to the name of the authentication setting which is used for querying Azure Resource Graph. The same + * authentication setting will also be assigned to any discovered entities. + */ + private String authenticationSetting; + + /* + * Whether to create relationships between the discovered entities based on a set of built-in rules. These + * relationships cannot be manually deleted. + */ + private DiscoveryRuleRelationshipDiscoveryBehavior discoverRelationships; + + /* + * Whether to add all recommended signals to the discovered entities. + */ + private DiscoveryRuleRecommendedSignalsBehavior addRecommendedSignals; + + /* + * Date when the discovery rule was (soft-)deleted. + */ + private OffsetDateTime deletionDate; + + /* + * Error message if the last discovery operation failed. + */ + private String errorMessage; + + /* + * Number of discovered entities in the last discovery operation. + */ + private Integer numberOfDiscoveredEntities; + + /* + * Name of the entity which represents the discovery rule. Note: It might take a few minutes after creating the + * discovery rule until the entity is created. + */ + private String entityName; + + /** + * Creates an instance of DiscoveryRuleProperties class. + */ + public DiscoveryRuleProperties() { + } + + /** + * Get the provisioningState property: The status of the last operation. + * + * @return the provisioningState value. + */ + public HealthModelProvisioningState provisioningState() { + return this.provisioningState; + } + + /** + * Get the displayName property: Display name. + * + * @return the displayName value. + */ + public String displayName() { + return this.displayName; + } + + /** + * Set the displayName property: Display name. + * + * @param displayName the displayName value to set. + * @return the DiscoveryRuleProperties object itself. + */ + public DiscoveryRuleProperties withDisplayName(String displayName) { + this.displayName = displayName; + return this; + } + + /** + * Get the resourceGraphQuery property: Azure Resource Graph query text in KQL syntax. The query must return at + * least a column named 'id' which contains the resource ID of the discovered resources. + * + * @return the resourceGraphQuery value. + */ + public String resourceGraphQuery() { + return this.resourceGraphQuery; + } + + /** + * Set the resourceGraphQuery property: Azure Resource Graph query text in KQL syntax. The query must return at + * least a column named 'id' which contains the resource ID of the discovered resources. + * + * @param resourceGraphQuery the resourceGraphQuery value to set. + * @return the DiscoveryRuleProperties object itself. + */ + public DiscoveryRuleProperties withResourceGraphQuery(String resourceGraphQuery) { + this.resourceGraphQuery = resourceGraphQuery; + return this; + } + + /** + * Get the authenticationSetting property: Reference to the name of the authentication setting which is used for + * querying Azure Resource Graph. The same authentication setting will also be assigned to any discovered entities. + * + * @return the authenticationSetting value. + */ + public String authenticationSetting() { + return this.authenticationSetting; + } + + /** + * Set the authenticationSetting property: Reference to the name of the authentication setting which is used for + * querying Azure Resource Graph. The same authentication setting will also be assigned to any discovered entities. + * + * @param authenticationSetting the authenticationSetting value to set. + * @return the DiscoveryRuleProperties object itself. + */ + public DiscoveryRuleProperties withAuthenticationSetting(String authenticationSetting) { + this.authenticationSetting = authenticationSetting; + return this; + } + + /** + * Get the discoverRelationships property: Whether to create relationships between the discovered entities based on + * a set of built-in rules. These relationships cannot be manually deleted. + * + * @return the discoverRelationships value. + */ + public DiscoveryRuleRelationshipDiscoveryBehavior discoverRelationships() { + return this.discoverRelationships; + } + + /** + * Set the discoverRelationships property: Whether to create relationships between the discovered entities based on + * a set of built-in rules. These relationships cannot be manually deleted. + * + * @param discoverRelationships the discoverRelationships value to set. + * @return the DiscoveryRuleProperties object itself. + */ + public DiscoveryRuleProperties + withDiscoverRelationships(DiscoveryRuleRelationshipDiscoveryBehavior discoverRelationships) { + this.discoverRelationships = discoverRelationships; + return this; + } + + /** + * Get the addRecommendedSignals property: Whether to add all recommended signals to the discovered entities. + * + * @return the addRecommendedSignals value. + */ + public DiscoveryRuleRecommendedSignalsBehavior addRecommendedSignals() { + return this.addRecommendedSignals; + } + + /** + * Set the addRecommendedSignals property: Whether to add all recommended signals to the discovered entities. + * + * @param addRecommendedSignals the addRecommendedSignals value to set. + * @return the DiscoveryRuleProperties object itself. + */ + public DiscoveryRuleProperties + withAddRecommendedSignals(DiscoveryRuleRecommendedSignalsBehavior addRecommendedSignals) { + this.addRecommendedSignals = addRecommendedSignals; + return this; + } + + /** + * Get the deletionDate property: Date when the discovery rule was (soft-)deleted. + * + * @return the deletionDate value. + */ + public OffsetDateTime deletionDate() { + return this.deletionDate; + } + + /** + * Get the errorMessage property: Error message if the last discovery operation failed. + * + * @return the errorMessage value. + */ + public String errorMessage() { + return this.errorMessage; + } + + /** + * Get the numberOfDiscoveredEntities property: Number of discovered entities in the last discovery operation. + * + * @return the numberOfDiscoveredEntities value. + */ + public Integer numberOfDiscoveredEntities() { + return this.numberOfDiscoveredEntities; + } + + /** + * Get the entityName property: Name of the entity which represents the discovery rule. Note: It might take a few + * minutes after creating the discovery rule until the entity is created. + * + * @return the entityName value. + */ + public String entityName() { + return this.entityName; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (resourceGraphQuery() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property resourceGraphQuery in model DiscoveryRuleProperties")); + } + if (authenticationSetting() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property authenticationSetting in model DiscoveryRuleProperties")); + } + if (discoverRelationships() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property discoverRelationships in model DiscoveryRuleProperties")); + } + if (addRecommendedSignals() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property addRecommendedSignals in model DiscoveryRuleProperties")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(DiscoveryRuleProperties.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("resourceGraphQuery", this.resourceGraphQuery); + jsonWriter.writeStringField("authenticationSetting", this.authenticationSetting); + jsonWriter.writeStringField("discoverRelationships", + this.discoverRelationships == null ? null : this.discoverRelationships.toString()); + jsonWriter.writeStringField("addRecommendedSignals", + this.addRecommendedSignals == null ? null : this.addRecommendedSignals.toString()); + jsonWriter.writeStringField("displayName", this.displayName); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DiscoveryRuleProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DiscoveryRuleProperties if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the DiscoveryRuleProperties. + */ + public static DiscoveryRuleProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + DiscoveryRuleProperties deserializedDiscoveryRuleProperties = new DiscoveryRuleProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("resourceGraphQuery".equals(fieldName)) { + deserializedDiscoveryRuleProperties.resourceGraphQuery = reader.getString(); + } else if ("authenticationSetting".equals(fieldName)) { + deserializedDiscoveryRuleProperties.authenticationSetting = reader.getString(); + } else if ("discoverRelationships".equals(fieldName)) { + deserializedDiscoveryRuleProperties.discoverRelationships + = DiscoveryRuleRelationshipDiscoveryBehavior.fromString(reader.getString()); + } else if ("addRecommendedSignals".equals(fieldName)) { + deserializedDiscoveryRuleProperties.addRecommendedSignals + = DiscoveryRuleRecommendedSignalsBehavior.fromString(reader.getString()); + } else if ("entityName".equals(fieldName)) { + deserializedDiscoveryRuleProperties.entityName = reader.getString(); + } else if ("provisioningState".equals(fieldName)) { + deserializedDiscoveryRuleProperties.provisioningState + = HealthModelProvisioningState.fromString(reader.getString()); + } else if ("displayName".equals(fieldName)) { + deserializedDiscoveryRuleProperties.displayName = reader.getString(); + } else if ("deletionDate".equals(fieldName)) { + deserializedDiscoveryRuleProperties.deletionDate = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else if ("errorMessage".equals(fieldName)) { + deserializedDiscoveryRuleProperties.errorMessage = reader.getString(); + } else if ("numberOfDiscoveredEntities".equals(fieldName)) { + deserializedDiscoveryRuleProperties.numberOfDiscoveredEntities + = reader.getNullable(JsonReader::getInt); + } else { + reader.skipChildren(); + } + } + + return deserializedDiscoveryRuleProperties; + }); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/DiscoveryRuleRecommendedSignalsBehavior.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/DiscoveryRuleRecommendedSignalsBehavior.java new file mode 100644 index 000000000000..dfbcfebd9b12 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/DiscoveryRuleRecommendedSignalsBehavior.java @@ -0,0 +1,52 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Discovery rule recommended signal behavior. + */ +public final class DiscoveryRuleRecommendedSignalsBehavior + extends ExpandableStringEnum { + /** + * Automatically add recommended signals. + */ + public static final DiscoveryRuleRecommendedSignalsBehavior ENABLED = fromString("Enabled"); + + /** + * Do not automatically add recommended signals. + */ + public static final DiscoveryRuleRecommendedSignalsBehavior DISABLED = fromString("Disabled"); + + /** + * Creates a new instance of DiscoveryRuleRecommendedSignalsBehavior value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public DiscoveryRuleRecommendedSignalsBehavior() { + } + + /** + * Creates or finds a DiscoveryRuleRecommendedSignalsBehavior from its string representation. + * + * @param name a name to look for. + * @return the corresponding DiscoveryRuleRecommendedSignalsBehavior. + */ + public static DiscoveryRuleRecommendedSignalsBehavior fromString(String name) { + return fromString(name, DiscoveryRuleRecommendedSignalsBehavior.class); + } + + /** + * Gets known DiscoveryRuleRecommendedSignalsBehavior values. + * + * @return known DiscoveryRuleRecommendedSignalsBehavior values. + */ + public static Collection values() { + return values(DiscoveryRuleRecommendedSignalsBehavior.class); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/DiscoveryRuleRelationshipDiscoveryBehavior.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/DiscoveryRuleRelationshipDiscoveryBehavior.java new file mode 100644 index 000000000000..3fdd73af7ef5 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/DiscoveryRuleRelationshipDiscoveryBehavior.java @@ -0,0 +1,52 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Discovery rule relationship discovery behavior. + */ +public final class DiscoveryRuleRelationshipDiscoveryBehavior + extends ExpandableStringEnum { + /** + * Automatically attempt to discover relationships. + */ + public static final DiscoveryRuleRelationshipDiscoveryBehavior ENABLED = fromString("Enabled"); + + /** + * Do not automatically attempt to discover relationships. + */ + public static final DiscoveryRuleRelationshipDiscoveryBehavior DISABLED = fromString("Disabled"); + + /** + * Creates a new instance of DiscoveryRuleRelationshipDiscoveryBehavior value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public DiscoveryRuleRelationshipDiscoveryBehavior() { + } + + /** + * Creates or finds a DiscoveryRuleRelationshipDiscoveryBehavior from its string representation. + * + * @param name a name to look for. + * @return the corresponding DiscoveryRuleRelationshipDiscoveryBehavior. + */ + public static DiscoveryRuleRelationshipDiscoveryBehavior fromString(String name) { + return fromString(name, DiscoveryRuleRelationshipDiscoveryBehavior.class); + } + + /** + * Gets known DiscoveryRuleRelationshipDiscoveryBehavior values. + * + * @return known DiscoveryRuleRelationshipDiscoveryBehavior values. + */ + public static Collection values() { + return values(DiscoveryRuleRelationshipDiscoveryBehavior.class); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/DiscoveryRules.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/DiscoveryRules.java new file mode 100644 index 000000000000..970367dbf33a --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/DiscoveryRules.java @@ -0,0 +1,151 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; +import java.time.OffsetDateTime; + +/** + * Resource collection API of DiscoveryRules. + */ +public interface DiscoveryRules { + /** + * Get a DiscoveryRule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param discoveryRuleName Name of the discovery rule. Must be unique within a health model. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a DiscoveryRule along with {@link Response}. + */ + Response getWithResponse(String resourceGroupName, String healthModelName, String discoveryRuleName, + Context context); + + /** + * Get a DiscoveryRule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param discoveryRuleName Name of the discovery rule. Must be unique within a health model. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a DiscoveryRule. + */ + DiscoveryRule get(String resourceGroupName, String healthModelName, String discoveryRuleName); + + /** + * Delete a DiscoveryRule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param discoveryRuleName Name of the discovery rule. Must be unique within a health model. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + Response deleteWithResponse(String resourceGroupName, String healthModelName, String discoveryRuleName, + Context context); + + /** + * Delete a DiscoveryRule. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param discoveryRuleName Name of the discovery rule. Must be unique within a health model. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void delete(String resourceGroupName, String healthModelName, String discoveryRuleName); + + /** + * List DiscoveryRule resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a DiscoveryRule list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable listByHealthModel(String resourceGroupName, String healthModelName); + + /** + * List DiscoveryRule resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param timestamp Timestamp to use for the operation. When specified, the version of the resource at this point in + * time is retrieved. If not specified, the latest version is used. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a DiscoveryRule list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable listByHealthModel(String resourceGroupName, String healthModelName, + OffsetDateTime timestamp, Context context); + + /** + * Get a DiscoveryRule. + * + * @param id the resource ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a DiscoveryRule along with {@link Response}. + */ + DiscoveryRule getById(String id); + + /** + * Get a DiscoveryRule. + * + * @param id the resource ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a DiscoveryRule along with {@link Response}. + */ + Response getByIdWithResponse(String id, Context context); + + /** + * Delete a DiscoveryRule. + * + * @param id the resource ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void deleteById(String id); + + /** + * Delete a DiscoveryRule. + * + * @param id the resource ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + Response deleteByIdWithResponse(String id, Context context); + + /** + * Begins definition for a new DiscoveryRule resource. + * + * @param name resource name. + * @return the first stage of the new DiscoveryRule definition. + */ + DiscoveryRule.DefinitionStages.Blank define(String name); +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/DynamicDetectionRule.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/DynamicDetectionRule.java new file mode 100644 index 000000000000..4ee48f530ef1 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/DynamicDetectionRule.java @@ -0,0 +1,204 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; + +/** + * ML-based evaluation rule for a signal definition. + */ +@Fluent +public final class DynamicDetectionRule implements JsonSerializable { + /* + * ML model to use for dynamic thresholds + */ + private DynamicThresholdModel dynamicThresholdModel; + + /* + * ML model sensitivity. Lowest value = high sensitivity. Supported step size = 0.5 + */ + private double modelSensitivity; + + /* + * Threshold direction + */ + private DynamicThresholdDirection dynamicThresholdDirection; + + /* + * Start time of the training in UTC. + */ + private OffsetDateTime trainingStartTime; + + /** + * Creates an instance of DynamicDetectionRule class. + */ + public DynamicDetectionRule() { + } + + /** + * Get the dynamicThresholdModel property: ML model to use for dynamic thresholds. + * + * @return the dynamicThresholdModel value. + */ + public DynamicThresholdModel dynamicThresholdModel() { + return this.dynamicThresholdModel; + } + + /** + * Set the dynamicThresholdModel property: ML model to use for dynamic thresholds. + * + * @param dynamicThresholdModel the dynamicThresholdModel value to set. + * @return the DynamicDetectionRule object itself. + */ + public DynamicDetectionRule withDynamicThresholdModel(DynamicThresholdModel dynamicThresholdModel) { + this.dynamicThresholdModel = dynamicThresholdModel; + return this; + } + + /** + * Get the modelSensitivity property: ML model sensitivity. Lowest value = high sensitivity. Supported step size = + * 0.5. + * + * @return the modelSensitivity value. + */ + public double modelSensitivity() { + return this.modelSensitivity; + } + + /** + * Set the modelSensitivity property: ML model sensitivity. Lowest value = high sensitivity. Supported step size = + * 0.5. + * + * @param modelSensitivity the modelSensitivity value to set. + * @return the DynamicDetectionRule object itself. + */ + public DynamicDetectionRule withModelSensitivity(double modelSensitivity) { + this.modelSensitivity = modelSensitivity; + return this; + } + + /** + * Get the dynamicThresholdDirection property: Threshold direction. + * + * @return the dynamicThresholdDirection value. + */ + public DynamicThresholdDirection dynamicThresholdDirection() { + return this.dynamicThresholdDirection; + } + + /** + * Set the dynamicThresholdDirection property: Threshold direction. + * + * @param dynamicThresholdDirection the dynamicThresholdDirection value to set. + * @return the DynamicDetectionRule object itself. + */ + public DynamicDetectionRule withDynamicThresholdDirection(DynamicThresholdDirection dynamicThresholdDirection) { + this.dynamicThresholdDirection = dynamicThresholdDirection; + return this; + } + + /** + * Get the trainingStartTime property: Start time of the training in UTC. + * + * @return the trainingStartTime value. + */ + public OffsetDateTime trainingStartTime() { + return this.trainingStartTime; + } + + /** + * Set the trainingStartTime property: Start time of the training in UTC. + * + * @param trainingStartTime the trainingStartTime value to set. + * @return the DynamicDetectionRule object itself. + */ + public DynamicDetectionRule withTrainingStartTime(OffsetDateTime trainingStartTime) { + this.trainingStartTime = trainingStartTime; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (dynamicThresholdModel() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property dynamicThresholdModel in model DynamicDetectionRule")); + } + if (dynamicThresholdDirection() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property dynamicThresholdDirection in model DynamicDetectionRule")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(DynamicDetectionRule.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("dynamicThresholdModel", + this.dynamicThresholdModel == null ? null : this.dynamicThresholdModel.toString()); + jsonWriter.writeDoubleField("modelSensitivity", this.modelSensitivity); + jsonWriter.writeStringField("dynamicThresholdDirection", + this.dynamicThresholdDirection == null ? null : this.dynamicThresholdDirection.toString()); + jsonWriter.writeStringField("trainingStartTime", + this.trainingStartTime == null + ? null + : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.trainingStartTime)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DynamicDetectionRule from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DynamicDetectionRule if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the DynamicDetectionRule. + */ + public static DynamicDetectionRule fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + DynamicDetectionRule deserializedDynamicDetectionRule = new DynamicDetectionRule(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("dynamicThresholdModel".equals(fieldName)) { + deserializedDynamicDetectionRule.dynamicThresholdModel + = DynamicThresholdModel.fromString(reader.getString()); + } else if ("modelSensitivity".equals(fieldName)) { + deserializedDynamicDetectionRule.modelSensitivity = reader.getDouble(); + } else if ("dynamicThresholdDirection".equals(fieldName)) { + deserializedDynamicDetectionRule.dynamicThresholdDirection + = DynamicThresholdDirection.fromString(reader.getString()); + } else if ("trainingStartTime".equals(fieldName)) { + deserializedDynamicDetectionRule.trainingStartTime = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else { + reader.skipChildren(); + } + } + + return deserializedDynamicDetectionRule; + }); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/DynamicThresholdDirection.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/DynamicThresholdDirection.java new file mode 100644 index 000000000000..8955e93a2ea6 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/DynamicThresholdDirection.java @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Threshold direction for dynamic thresholds. + */ +public final class DynamicThresholdDirection extends ExpandableStringEnum { + /** + * Lower than. + */ + public static final DynamicThresholdDirection LOWER_THAN = fromString("LowerThan"); + + /** + * Greater than. + */ + public static final DynamicThresholdDirection GREATER_THAN = fromString("GreaterThan"); + + /** + * Greater or Lower Than. + */ + public static final DynamicThresholdDirection GREATER_OR_LOWER_THAN = fromString("GreaterOrLowerThan"); + + /** + * Creates a new instance of DynamicThresholdDirection value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public DynamicThresholdDirection() { + } + + /** + * Creates or finds a DynamicThresholdDirection from its string representation. + * + * @param name a name to look for. + * @return the corresponding DynamicThresholdDirection. + */ + public static DynamicThresholdDirection fromString(String name) { + return fromString(name, DynamicThresholdDirection.class); + } + + /** + * Gets known DynamicThresholdDirection values. + * + * @return known DynamicThresholdDirection values. + */ + public static Collection values() { + return values(DynamicThresholdDirection.class); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/DynamicThresholdModel.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/DynamicThresholdModel.java new file mode 100644 index 000000000000..228504daf4a9 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/DynamicThresholdModel.java @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * ML-based model variants. + */ +public final class DynamicThresholdModel extends ExpandableStringEnum { + /** + * Anomaly detection model. + */ + public static final DynamicThresholdModel ANOMALY_DETECTION = fromString("AnomalyDetection"); + + /** + * Creates a new instance of DynamicThresholdModel value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public DynamicThresholdModel() { + } + + /** + * Creates or finds a DynamicThresholdModel from its string representation. + * + * @param name a name to look for. + * @return the corresponding DynamicThresholdModel. + */ + public static DynamicThresholdModel fromString(String name) { + return fromString(name, DynamicThresholdModel.class); + } + + /** + * Gets known DynamicThresholdModel values. + * + * @return known DynamicThresholdModel values. + */ + public static Collection values() { + return values(DynamicThresholdModel.class); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/Entities.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/Entities.java new file mode 100644 index 000000000000..c0a3e12a07be --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/Entities.java @@ -0,0 +1,151 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; +import java.time.OffsetDateTime; + +/** + * Resource collection API of Entities. + */ +public interface Entities { + /** + * Get a Entity. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param entityName Name of the entity. Must be unique within a health model. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Entity along with {@link Response}. + */ + Response getWithResponse(String resourceGroupName, String healthModelName, String entityName, + Context context); + + /** + * Get a Entity. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param entityName Name of the entity. Must be unique within a health model. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Entity. + */ + Entity get(String resourceGroupName, String healthModelName, String entityName); + + /** + * Delete a Entity. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param entityName Name of the entity. Must be unique within a health model. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + Response deleteWithResponse(String resourceGroupName, String healthModelName, String entityName, + Context context); + + /** + * Delete a Entity. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param entityName Name of the entity. Must be unique within a health model. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void delete(String resourceGroupName, String healthModelName, String entityName); + + /** + * List Entity resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Entity list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable listByHealthModel(String resourceGroupName, String healthModelName); + + /** + * List Entity resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param timestamp Timestamp to use for the operation. When specified, the version of the resource at this point in + * time is retrieved. If not specified, the latest version is used. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Entity list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable listByHealthModel(String resourceGroupName, String healthModelName, OffsetDateTime timestamp, + Context context); + + /** + * Get a Entity. + * + * @param id the resource ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Entity along with {@link Response}. + */ + Entity getById(String id); + + /** + * Get a Entity. + * + * @param id the resource ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Entity along with {@link Response}. + */ + Response getByIdWithResponse(String id, Context context); + + /** + * Delete a Entity. + * + * @param id the resource ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void deleteById(String id); + + /** + * Delete a Entity. + * + * @param id the resource ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + Response deleteByIdWithResponse(String id, Context context); + + /** + * Begins definition for a new Entity resource. + * + * @param name resource name. + * @return the first stage of the new Entity definition. + */ + Entity.DefinitionStages.Blank define(String name); +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/Entity.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/Entity.java new file mode 100644 index 000000000000..510d57d9a32e --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/Entity.java @@ -0,0 +1,189 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.azure.resourcemanager.cloudhealth.fluent.models.EntityInner; + +/** + * An immutable client-side representation of Entity. + */ +public interface Entity { + /** + * Gets the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + String id(); + + /** + * Gets the name property: The name of the resource. + * + * @return the name value. + */ + String name(); + + /** + * Gets the type property: The type of the resource. + * + * @return the type value. + */ + String type(); + + /** + * Gets the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + EntityProperties properties(); + + /** + * Gets the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + SystemData systemData(); + + /** + * Gets the name of the resource group. + * + * @return the name of the resource group. + */ + String resourceGroupName(); + + /** + * Gets the inner com.azure.resourcemanager.cloudhealth.fluent.models.EntityInner object. + * + * @return the inner object. + */ + EntityInner innerModel(); + + /** + * The entirety of the Entity definition. + */ + interface Definition + extends DefinitionStages.Blank, DefinitionStages.WithParentResource, DefinitionStages.WithCreate { + } + + /** + * The Entity definition stages. + */ + interface DefinitionStages { + /** + * The first stage of the Entity definition. + */ + interface Blank extends WithParentResource { + } + + /** + * The stage of the Entity definition allowing to specify parent resource. + */ + interface WithParentResource { + /** + * Specifies resourceGroupName, healthModelName. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @return the next definition stage. + */ + WithCreate withExistingHealthmodel(String resourceGroupName, String healthModelName); + } + + /** + * The stage of the Entity definition which contains all the minimum required properties for the resource to be + * created, but also allows for any other optional properties to be specified. + */ + interface WithCreate extends DefinitionStages.WithProperties { + /** + * Executes the create request. + * + * @return the created resource. + */ + Entity create(); + + /** + * Executes the create request. + * + * @param context The context to associate with this operation. + * @return the created resource. + */ + Entity create(Context context); + } + + /** + * The stage of the Entity definition allowing to specify properties. + */ + interface WithProperties { + /** + * Specifies the properties property: The resource-specific properties for this resource.. + * + * @param properties The resource-specific properties for this resource. + * @return the next definition stage. + */ + WithCreate withProperties(EntityProperties properties); + } + } + + /** + * Begins update for the Entity resource. + * + * @return the stage of resource update. + */ + Entity.Update update(); + + /** + * The template for Entity update. + */ + interface Update extends UpdateStages.WithProperties { + /** + * Executes the update request. + * + * @return the updated resource. + */ + Entity apply(); + + /** + * Executes the update request. + * + * @param context The context to associate with this operation. + * @return the updated resource. + */ + Entity apply(Context context); + } + + /** + * The Entity update stages. + */ + interface UpdateStages { + /** + * The stage of the Entity update allowing to specify properties. + */ + interface WithProperties { + /** + * Specifies the properties property: The resource-specific properties for this resource.. + * + * @param properties The resource-specific properties for this resource. + * @return the next definition stage. + */ + Update withProperties(EntityProperties properties); + } + } + + /** + * Refreshes the resource to sync with Azure. + * + * @return the refreshed resource. + */ + Entity refresh(); + + /** + * Refreshes the resource to sync with Azure. + * + * @param context The context to associate with this operation. + * @return the refreshed resource. + */ + Entity refresh(Context context); +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/EntityAlerts.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/EntityAlerts.java new file mode 100644 index 000000000000..92e239259b56 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/EntityAlerts.java @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Alert configuration for an entity. + */ +@Fluent +public final class EntityAlerts implements JsonSerializable { + /* + * Alert to be triggered on state change to unhealthy + */ + private AlertConfiguration unhealthy; + + /* + * Alert to be triggered on state change to degraded + */ + private AlertConfiguration degraded; + + /** + * Creates an instance of EntityAlerts class. + */ + public EntityAlerts() { + } + + /** + * Get the unhealthy property: Alert to be triggered on state change to unhealthy. + * + * @return the unhealthy value. + */ + public AlertConfiguration unhealthy() { + return this.unhealthy; + } + + /** + * Set the unhealthy property: Alert to be triggered on state change to unhealthy. + * + * @param unhealthy the unhealthy value to set. + * @return the EntityAlerts object itself. + */ + public EntityAlerts withUnhealthy(AlertConfiguration unhealthy) { + this.unhealthy = unhealthy; + return this; + } + + /** + * Get the degraded property: Alert to be triggered on state change to degraded. + * + * @return the degraded value. + */ + public AlertConfiguration degraded() { + return this.degraded; + } + + /** + * Set the degraded property: Alert to be triggered on state change to degraded. + * + * @param degraded the degraded value to set. + * @return the EntityAlerts object itself. + */ + public EntityAlerts withDegraded(AlertConfiguration degraded) { + this.degraded = degraded; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (unhealthy() != null) { + unhealthy().validate(); + } + if (degraded() != null) { + degraded().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("unhealthy", this.unhealthy); + jsonWriter.writeJsonField("degraded", this.degraded); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of EntityAlerts from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of EntityAlerts if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the EntityAlerts. + */ + public static EntityAlerts fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + EntityAlerts deserializedEntityAlerts = new EntityAlerts(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("unhealthy".equals(fieldName)) { + deserializedEntityAlerts.unhealthy = AlertConfiguration.fromJson(reader); + } else if ("degraded".equals(fieldName)) { + deserializedEntityAlerts.degraded = AlertConfiguration.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedEntityAlerts; + }); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/EntityCoordinates.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/EntityCoordinates.java new file mode 100644 index 000000000000..bcd5fb1df71b --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/EntityCoordinates.java @@ -0,0 +1,122 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Visual position of the entity. + */ +@Fluent +public final class EntityCoordinates implements JsonSerializable { + /* + * X Coordinate + */ + private double x; + + /* + * Y Coordinate + */ + private double y; + + /** + * Creates an instance of EntityCoordinates class. + */ + public EntityCoordinates() { + } + + /** + * Get the x property: X Coordinate. + * + * @return the x value. + */ + public double x() { + return this.x; + } + + /** + * Set the x property: X Coordinate. + * + * @param x the x value to set. + * @return the EntityCoordinates object itself. + */ + public EntityCoordinates withX(double x) { + this.x = x; + return this; + } + + /** + * Get the y property: Y Coordinate. + * + * @return the y value. + */ + public double y() { + return this.y; + } + + /** + * Set the y property: Y Coordinate. + * + * @param y the y value to set. + * @return the EntityCoordinates object itself. + */ + public EntityCoordinates withY(double y) { + this.y = y; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeDoubleField("x", this.x); + jsonWriter.writeDoubleField("y", this.y); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of EntityCoordinates from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of EntityCoordinates if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the EntityCoordinates. + */ + public static EntityCoordinates fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + EntityCoordinates deserializedEntityCoordinates = new EntityCoordinates(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("x".equals(fieldName)) { + deserializedEntityCoordinates.x = reader.getDouble(); + } else if ("y".equals(fieldName)) { + deserializedEntityCoordinates.y = reader.getDouble(); + } else { + reader.skipChildren(); + } + } + + return deserializedEntityCoordinates; + }); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/EntityImpact.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/EntityImpact.java new file mode 100644 index 000000000000..4d9313b8d65e --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/EntityImpact.java @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Type of impact an entity has on health state propagation. + */ +public final class EntityImpact extends ExpandableStringEnum { + /** + * Standard impact. + */ + public static final EntityImpact STANDARD = fromString("Standard"); + + /** + * Limited impact. + */ + public static final EntityImpact LIMITED = fromString("Limited"); + + /** + * Suppressed impact. + */ + public static final EntityImpact SUPPRESSED = fromString("Suppressed"); + + /** + * Creates a new instance of EntityImpact value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public EntityImpact() { + } + + /** + * Creates or finds a EntityImpact from its string representation. + * + * @param name a name to look for. + * @return the corresponding EntityImpact. + */ + public static EntityImpact fromString(String name) { + return fromString(name, EntityImpact.class); + } + + /** + * Gets known EntityImpact values. + * + * @return known EntityImpact values. + */ + public static Collection values() { + return values(EntityImpact.class); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/EntityProperties.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/EntityProperties.java new file mode 100644 index 000000000000..60443651e6ca --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/EntityProperties.java @@ -0,0 +1,399 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.CoreUtils; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.Map; + +/** + * Properties which are common across all kinds of entities. + */ +@Fluent +public final class EntityProperties implements JsonSerializable { + /* + * The status of the last operation. + */ + private HealthModelProvisioningState provisioningState; + + /* + * Display name + */ + private String displayName; + + /* + * Entity kind + */ + private String kind; + + /* + * Positioning of the entity on the model canvas + */ + private EntityCoordinates canvasPosition; + + /* + * Visual icon definition. If not set, a default icon is used. + */ + private IconDefinition icon; + + /* + * Health objective as a percentage of time the entity should be healthy. + */ + private Double healthObjective; + + /* + * Impact of the entity in health state propagation + */ + private EntityImpact impact; + + /* + * Optional set of labels (key-value pairs) + */ + private Map labels; + + /* + * Signal groups which are assigned to this entity + */ + private SignalGroup signals; + + /* + * Discovered by which discovery rule. If set, the entity cannot be deleted manually. + */ + private String discoveredBy; + + /* + * Date when the entity was (soft-)deleted + */ + private OffsetDateTime deletionDate; + + /* + * Health state of this entity + */ + private HealthState healthState; + + /* + * Alert configuration for this entity + */ + private EntityAlerts alerts; + + /** + * Creates an instance of EntityProperties class. + */ + public EntityProperties() { + } + + /** + * Get the provisioningState property: The status of the last operation. + * + * @return the provisioningState value. + */ + public HealthModelProvisioningState provisioningState() { + return this.provisioningState; + } + + /** + * Get the displayName property: Display name. + * + * @return the displayName value. + */ + public String displayName() { + return this.displayName; + } + + /** + * Set the displayName property: Display name. + * + * @param displayName the displayName value to set. + * @return the EntityProperties object itself. + */ + public EntityProperties withDisplayName(String displayName) { + this.displayName = displayName; + return this; + } + + /** + * Get the kind property: Entity kind. + * + * @return the kind value. + */ + public String kind() { + return this.kind; + } + + /** + * Set the kind property: Entity kind. + * + * @param kind the kind value to set. + * @return the EntityProperties object itself. + */ + public EntityProperties withKind(String kind) { + this.kind = kind; + return this; + } + + /** + * Get the canvasPosition property: Positioning of the entity on the model canvas. + * + * @return the canvasPosition value. + */ + public EntityCoordinates canvasPosition() { + return this.canvasPosition; + } + + /** + * Set the canvasPosition property: Positioning of the entity on the model canvas. + * + * @param canvasPosition the canvasPosition value to set. + * @return the EntityProperties object itself. + */ + public EntityProperties withCanvasPosition(EntityCoordinates canvasPosition) { + this.canvasPosition = canvasPosition; + return this; + } + + /** + * Get the icon property: Visual icon definition. If not set, a default icon is used. + * + * @return the icon value. + */ + public IconDefinition icon() { + return this.icon; + } + + /** + * Set the icon property: Visual icon definition. If not set, a default icon is used. + * + * @param icon the icon value to set. + * @return the EntityProperties object itself. + */ + public EntityProperties withIcon(IconDefinition icon) { + this.icon = icon; + return this; + } + + /** + * Get the healthObjective property: Health objective as a percentage of time the entity should be healthy. + * + * @return the healthObjective value. + */ + public Double healthObjective() { + return this.healthObjective; + } + + /** + * Set the healthObjective property: Health objective as a percentage of time the entity should be healthy. + * + * @param healthObjective the healthObjective value to set. + * @return the EntityProperties object itself. + */ + public EntityProperties withHealthObjective(Double healthObjective) { + this.healthObjective = healthObjective; + return this; + } + + /** + * Get the impact property: Impact of the entity in health state propagation. + * + * @return the impact value. + */ + public EntityImpact impact() { + return this.impact; + } + + /** + * Set the impact property: Impact of the entity in health state propagation. + * + * @param impact the impact value to set. + * @return the EntityProperties object itself. + */ + public EntityProperties withImpact(EntityImpact impact) { + this.impact = impact; + return this; + } + + /** + * Get the labels property: Optional set of labels (key-value pairs). + * + * @return the labels value. + */ + public Map labels() { + return this.labels; + } + + /** + * Set the labels property: Optional set of labels (key-value pairs). + * + * @param labels the labels value to set. + * @return the EntityProperties object itself. + */ + public EntityProperties withLabels(Map labels) { + this.labels = labels; + return this; + } + + /** + * Get the signals property: Signal groups which are assigned to this entity. + * + * @return the signals value. + */ + public SignalGroup signals() { + return this.signals; + } + + /** + * Set the signals property: Signal groups which are assigned to this entity. + * + * @param signals the signals value to set. + * @return the EntityProperties object itself. + */ + public EntityProperties withSignals(SignalGroup signals) { + this.signals = signals; + return this; + } + + /** + * Get the discoveredBy property: Discovered by which discovery rule. If set, the entity cannot be deleted manually. + * + * @return the discoveredBy value. + */ + public String discoveredBy() { + return this.discoveredBy; + } + + /** + * Get the deletionDate property: Date when the entity was (soft-)deleted. + * + * @return the deletionDate value. + */ + public OffsetDateTime deletionDate() { + return this.deletionDate; + } + + /** + * Get the healthState property: Health state of this entity. + * + * @return the healthState value. + */ + public HealthState healthState() { + return this.healthState; + } + + /** + * Get the alerts property: Alert configuration for this entity. + * + * @return the alerts value. + */ + public EntityAlerts alerts() { + return this.alerts; + } + + /** + * Set the alerts property: Alert configuration for this entity. + * + * @param alerts the alerts value to set. + * @return the EntityProperties object itself. + */ + public EntityProperties withAlerts(EntityAlerts alerts) { + this.alerts = alerts; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (canvasPosition() != null) { + canvasPosition().validate(); + } + if (icon() != null) { + icon().validate(); + } + if (signals() != null) { + signals().validate(); + } + if (alerts() != null) { + alerts().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("displayName", this.displayName); + jsonWriter.writeStringField("kind", this.kind); + jsonWriter.writeJsonField("canvasPosition", this.canvasPosition); + jsonWriter.writeJsonField("icon", this.icon); + jsonWriter.writeNumberField("healthObjective", this.healthObjective); + jsonWriter.writeStringField("impact", this.impact == null ? null : this.impact.toString()); + jsonWriter.writeMapField("labels", this.labels, (writer, element) -> writer.writeString(element)); + jsonWriter.writeJsonField("signals", this.signals); + jsonWriter.writeJsonField("alerts", this.alerts); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of EntityProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of EntityProperties if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the EntityProperties. + */ + public static EntityProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + EntityProperties deserializedEntityProperties = new EntityProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("provisioningState".equals(fieldName)) { + deserializedEntityProperties.provisioningState + = HealthModelProvisioningState.fromString(reader.getString()); + } else if ("displayName".equals(fieldName)) { + deserializedEntityProperties.displayName = reader.getString(); + } else if ("kind".equals(fieldName)) { + deserializedEntityProperties.kind = reader.getString(); + } else if ("canvasPosition".equals(fieldName)) { + deserializedEntityProperties.canvasPosition = EntityCoordinates.fromJson(reader); + } else if ("icon".equals(fieldName)) { + deserializedEntityProperties.icon = IconDefinition.fromJson(reader); + } else if ("healthObjective".equals(fieldName)) { + deserializedEntityProperties.healthObjective = reader.getNullable(JsonReader::getDouble); + } else if ("impact".equals(fieldName)) { + deserializedEntityProperties.impact = EntityImpact.fromString(reader.getString()); + } else if ("labels".equals(fieldName)) { + Map labels = reader.readMap(reader1 -> reader1.getString()); + deserializedEntityProperties.labels = labels; + } else if ("signals".equals(fieldName)) { + deserializedEntityProperties.signals = SignalGroup.fromJson(reader); + } else if ("discoveredBy".equals(fieldName)) { + deserializedEntityProperties.discoveredBy = reader.getString(); + } else if ("deletionDate".equals(fieldName)) { + deserializedEntityProperties.deletionDate = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else if ("healthState".equals(fieldName)) { + deserializedEntityProperties.healthState = HealthState.fromString(reader.getString()); + } else if ("alerts".equals(fieldName)) { + deserializedEntityProperties.alerts = EntityAlerts.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedEntityProperties; + }); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/EvaluationRule.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/EvaluationRule.java new file mode 100644 index 000000000000..55981ef497b5 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/EvaluationRule.java @@ -0,0 +1,164 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Evaluation rule for a signal definition. + */ +@Fluent +public final class EvaluationRule implements JsonSerializable { + /* + * Configure to use ML-based dynamic thresholds. When used, degradedRule and unhealthyRule must not be set. + */ + private DynamicDetectionRule dynamicDetectionRule; + + /* + * Degraded rule with static threshold. When used, dynamicDetectionRule must not be set. + */ + private ThresholdRule degradedRule; + + /* + * Unhealthy rule with static threshold. When used, dynamicDetectionRule must not be set. + */ + private ThresholdRule unhealthyRule; + + /** + * Creates an instance of EvaluationRule class. + */ + public EvaluationRule() { + } + + /** + * Get the dynamicDetectionRule property: Configure to use ML-based dynamic thresholds. When used, degradedRule and + * unhealthyRule must not be set. + * + * @return the dynamicDetectionRule value. + */ + public DynamicDetectionRule dynamicDetectionRule() { + return this.dynamicDetectionRule; + } + + /** + * Set the dynamicDetectionRule property: Configure to use ML-based dynamic thresholds. When used, degradedRule and + * unhealthyRule must not be set. + * + * @param dynamicDetectionRule the dynamicDetectionRule value to set. + * @return the EvaluationRule object itself. + */ + public EvaluationRule withDynamicDetectionRule(DynamicDetectionRule dynamicDetectionRule) { + this.dynamicDetectionRule = dynamicDetectionRule; + return this; + } + + /** + * Get the degradedRule property: Degraded rule with static threshold. When used, dynamicDetectionRule must not be + * set. + * + * @return the degradedRule value. + */ + public ThresholdRule degradedRule() { + return this.degradedRule; + } + + /** + * Set the degradedRule property: Degraded rule with static threshold. When used, dynamicDetectionRule must not be + * set. + * + * @param degradedRule the degradedRule value to set. + * @return the EvaluationRule object itself. + */ + public EvaluationRule withDegradedRule(ThresholdRule degradedRule) { + this.degradedRule = degradedRule; + return this; + } + + /** + * Get the unhealthyRule property: Unhealthy rule with static threshold. When used, dynamicDetectionRule must not be + * set. + * + * @return the unhealthyRule value. + */ + public ThresholdRule unhealthyRule() { + return this.unhealthyRule; + } + + /** + * Set the unhealthyRule property: Unhealthy rule with static threshold. When used, dynamicDetectionRule must not be + * set. + * + * @param unhealthyRule the unhealthyRule value to set. + * @return the EvaluationRule object itself. + */ + public EvaluationRule withUnhealthyRule(ThresholdRule unhealthyRule) { + this.unhealthyRule = unhealthyRule; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (dynamicDetectionRule() != null) { + dynamicDetectionRule().validate(); + } + if (degradedRule() != null) { + degradedRule().validate(); + } + if (unhealthyRule() != null) { + unhealthyRule().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("dynamicDetectionRule", this.dynamicDetectionRule); + jsonWriter.writeJsonField("degradedRule", this.degradedRule); + jsonWriter.writeJsonField("unhealthyRule", this.unhealthyRule); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of EvaluationRule from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of EvaluationRule if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the EvaluationRule. + */ + public static EvaluationRule fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + EvaluationRule deserializedEvaluationRule = new EvaluationRule(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("dynamicDetectionRule".equals(fieldName)) { + deserializedEvaluationRule.dynamicDetectionRule = DynamicDetectionRule.fromJson(reader); + } else if ("degradedRule".equals(fieldName)) { + deserializedEvaluationRule.degradedRule = ThresholdRule.fromJson(reader); + } else if ("unhealthyRule".equals(fieldName)) { + deserializedEvaluationRule.unhealthyRule = ThresholdRule.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedEvaluationRule; + }); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/HealthModel.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/HealthModel.java new file mode 100644 index 000000000000..f4293381c63f --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/HealthModel.java @@ -0,0 +1,299 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.management.Region; +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.azure.resourcemanager.cloudhealth.fluent.models.HealthModelInner; +import java.util.Map; + +/** + * An immutable client-side representation of HealthModel. + */ +public interface HealthModel { + /** + * Gets the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + String id(); + + /** + * Gets the name property: The name of the resource. + * + * @return the name value. + */ + String name(); + + /** + * Gets the type property: The type of the resource. + * + * @return the type value. + */ + String type(); + + /** + * Gets the location property: The geo-location where the resource lives. + * + * @return the location value. + */ + String location(); + + /** + * Gets the tags property: Resource tags. + * + * @return the tags value. + */ + Map tags(); + + /** + * Gets the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + HealthModelProperties properties(); + + /** + * Gets the identity property: The managed service identities assigned to this resource. + * + * @return the identity value. + */ + ManagedServiceIdentity identity(); + + /** + * Gets the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + SystemData systemData(); + + /** + * Gets the region of the resource. + * + * @return the region of the resource. + */ + Region region(); + + /** + * Gets the name of the resource region. + * + * @return the name of the resource region. + */ + String regionName(); + + /** + * Gets the name of the resource group. + * + * @return the name of the resource group. + */ + String resourceGroupName(); + + /** + * Gets the inner com.azure.resourcemanager.cloudhealth.fluent.models.HealthModelInner object. + * + * @return the inner object. + */ + HealthModelInner innerModel(); + + /** + * The entirety of the HealthModel definition. + */ + interface Definition extends DefinitionStages.Blank, DefinitionStages.WithLocation, + DefinitionStages.WithResourceGroup, DefinitionStages.WithCreate { + } + + /** + * The HealthModel definition stages. + */ + interface DefinitionStages { + /** + * The first stage of the HealthModel definition. + */ + interface Blank extends WithLocation { + } + + /** + * The stage of the HealthModel definition allowing to specify location. + */ + interface WithLocation { + /** + * Specifies the region for the resource. + * + * @param location The geo-location where the resource lives. + * @return the next definition stage. + */ + WithResourceGroup withRegion(Region location); + + /** + * Specifies the region for the resource. + * + * @param location The geo-location where the resource lives. + * @return the next definition stage. + */ + WithResourceGroup withRegion(String location); + } + + /** + * The stage of the HealthModel definition allowing to specify parent resource. + */ + interface WithResourceGroup { + /** + * Specifies resourceGroupName. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @return the next definition stage. + */ + WithCreate withExistingResourceGroup(String resourceGroupName); + } + + /** + * The stage of the HealthModel definition which contains all the minimum required properties for the resource + * to be created, but also allows for any other optional properties to be specified. + */ + interface WithCreate + extends DefinitionStages.WithTags, DefinitionStages.WithProperties, DefinitionStages.WithIdentity { + /** + * Executes the create request. + * + * @return the created resource. + */ + HealthModel create(); + + /** + * Executes the create request. + * + * @param context The context to associate with this operation. + * @return the created resource. + */ + HealthModel create(Context context); + } + + /** + * The stage of the HealthModel definition allowing to specify tags. + */ + interface WithTags { + /** + * Specifies the tags property: Resource tags.. + * + * @param tags Resource tags. + * @return the next definition stage. + */ + WithCreate withTags(Map tags); + } + + /** + * The stage of the HealthModel definition allowing to specify properties. + */ + interface WithProperties { + /** + * Specifies the properties property: The resource-specific properties for this resource.. + * + * @param properties The resource-specific properties for this resource. + * @return the next definition stage. + */ + WithCreate withProperties(HealthModelProperties properties); + } + + /** + * The stage of the HealthModel definition allowing to specify identity. + */ + interface WithIdentity { + /** + * Specifies the identity property: The managed service identities assigned to this resource.. + * + * @param identity The managed service identities assigned to this resource. + * @return the next definition stage. + */ + WithCreate withIdentity(ManagedServiceIdentity identity); + } + } + + /** + * Begins update for the HealthModel resource. + * + * @return the stage of resource update. + */ + HealthModel.Update update(); + + /** + * The template for HealthModel update. + */ + interface Update extends UpdateStages.WithTags, UpdateStages.WithIdentity, UpdateStages.WithProperties { + /** + * Executes the update request. + * + * @return the updated resource. + */ + HealthModel apply(); + + /** + * Executes the update request. + * + * @param context The context to associate with this operation. + * @return the updated resource. + */ + HealthModel apply(Context context); + } + + /** + * The HealthModel update stages. + */ + interface UpdateStages { + /** + * The stage of the HealthModel update allowing to specify tags. + */ + interface WithTags { + /** + * Specifies the tags property: Resource tags.. + * + * @param tags Resource tags. + * @return the next definition stage. + */ + Update withTags(Map tags); + } + + /** + * The stage of the HealthModel update allowing to specify identity. + */ + interface WithIdentity { + /** + * Specifies the identity property: The managed service identities assigned to this resource.. + * + * @param identity The managed service identities assigned to this resource. + * @return the next definition stage. + */ + Update withIdentity(ManagedServiceIdentity identity); + } + + /** + * The stage of the HealthModel update allowing to specify properties. + */ + interface WithProperties { + /** + * Specifies the properties property: The resource-specific properties for this resource.. + * + * @param properties The resource-specific properties for this resource. + * @return the next definition stage. + */ + Update withProperties(HealthModelUpdateProperties properties); + } + } + + /** + * Refreshes the resource to sync with Azure. + * + * @return the refreshed resource. + */ + HealthModel refresh(); + + /** + * Refreshes the resource to sync with Azure. + * + * @param context The context to associate with this operation. + * @return the refreshed resource. + */ + HealthModel refresh(Context context); +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/HealthModelProperties.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/HealthModelProperties.java new file mode 100644 index 000000000000..f2ec74fdc73a --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/HealthModelProperties.java @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * HealthModel properties. + */ +@Fluent +public final class HealthModelProperties implements JsonSerializable { + /* + * The data plane endpoint for interacting with health data + */ + private String dataplaneEndpoint; + + /* + * The status of the last operation. + */ + private HealthModelProvisioningState provisioningState; + + /* + * Configure to automatically discover entities from a given scope, such as a Service Group. The discovered entities + * will be linked to the root entity of the health model. + */ + private ModelDiscoverySettings discovery; + + /** + * Creates an instance of HealthModelProperties class. + */ + public HealthModelProperties() { + } + + /** + * Get the dataplaneEndpoint property: The data plane endpoint for interacting with health data. + * + * @return the dataplaneEndpoint value. + */ + public String dataplaneEndpoint() { + return this.dataplaneEndpoint; + } + + /** + * Get the provisioningState property: The status of the last operation. + * + * @return the provisioningState value. + */ + public HealthModelProvisioningState provisioningState() { + return this.provisioningState; + } + + /** + * Get the discovery property: Configure to automatically discover entities from a given scope, such as a Service + * Group. The discovered entities will be linked to the root entity of the health model. + * + * @return the discovery value. + */ + public ModelDiscoverySettings discovery() { + return this.discovery; + } + + /** + * Set the discovery property: Configure to automatically discover entities from a given scope, such as a Service + * Group. The discovered entities will be linked to the root entity of the health model. + * + * @param discovery the discovery value to set. + * @return the HealthModelProperties object itself. + */ + public HealthModelProperties withDiscovery(ModelDiscoverySettings discovery) { + this.discovery = discovery; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (discovery() != null) { + discovery().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("discovery", this.discovery); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of HealthModelProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of HealthModelProperties if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IOException If an error occurs while reading the HealthModelProperties. + */ + public static HealthModelProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + HealthModelProperties deserializedHealthModelProperties = new HealthModelProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("dataplaneEndpoint".equals(fieldName)) { + deserializedHealthModelProperties.dataplaneEndpoint = reader.getString(); + } else if ("provisioningState".equals(fieldName)) { + deserializedHealthModelProperties.provisioningState + = HealthModelProvisioningState.fromString(reader.getString()); + } else if ("discovery".equals(fieldName)) { + deserializedHealthModelProperties.discovery = ModelDiscoverySettings.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedHealthModelProperties; + }); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/HealthModelProvisioningState.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/HealthModelProvisioningState.java new file mode 100644 index 000000000000..ca0f4a4764b0 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/HealthModelProvisioningState.java @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Health Model provisioning states. + */ +public final class HealthModelProvisioningState extends ExpandableStringEnum { + /** + * Resource has been created. + */ + public static final HealthModelProvisioningState SUCCEEDED = fromString("Succeeded"); + + /** + * Resource creation failed. + */ + public static final HealthModelProvisioningState FAILED = fromString("Failed"); + + /** + * Resource creation was canceled. + */ + public static final HealthModelProvisioningState CANCELED = fromString("Canceled"); + + /** + * Static value Creating for HealthModelProvisioningState. + */ + public static final HealthModelProvisioningState CREATING = fromString("Creating"); + + /** + * Static value Deleting for HealthModelProvisioningState. + */ + public static final HealthModelProvisioningState DELETING = fromString("Deleting"); + + /** + * Creates a new instance of HealthModelProvisioningState value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public HealthModelProvisioningState() { + } + + /** + * Creates or finds a HealthModelProvisioningState from its string representation. + * + * @param name a name to look for. + * @return the corresponding HealthModelProvisioningState. + */ + public static HealthModelProvisioningState fromString(String name) { + return fromString(name, HealthModelProvisioningState.class); + } + + /** + * Gets known HealthModelProvisioningState values. + * + * @return known HealthModelProvisioningState values. + */ + public static Collection values() { + return values(HealthModelProvisioningState.class); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/HealthModelUpdate.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/HealthModelUpdate.java new file mode 100644 index 000000000000..655e59bbe588 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/HealthModelUpdate.java @@ -0,0 +1,157 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.Map; + +/** + * The type used for update operations of the HealthModel. + */ +@Fluent +public final class HealthModelUpdate implements JsonSerializable { + /* + * The managed service identities assigned to this resource. + */ + private ManagedServiceIdentity identity; + + /* + * Resource tags. + */ + private Map tags; + + /* + * The resource-specific properties for this resource. + */ + private HealthModelUpdateProperties properties; + + /** + * Creates an instance of HealthModelUpdate class. + */ + public HealthModelUpdate() { + } + + /** + * Get the identity property: The managed service identities assigned to this resource. + * + * @return the identity value. + */ + public ManagedServiceIdentity identity() { + return this.identity; + } + + /** + * Set the identity property: The managed service identities assigned to this resource. + * + * @param identity the identity value to set. + * @return the HealthModelUpdate object itself. + */ + public HealthModelUpdate withIdentity(ManagedServiceIdentity identity) { + this.identity = identity; + return this; + } + + /** + * Get the tags property: Resource tags. + * + * @return the tags value. + */ + public Map tags() { + return this.tags; + } + + /** + * Set the tags property: Resource tags. + * + * @param tags the tags value to set. + * @return the HealthModelUpdate object itself. + */ + public HealthModelUpdate withTags(Map tags) { + this.tags = tags; + return this; + } + + /** + * Get the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + public HealthModelUpdateProperties properties() { + return this.properties; + } + + /** + * Set the properties property: The resource-specific properties for this resource. + * + * @param properties the properties value to set. + * @return the HealthModelUpdate object itself. + */ + public HealthModelUpdate withProperties(HealthModelUpdateProperties properties) { + this.properties = properties; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (identity() != null) { + identity().validate(); + } + if (properties() != null) { + properties().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("identity", this.identity); + jsonWriter.writeMapField("tags", this.tags, (writer, element) -> writer.writeString(element)); + jsonWriter.writeJsonField("properties", this.properties); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of HealthModelUpdate from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of HealthModelUpdate if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the HealthModelUpdate. + */ + public static HealthModelUpdate fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + HealthModelUpdate deserializedHealthModelUpdate = new HealthModelUpdate(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("identity".equals(fieldName)) { + deserializedHealthModelUpdate.identity = ManagedServiceIdentity.fromJson(reader); + } else if ("tags".equals(fieldName)) { + Map tags = reader.readMap(reader1 -> reader1.getString()); + deserializedHealthModelUpdate.tags = tags; + } else if ("properties".equals(fieldName)) { + deserializedHealthModelUpdate.properties = HealthModelUpdateProperties.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedHealthModelUpdate; + }); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/HealthModelUpdateProperties.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/HealthModelUpdateProperties.java new file mode 100644 index 000000000000..c4b7d224500e --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/HealthModelUpdateProperties.java @@ -0,0 +1,99 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The updatable properties of the HealthModel. + */ +@Fluent +public final class HealthModelUpdateProperties implements JsonSerializable { + /* + * Configure to automatically discover entities from a given scope, such as a Service Group. The discovered entities + * will be linked to the root entity of the health model. + */ + private ModelDiscoverySettings discovery; + + /** + * Creates an instance of HealthModelUpdateProperties class. + */ + public HealthModelUpdateProperties() { + } + + /** + * Get the discovery property: Configure to automatically discover entities from a given scope, such as a Service + * Group. The discovered entities will be linked to the root entity of the health model. + * + * @return the discovery value. + */ + public ModelDiscoverySettings discovery() { + return this.discovery; + } + + /** + * Set the discovery property: Configure to automatically discover entities from a given scope, such as a Service + * Group. The discovered entities will be linked to the root entity of the health model. + * + * @param discovery the discovery value to set. + * @return the HealthModelUpdateProperties object itself. + */ + public HealthModelUpdateProperties withDiscovery(ModelDiscoverySettings discovery) { + this.discovery = discovery; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (discovery() != null) { + discovery().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("discovery", this.discovery); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of HealthModelUpdateProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of HealthModelUpdateProperties if the JsonReader was pointing to an instance of it, or null + * if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the HealthModelUpdateProperties. + */ + public static HealthModelUpdateProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + HealthModelUpdateProperties deserializedHealthModelUpdateProperties = new HealthModelUpdateProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("discovery".equals(fieldName)) { + deserializedHealthModelUpdateProperties.discovery = ModelDiscoverySettings.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedHealthModelUpdateProperties; + }); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/HealthModels.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/HealthModels.java new file mode 100644 index 000000000000..1c44b49e705c --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/HealthModels.java @@ -0,0 +1,158 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; + +/** + * Resource collection API of HealthModels. + */ +public interface HealthModels { + /** + * Get a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a HealthModel along with {@link Response}. + */ + Response getByResourceGroupWithResponse(String resourceGroupName, String healthModelName, + Context context); + + /** + * Get a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a HealthModel. + */ + HealthModel getByResourceGroup(String resourceGroupName, String healthModelName); + + /** + * Delete a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void deleteByResourceGroup(String resourceGroupName, String healthModelName); + + /** + * Delete a HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void delete(String resourceGroupName, String healthModelName, Context context); + + /** + * List HealthModel resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a HealthModel list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable listByResourceGroup(String resourceGroupName); + + /** + * List HealthModel resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a HealthModel list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable listByResourceGroup(String resourceGroupName, Context context); + + /** + * List HealthModel resources by subscription ID. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a HealthModel list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable list(); + + /** + * List HealthModel resources by subscription ID. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a HealthModel list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable list(Context context); + + /** + * Get a HealthModel. + * + * @param id the resource ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a HealthModel along with {@link Response}. + */ + HealthModel getById(String id); + + /** + * Get a HealthModel. + * + * @param id the resource ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a HealthModel along with {@link Response}. + */ + Response getByIdWithResponse(String id, Context context); + + /** + * Delete a HealthModel. + * + * @param id the resource ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void deleteById(String id); + + /** + * Delete a HealthModel. + * + * @param id the resource ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void deleteByIdWithResponse(String id, Context context); + + /** + * Begins definition for a new HealthModel resource. + * + * @param name resource name. + * @return the first stage of the new HealthModel definition. + */ + HealthModel.DefinitionStages.Blank define(String name); +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/HealthState.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/HealthState.java new file mode 100644 index 000000000000..202f3747c08f --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/HealthState.java @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Health state of an entity. + */ +public final class HealthState extends ExpandableStringEnum { + /** + * Healthy status. + */ + public static final HealthState HEALTHY = fromString("Healthy"); + + /** + * Degraded status. + */ + public static final HealthState DEGRADED = fromString("Degraded"); + + /** + * Error status (Unhealthy). + */ + public static final HealthState ERROR = fromString("Error"); + + /** + * Unknown status. + */ + public static final HealthState UNKNOWN = fromString("Unknown"); + + /** + * Deleted status. + */ + public static final HealthState DELETED = fromString("Deleted"); + + /** + * Creates a new instance of HealthState value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public HealthState() { + } + + /** + * Creates or finds a HealthState from its string representation. + * + * @param name a name to look for. + * @return the corresponding HealthState. + */ + public static HealthState fromString(String name) { + return fromString(name, HealthState.class); + } + + /** + * Gets known HealthState values. + * + * @return known HealthState values. + */ + public static Collection values() { + return values(HealthState.class); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/IconDefinition.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/IconDefinition.java new file mode 100644 index 000000000000..163f94fb5fe2 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/IconDefinition.java @@ -0,0 +1,129 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Visual icon definition of an entity. + */ +@Fluent +public final class IconDefinition implements JsonSerializable { + /* + * Name of the built-in icon, or 'Custom' to use customData + */ + private String iconName; + + /* + * Custom data. Base64-encoded SVG data. If set, this overrides the built-in icon. + */ + private String customData; + + /** + * Creates an instance of IconDefinition class. + */ + public IconDefinition() { + } + + /** + * Get the iconName property: Name of the built-in icon, or 'Custom' to use customData. + * + * @return the iconName value. + */ + public String iconName() { + return this.iconName; + } + + /** + * Set the iconName property: Name of the built-in icon, or 'Custom' to use customData. + * + * @param iconName the iconName value to set. + * @return the IconDefinition object itself. + */ + public IconDefinition withIconName(String iconName) { + this.iconName = iconName; + return this; + } + + /** + * Get the customData property: Custom data. Base64-encoded SVG data. If set, this overrides the built-in icon. + * + * @return the customData value. + */ + public String customData() { + return this.customData; + } + + /** + * Set the customData property: Custom data. Base64-encoded SVG data. If set, this overrides the built-in icon. + * + * @param customData the customData value to set. + * @return the IconDefinition object itself. + */ + public IconDefinition withCustomData(String customData) { + this.customData = customData; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (iconName() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property iconName in model IconDefinition")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(IconDefinition.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("iconName", this.iconName); + jsonWriter.writeStringField("customData", this.customData); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of IconDefinition from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of IconDefinition if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the IconDefinition. + */ + public static IconDefinition fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + IconDefinition deserializedIconDefinition = new IconDefinition(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("iconName".equals(fieldName)) { + deserializedIconDefinition.iconName = reader.getString(); + } else if ("customData".equals(fieldName)) { + deserializedIconDefinition.customData = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedIconDefinition; + }); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/LogAnalyticsQuerySignalDefinitionProperties.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/LogAnalyticsQuerySignalDefinitionProperties.java new file mode 100644 index 000000000000..81f68d38f7cb --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/LogAnalyticsQuerySignalDefinitionProperties.java @@ -0,0 +1,261 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.Map; + +/** + * Log Analytics Query Signal Definition properties. + */ +@Fluent +public final class LogAnalyticsQuerySignalDefinitionProperties extends SignalDefinitionProperties { + /* + * Kind of the signal definition + */ + private SignalKind signalKind = SignalKind.LOG_ANALYTICS_QUERY; + + /* + * Query text in KQL syntax + */ + private String queryText; + + /* + * Time range of signal. ISO duration format like PT10M. If not specified, the KQL query must define a time range. + */ + private String timeGrain; + + /* + * Name of the column in the result set to evaluate against the thresholds. Defaults to the first column in the + * result set if not specified. The column must be numeric. + */ + private String valueColumnName; + + /** + * Creates an instance of LogAnalyticsQuerySignalDefinitionProperties class. + */ + public LogAnalyticsQuerySignalDefinitionProperties() { + } + + /** + * Get the signalKind property: Kind of the signal definition. + * + * @return the signalKind value. + */ + @Override + public SignalKind signalKind() { + return this.signalKind; + } + + /** + * Get the queryText property: Query text in KQL syntax. + * + * @return the queryText value. + */ + public String queryText() { + return this.queryText; + } + + /** + * Set the queryText property: Query text in KQL syntax. + * + * @param queryText the queryText value to set. + * @return the LogAnalyticsQuerySignalDefinitionProperties object itself. + */ + public LogAnalyticsQuerySignalDefinitionProperties withQueryText(String queryText) { + this.queryText = queryText; + return this; + } + + /** + * Get the timeGrain property: Time range of signal. ISO duration format like PT10M. If not specified, the KQL query + * must define a time range. + * + * @return the timeGrain value. + */ + public String timeGrain() { + return this.timeGrain; + } + + /** + * Set the timeGrain property: Time range of signal. ISO duration format like PT10M. If not specified, the KQL query + * must define a time range. + * + * @param timeGrain the timeGrain value to set. + * @return the LogAnalyticsQuerySignalDefinitionProperties object itself. + */ + public LogAnalyticsQuerySignalDefinitionProperties withTimeGrain(String timeGrain) { + this.timeGrain = timeGrain; + return this; + } + + /** + * Get the valueColumnName property: Name of the column in the result set to evaluate against the thresholds. + * Defaults to the first column in the result set if not specified. The column must be numeric. + * + * @return the valueColumnName value. + */ + public String valueColumnName() { + return this.valueColumnName; + } + + /** + * Set the valueColumnName property: Name of the column in the result set to evaluate against the thresholds. + * Defaults to the first column in the result set if not specified. The column must be numeric. + * + * @param valueColumnName the valueColumnName value to set. + * @return the LogAnalyticsQuerySignalDefinitionProperties object itself. + */ + public LogAnalyticsQuerySignalDefinitionProperties withValueColumnName(String valueColumnName) { + this.valueColumnName = valueColumnName; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public LogAnalyticsQuerySignalDefinitionProperties withDisplayName(String displayName) { + super.withDisplayName(displayName); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public LogAnalyticsQuerySignalDefinitionProperties withRefreshInterval(RefreshInterval refreshInterval) { + super.withRefreshInterval(refreshInterval); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public LogAnalyticsQuerySignalDefinitionProperties withLabels(Map labels) { + super.withLabels(labels); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public LogAnalyticsQuerySignalDefinitionProperties withDataUnit(String dataUnit) { + super.withDataUnit(dataUnit); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public LogAnalyticsQuerySignalDefinitionProperties withEvaluationRules(EvaluationRule evaluationRules) { + super.withEvaluationRules(evaluationRules); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + @Override + public void validate() { + if (queryText() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property queryText in model LogAnalyticsQuerySignalDefinitionProperties")); + } + if (evaluationRules() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property evaluationRules in model LogAnalyticsQuerySignalDefinitionProperties")); + } else { + evaluationRules().validate(); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(LogAnalyticsQuerySignalDefinitionProperties.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("evaluationRules", evaluationRules()); + jsonWriter.writeStringField("displayName", displayName()); + jsonWriter.writeStringField("refreshInterval", refreshInterval() == null ? null : refreshInterval().toString()); + jsonWriter.writeMapField("labels", labels(), (writer, element) -> writer.writeString(element)); + jsonWriter.writeStringField("dataUnit", dataUnit()); + jsonWriter.writeStringField("queryText", this.queryText); + jsonWriter.writeStringField("signalKind", this.signalKind == null ? null : this.signalKind.toString()); + jsonWriter.writeStringField("timeGrain", this.timeGrain); + jsonWriter.writeStringField("valueColumnName", this.valueColumnName); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of LogAnalyticsQuerySignalDefinitionProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of LogAnalyticsQuerySignalDefinitionProperties if the JsonReader was pointing to an instance + * of it, or null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the LogAnalyticsQuerySignalDefinitionProperties. + */ + public static LogAnalyticsQuerySignalDefinitionProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + LogAnalyticsQuerySignalDefinitionProperties deserializedLogAnalyticsQuerySignalDefinitionProperties + = new LogAnalyticsQuerySignalDefinitionProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("evaluationRules".equals(fieldName)) { + deserializedLogAnalyticsQuerySignalDefinitionProperties + .withEvaluationRules(EvaluationRule.fromJson(reader)); + } else if ("provisioningState".equals(fieldName)) { + deserializedLogAnalyticsQuerySignalDefinitionProperties + .withProvisioningState(HealthModelProvisioningState.fromString(reader.getString())); + } else if ("displayName".equals(fieldName)) { + deserializedLogAnalyticsQuerySignalDefinitionProperties.withDisplayName(reader.getString()); + } else if ("refreshInterval".equals(fieldName)) { + deserializedLogAnalyticsQuerySignalDefinitionProperties + .withRefreshInterval(RefreshInterval.fromString(reader.getString())); + } else if ("labels".equals(fieldName)) { + Map labels = reader.readMap(reader1 -> reader1.getString()); + deserializedLogAnalyticsQuerySignalDefinitionProperties.withLabels(labels); + } else if ("dataUnit".equals(fieldName)) { + deserializedLogAnalyticsQuerySignalDefinitionProperties.withDataUnit(reader.getString()); + } else if ("deletionDate".equals(fieldName)) { + deserializedLogAnalyticsQuerySignalDefinitionProperties.withDeletionDate(reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()))); + } else if ("queryText".equals(fieldName)) { + deserializedLogAnalyticsQuerySignalDefinitionProperties.queryText = reader.getString(); + } else if ("signalKind".equals(fieldName)) { + deserializedLogAnalyticsQuerySignalDefinitionProperties.signalKind + = SignalKind.fromString(reader.getString()); + } else if ("timeGrain".equals(fieldName)) { + deserializedLogAnalyticsQuerySignalDefinitionProperties.timeGrain = reader.getString(); + } else if ("valueColumnName".equals(fieldName)) { + deserializedLogAnalyticsQuerySignalDefinitionProperties.valueColumnName = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedLogAnalyticsQuerySignalDefinitionProperties; + }); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/LogAnalyticsSignalGroup.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/LogAnalyticsSignalGroup.java new file mode 100644 index 000000000000..e2e0505c3eb0 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/LogAnalyticsSignalGroup.java @@ -0,0 +1,174 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * A grouping of signal assignments for a Log Analytics Workspace. + */ +@Fluent +public final class LogAnalyticsSignalGroup implements JsonSerializable { + /* + * Signal definitions which are assigned to this signal group. All assignments are combined with an OR operator. + */ + private List signalAssignments; + + /* + * Reference to the name of the authentication setting which is used for querying the data source + */ + private String authenticationSetting; + + /* + * Log Analytics Workspace resource ID + */ + private String logAnalyticsWorkspaceResourceId; + + /** + * Creates an instance of LogAnalyticsSignalGroup class. + */ + public LogAnalyticsSignalGroup() { + } + + /** + * Get the signalAssignments property: Signal definitions which are assigned to this signal group. All assignments + * are combined with an OR operator. + * + * @return the signalAssignments value. + */ + public List signalAssignments() { + return this.signalAssignments; + } + + /** + * Set the signalAssignments property: Signal definitions which are assigned to this signal group. All assignments + * are combined with an OR operator. + * + * @param signalAssignments the signalAssignments value to set. + * @return the LogAnalyticsSignalGroup object itself. + */ + public LogAnalyticsSignalGroup withSignalAssignments(List signalAssignments) { + this.signalAssignments = signalAssignments; + return this; + } + + /** + * Get the authenticationSetting property: Reference to the name of the authentication setting which is used for + * querying the data source. + * + * @return the authenticationSetting value. + */ + public String authenticationSetting() { + return this.authenticationSetting; + } + + /** + * Set the authenticationSetting property: Reference to the name of the authentication setting which is used for + * querying the data source. + * + * @param authenticationSetting the authenticationSetting value to set. + * @return the LogAnalyticsSignalGroup object itself. + */ + public LogAnalyticsSignalGroup withAuthenticationSetting(String authenticationSetting) { + this.authenticationSetting = authenticationSetting; + return this; + } + + /** + * Get the logAnalyticsWorkspaceResourceId property: Log Analytics Workspace resource ID. + * + * @return the logAnalyticsWorkspaceResourceId value. + */ + public String logAnalyticsWorkspaceResourceId() { + return this.logAnalyticsWorkspaceResourceId; + } + + /** + * Set the logAnalyticsWorkspaceResourceId property: Log Analytics Workspace resource ID. + * + * @param logAnalyticsWorkspaceResourceId the logAnalyticsWorkspaceResourceId value to set. + * @return the LogAnalyticsSignalGroup object itself. + */ + public LogAnalyticsSignalGroup withLogAnalyticsWorkspaceResourceId(String logAnalyticsWorkspaceResourceId) { + this.logAnalyticsWorkspaceResourceId = logAnalyticsWorkspaceResourceId; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (signalAssignments() != null) { + signalAssignments().forEach(e -> e.validate()); + } + if (authenticationSetting() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property authenticationSetting in model LogAnalyticsSignalGroup")); + } + if (logAnalyticsWorkspaceResourceId() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property logAnalyticsWorkspaceResourceId in model LogAnalyticsSignalGroup")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(LogAnalyticsSignalGroup.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("authenticationSetting", this.authenticationSetting); + jsonWriter.writeStringField("logAnalyticsWorkspaceResourceId", this.logAnalyticsWorkspaceResourceId); + jsonWriter.writeArrayField("signalAssignments", this.signalAssignments, + (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of LogAnalyticsSignalGroup from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of LogAnalyticsSignalGroup if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the LogAnalyticsSignalGroup. + */ + public static LogAnalyticsSignalGroup fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + LogAnalyticsSignalGroup deserializedLogAnalyticsSignalGroup = new LogAnalyticsSignalGroup(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("authenticationSetting".equals(fieldName)) { + deserializedLogAnalyticsSignalGroup.authenticationSetting = reader.getString(); + } else if ("logAnalyticsWorkspaceResourceId".equals(fieldName)) { + deserializedLogAnalyticsSignalGroup.logAnalyticsWorkspaceResourceId = reader.getString(); + } else if ("signalAssignments".equals(fieldName)) { + List signalAssignments + = reader.readArray(reader1 -> SignalAssignment.fromJson(reader1)); + deserializedLogAnalyticsSignalGroup.signalAssignments = signalAssignments; + } else { + reader.skipChildren(); + } + } + + return deserializedLogAnalyticsSignalGroup; + }); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/ManagedIdentityAuthenticationSettingProperties.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/ManagedIdentityAuthenticationSettingProperties.java new file mode 100644 index 000000000000..2bdcfae2cc48 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/ManagedIdentityAuthenticationSettingProperties.java @@ -0,0 +1,140 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Authentication setting properties for Azure Managed Identity. + */ +@Fluent +public final class ManagedIdentityAuthenticationSettingProperties extends AuthenticationSettingProperties { + /* + * Kind of the authentication setting + */ + private AuthenticationKind authenticationKind = AuthenticationKind.MANAGED_IDENTITY; + + /* + * Name of the managed identity to use. Either 'SystemAssigned' or the resourceId of a user-assigned identity. + */ + private String managedIdentityName; + + /** + * Creates an instance of ManagedIdentityAuthenticationSettingProperties class. + */ + public ManagedIdentityAuthenticationSettingProperties() { + } + + /** + * Get the authenticationKind property: Kind of the authentication setting. + * + * @return the authenticationKind value. + */ + @Override + public AuthenticationKind authenticationKind() { + return this.authenticationKind; + } + + /** + * Get the managedIdentityName property: Name of the managed identity to use. Either 'SystemAssigned' or the + * resourceId of a user-assigned identity. + * + * @return the managedIdentityName value. + */ + public String managedIdentityName() { + return this.managedIdentityName; + } + + /** + * Set the managedIdentityName property: Name of the managed identity to use. Either 'SystemAssigned' or the + * resourceId of a user-assigned identity. + * + * @param managedIdentityName the managedIdentityName value to set. + * @return the ManagedIdentityAuthenticationSettingProperties object itself. + */ + public ManagedIdentityAuthenticationSettingProperties withManagedIdentityName(String managedIdentityName) { + this.managedIdentityName = managedIdentityName; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ManagedIdentityAuthenticationSettingProperties withDisplayName(String displayName) { + super.withDisplayName(displayName); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + @Override + public void validate() { + if (managedIdentityName() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property managedIdentityName in model ManagedIdentityAuthenticationSettingProperties")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(ManagedIdentityAuthenticationSettingProperties.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("displayName", displayName()); + jsonWriter.writeStringField("managedIdentityName", this.managedIdentityName); + jsonWriter.writeStringField("authenticationKind", + this.authenticationKind == null ? null : this.authenticationKind.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ManagedIdentityAuthenticationSettingProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ManagedIdentityAuthenticationSettingProperties if the JsonReader was pointing to an + * instance of it, or null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ManagedIdentityAuthenticationSettingProperties. + */ + public static ManagedIdentityAuthenticationSettingProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ManagedIdentityAuthenticationSettingProperties deserializedManagedIdentityAuthenticationSettingProperties + = new ManagedIdentityAuthenticationSettingProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("provisioningState".equals(fieldName)) { + deserializedManagedIdentityAuthenticationSettingProperties + .withProvisioningState(HealthModelProvisioningState.fromString(reader.getString())); + } else if ("displayName".equals(fieldName)) { + deserializedManagedIdentityAuthenticationSettingProperties.withDisplayName(reader.getString()); + } else if ("managedIdentityName".equals(fieldName)) { + deserializedManagedIdentityAuthenticationSettingProperties.managedIdentityName = reader.getString(); + } else if ("authenticationKind".equals(fieldName)) { + deserializedManagedIdentityAuthenticationSettingProperties.authenticationKind + = AuthenticationKind.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedManagedIdentityAuthenticationSettingProperties; + }); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/ManagedServiceIdentity.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/ManagedServiceIdentity.java new file mode 100644 index 000000000000..43f69a077ab3 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/ManagedServiceIdentity.java @@ -0,0 +1,176 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.Map; + +/** + * Managed service identity (system assigned and/or user assigned identities). + */ +@Fluent +public final class ManagedServiceIdentity implements JsonSerializable { + /* + * The service principal ID of the system assigned identity. This property will only be provided for a system + * assigned identity. + */ + private String principalId; + + /* + * The tenant ID of the system assigned identity. This property will only be provided for a system assigned + * identity. + */ + private String tenantId; + + /* + * The type of managed identity assigned to this resource. + */ + private ManagedServiceIdentityType type; + + /* + * The identities assigned to this resource by the user. + */ + private Map userAssignedIdentities; + + /** + * Creates an instance of ManagedServiceIdentity class. + */ + public ManagedServiceIdentity() { + } + + /** + * Get the principalId property: The service principal ID of the system assigned identity. This property will only + * be provided for a system assigned identity. + * + * @return the principalId value. + */ + public String principalId() { + return this.principalId; + } + + /** + * Get the tenantId property: The tenant ID of the system assigned identity. This property will only be provided for + * a system assigned identity. + * + * @return the tenantId value. + */ + public String tenantId() { + return this.tenantId; + } + + /** + * Get the type property: The type of managed identity assigned to this resource. + * + * @return the type value. + */ + public ManagedServiceIdentityType type() { + return this.type; + } + + /** + * Set the type property: The type of managed identity assigned to this resource. + * + * @param type the type value to set. + * @return the ManagedServiceIdentity object itself. + */ + public ManagedServiceIdentity withType(ManagedServiceIdentityType type) { + this.type = type; + return this; + } + + /** + * Get the userAssignedIdentities property: The identities assigned to this resource by the user. + * + * @return the userAssignedIdentities value. + */ + public Map userAssignedIdentities() { + return this.userAssignedIdentities; + } + + /** + * Set the userAssignedIdentities property: The identities assigned to this resource by the user. + * + * @param userAssignedIdentities the userAssignedIdentities value to set. + * @return the ManagedServiceIdentity object itself. + */ + public ManagedServiceIdentity withUserAssignedIdentities(Map userAssignedIdentities) { + this.userAssignedIdentities = userAssignedIdentities; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (type() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property type in model ManagedServiceIdentity")); + } + if (userAssignedIdentities() != null) { + userAssignedIdentities().values().forEach(e -> { + if (e != null) { + e.validate(); + } + }); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(ManagedServiceIdentity.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + jsonWriter.writeMapField("userAssignedIdentities", this.userAssignedIdentities, + (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ManagedServiceIdentity from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ManagedServiceIdentity if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ManagedServiceIdentity. + */ + public static ManagedServiceIdentity fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ManagedServiceIdentity deserializedManagedServiceIdentity = new ManagedServiceIdentity(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("type".equals(fieldName)) { + deserializedManagedServiceIdentity.type = ManagedServiceIdentityType.fromString(reader.getString()); + } else if ("principalId".equals(fieldName)) { + deserializedManagedServiceIdentity.principalId = reader.getString(); + } else if ("tenantId".equals(fieldName)) { + deserializedManagedServiceIdentity.tenantId = reader.getString(); + } else if ("userAssignedIdentities".equals(fieldName)) { + Map userAssignedIdentities + = reader.readMap(reader1 -> UserAssignedIdentity.fromJson(reader1)); + deserializedManagedServiceIdentity.userAssignedIdentities = userAssignedIdentities; + } else { + reader.skipChildren(); + } + } + + return deserializedManagedServiceIdentity; + }); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/ManagedServiceIdentityType.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/ManagedServiceIdentityType.java new file mode 100644 index 000000000000..82b604085a75 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/ManagedServiceIdentityType.java @@ -0,0 +1,62 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). + */ +public final class ManagedServiceIdentityType extends ExpandableStringEnum { + /** + * No managed identity. + */ + public static final ManagedServiceIdentityType NONE = fromString("None"); + + /** + * System assigned managed identity. + */ + public static final ManagedServiceIdentityType SYSTEM_ASSIGNED = fromString("SystemAssigned"); + + /** + * User assigned managed identity. + */ + public static final ManagedServiceIdentityType USER_ASSIGNED = fromString("UserAssigned"); + + /** + * System and user assigned managed identity. + */ + public static final ManagedServiceIdentityType SYSTEM_ASSIGNED_USER_ASSIGNED + = fromString("SystemAssigned,UserAssigned"); + + /** + * Creates a new instance of ManagedServiceIdentityType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public ManagedServiceIdentityType() { + } + + /** + * Creates or finds a ManagedServiceIdentityType from its string representation. + * + * @param name a name to look for. + * @return the corresponding ManagedServiceIdentityType. + */ + public static ManagedServiceIdentityType fromString(String name) { + return fromString(name, ManagedServiceIdentityType.class); + } + + /** + * Gets known ManagedServiceIdentityType values. + * + * @return known ManagedServiceIdentityType values. + */ + public static Collection values() { + return values(ManagedServiceIdentityType.class); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/MetricAggregationType.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/MetricAggregationType.java new file mode 100644 index 000000000000..f1fd6176d97d --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/MetricAggregationType.java @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Metric aggregation type. + */ +public final class MetricAggregationType extends ExpandableStringEnum { + /** + * Static value None for MetricAggregationType. + */ + public static final MetricAggregationType NONE = fromString("None"); + + /** + * Static value Average for MetricAggregationType. + */ + public static final MetricAggregationType AVERAGE = fromString("Average"); + + /** + * Static value Count for MetricAggregationType. + */ + public static final MetricAggregationType COUNT = fromString("Count"); + + /** + * Static value Minimum for MetricAggregationType. + */ + public static final MetricAggregationType MINIMUM = fromString("Minimum"); + + /** + * Static value Maximum for MetricAggregationType. + */ + public static final MetricAggregationType MAXIMUM = fromString("Maximum"); + + /** + * Static value Total for MetricAggregationType. + */ + public static final MetricAggregationType TOTAL = fromString("Total"); + + /** + * Creates a new instance of MetricAggregationType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public MetricAggregationType() { + } + + /** + * Creates or finds a MetricAggregationType from its string representation. + * + * @param name a name to look for. + * @return the corresponding MetricAggregationType. + */ + public static MetricAggregationType fromString(String name) { + return fromString(name, MetricAggregationType.class); + } + + /** + * Gets known MetricAggregationType values. + * + * @return known MetricAggregationType values. + */ + public static Collection values() { + return values(MetricAggregationType.class); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/ModelDiscoverySettings.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/ModelDiscoverySettings.java new file mode 100644 index 000000000000..5060a7288b00 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/ModelDiscoverySettings.java @@ -0,0 +1,174 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Settings for automatically discovering entities for the health model. + */ +@Fluent +public final class ModelDiscoverySettings implements JsonSerializable { + /* + * The scope from which entities should be automatically discovered. For example, the resource id of a Service + * Group. + */ + private String scope; + + /* + * Whether to add all recommended signals to the discovered entities. + */ + private DiscoveryRuleRecommendedSignalsBehavior addRecommendedSignals; + + /* + * Which Managed Identity of the health model to use for discovery. Defaults to SystemAssigned, if not set. Can be + * set to 'SystemAssigned' or to the resource id of a user-assigned managed identity which is linked to the health + * model. + */ + private String identity; + + /** + * Creates an instance of ModelDiscoverySettings class. + */ + public ModelDiscoverySettings() { + } + + /** + * Get the scope property: The scope from which entities should be automatically discovered. For example, the + * resource id of a Service Group. + * + * @return the scope value. + */ + public String scope() { + return this.scope; + } + + /** + * Set the scope property: The scope from which entities should be automatically discovered. For example, the + * resource id of a Service Group. + * + * @param scope the scope value to set. + * @return the ModelDiscoverySettings object itself. + */ + public ModelDiscoverySettings withScope(String scope) { + this.scope = scope; + return this; + } + + /** + * Get the addRecommendedSignals property: Whether to add all recommended signals to the discovered entities. + * + * @return the addRecommendedSignals value. + */ + public DiscoveryRuleRecommendedSignalsBehavior addRecommendedSignals() { + return this.addRecommendedSignals; + } + + /** + * Set the addRecommendedSignals property: Whether to add all recommended signals to the discovered entities. + * + * @param addRecommendedSignals the addRecommendedSignals value to set. + * @return the ModelDiscoverySettings object itself. + */ + public ModelDiscoverySettings + withAddRecommendedSignals(DiscoveryRuleRecommendedSignalsBehavior addRecommendedSignals) { + this.addRecommendedSignals = addRecommendedSignals; + return this; + } + + /** + * Get the identity property: Which Managed Identity of the health model to use for discovery. Defaults to + * SystemAssigned, if not set. Can be set to 'SystemAssigned' or to the resource id of a user-assigned managed + * identity which is linked to the health model. + * + * @return the identity value. + */ + public String identity() { + return this.identity; + } + + /** + * Set the identity property: Which Managed Identity of the health model to use for discovery. Defaults to + * SystemAssigned, if not set. Can be set to 'SystemAssigned' or to the resource id of a user-assigned managed + * identity which is linked to the health model. + * + * @param identity the identity value to set. + * @return the ModelDiscoverySettings object itself. + */ + public ModelDiscoverySettings withIdentity(String identity) { + this.identity = identity; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (scope() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property scope in model ModelDiscoverySettings")); + } + if (addRecommendedSignals() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property addRecommendedSignals in model ModelDiscoverySettings")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(ModelDiscoverySettings.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("scope", this.scope); + jsonWriter.writeStringField("addRecommendedSignals", + this.addRecommendedSignals == null ? null : this.addRecommendedSignals.toString()); + jsonWriter.writeStringField("identity", this.identity); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ModelDiscoverySettings from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ModelDiscoverySettings if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ModelDiscoverySettings. + */ + public static ModelDiscoverySettings fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ModelDiscoverySettings deserializedModelDiscoverySettings = new ModelDiscoverySettings(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("scope".equals(fieldName)) { + deserializedModelDiscoverySettings.scope = reader.getString(); + } else if ("addRecommendedSignals".equals(fieldName)) { + deserializedModelDiscoverySettings.addRecommendedSignals + = DiscoveryRuleRecommendedSignalsBehavior.fromString(reader.getString()); + } else if ("identity".equals(fieldName)) { + deserializedModelDiscoverySettings.identity = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedModelDiscoverySettings; + }); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/Operation.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/Operation.java new file mode 100644 index 000000000000..605fb911b0b3 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/Operation.java @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.resourcemanager.cloudhealth.fluent.models.OperationInner; + +/** + * An immutable client-side representation of Operation. + */ +public interface Operation { + /** + * Gets the name property: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + * "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + * + * @return the name value. + */ + String name(); + + /** + * Gets the isDataAction property: Whether the operation applies to data-plane. This is "true" for data-plane + * operations and "false" for Azure Resource Manager/control-plane operations. + * + * @return the isDataAction value. + */ + Boolean isDataAction(); + + /** + * Gets the display property: Localized display information for this particular operation. + * + * @return the display value. + */ + OperationDisplay display(); + + /** + * Gets the origin property: The intended executor of the operation; as in Resource Based Access Control (RBAC) and + * audit logs UX. Default value is "user,system". + * + * @return the origin value. + */ + Origin origin(); + + /** + * Gets the actionType property: Extensible enum. Indicates the action type. "Internal" refers to actions that are + * for internal only APIs. + * + * @return the actionType value. + */ + ActionType actionType(); + + /** + * Gets the inner com.azure.resourcemanager.cloudhealth.fluent.models.OperationInner object. + * + * @return the inner object. + */ + OperationInner innerModel(); +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/OperationDisplay.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/OperationDisplay.java new file mode 100644 index 000000000000..d6f1bb5bef6a --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/OperationDisplay.java @@ -0,0 +1,136 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Localized display information for and operation. + */ +@Immutable +public final class OperationDisplay implements JsonSerializable { + /* + * The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or + * "Microsoft Compute". + */ + private String provider; + + /* + * The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or + * "Job Schedule Collections". + */ + private String resource; + + /* + * The concise, localized friendly name for the operation; suitable for dropdowns. E.g. + * "Create or Update Virtual Machine", "Restart Virtual Machine". + */ + private String operation; + + /* + * The short, localized friendly description of the operation; suitable for tool tips and detailed views. + */ + private String description; + + /** + * Creates an instance of OperationDisplay class. + */ + private OperationDisplay() { + } + + /** + * Get the provider property: The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring + * Insights" or "Microsoft Compute". + * + * @return the provider value. + */ + public String provider() { + return this.provider; + } + + /** + * Get the resource property: The localized friendly name of the resource type related to this operation. E.g. + * "Virtual Machines" or "Job Schedule Collections". + * + * @return the resource value. + */ + public String resource() { + return this.resource; + } + + /** + * Get the operation property: The concise, localized friendly name for the operation; suitable for dropdowns. E.g. + * "Create or Update Virtual Machine", "Restart Virtual Machine". + * + * @return the operation value. + */ + public String operation() { + return this.operation; + } + + /** + * Get the description property: The short, localized friendly description of the operation; suitable for tool tips + * and detailed views. + * + * @return the description value. + */ + public String description() { + return this.description; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of OperationDisplay from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OperationDisplay if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the OperationDisplay. + */ + public static OperationDisplay fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OperationDisplay deserializedOperationDisplay = new OperationDisplay(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("provider".equals(fieldName)) { + deserializedOperationDisplay.provider = reader.getString(); + } else if ("resource".equals(fieldName)) { + deserializedOperationDisplay.resource = reader.getString(); + } else if ("operation".equals(fieldName)) { + deserializedOperationDisplay.operation = reader.getString(); + } else if ("description".equals(fieldName)) { + deserializedOperationDisplay.description = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedOperationDisplay; + }); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/Operations.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/Operations.java new file mode 100644 index 000000000000..1cb22dd76dfb --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/Operations.java @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Context; + +/** + * Resource collection API of Operations. + */ +public interface Operations { + /** + * List the operations for the provider. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedIterable}. + */ + PagedIterable list(); + + /** + * List the operations for the provider. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedIterable}. + */ + PagedIterable list(Context context); +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/Origin.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/Origin.java new file mode 100644 index 000000000000..ade7466c84d0 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/Origin.java @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value + * is "user,system". + */ +public final class Origin extends ExpandableStringEnum { + /** + * Indicates the operation is initiated by a user. + */ + public static final Origin USER = fromString("user"); + + /** + * Indicates the operation is initiated by a system. + */ + public static final Origin SYSTEM = fromString("system"); + + /** + * Indicates the operation is initiated by a user or system. + */ + public static final Origin USER_SYSTEM = fromString("user,system"); + + /** + * Creates a new instance of Origin value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public Origin() { + } + + /** + * Creates or finds a Origin from its string representation. + * + * @param name a name to look for. + * @return the corresponding Origin. + */ + public static Origin fromString(String name) { + return fromString(name, Origin.class); + } + + /** + * Gets known Origin values. + * + * @return known Origin values. + */ + public static Collection values() { + return values(Origin.class); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/PrometheusMetricsSignalDefinitionProperties.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/PrometheusMetricsSignalDefinitionProperties.java new file mode 100644 index 000000000000..fa51e2935bae --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/PrometheusMetricsSignalDefinitionProperties.java @@ -0,0 +1,228 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.Map; + +/** + * Prometheus Metrics Signal Definition properties. + */ +@Fluent +public final class PrometheusMetricsSignalDefinitionProperties extends SignalDefinitionProperties { + /* + * Kind of the signal definition + */ + private SignalKind signalKind = SignalKind.PROMETHEUS_METRICS_QUERY; + + /* + * Query text in PromQL syntax + */ + private String queryText; + + /* + * Time range of signal. ISO duration format like PT10M. + */ + private String timeGrain; + + /** + * Creates an instance of PrometheusMetricsSignalDefinitionProperties class. + */ + public PrometheusMetricsSignalDefinitionProperties() { + } + + /** + * Get the signalKind property: Kind of the signal definition. + * + * @return the signalKind value. + */ + @Override + public SignalKind signalKind() { + return this.signalKind; + } + + /** + * Get the queryText property: Query text in PromQL syntax. + * + * @return the queryText value. + */ + public String queryText() { + return this.queryText; + } + + /** + * Set the queryText property: Query text in PromQL syntax. + * + * @param queryText the queryText value to set. + * @return the PrometheusMetricsSignalDefinitionProperties object itself. + */ + public PrometheusMetricsSignalDefinitionProperties withQueryText(String queryText) { + this.queryText = queryText; + return this; + } + + /** + * Get the timeGrain property: Time range of signal. ISO duration format like PT10M. + * + * @return the timeGrain value. + */ + public String timeGrain() { + return this.timeGrain; + } + + /** + * Set the timeGrain property: Time range of signal. ISO duration format like PT10M. + * + * @param timeGrain the timeGrain value to set. + * @return the PrometheusMetricsSignalDefinitionProperties object itself. + */ + public PrometheusMetricsSignalDefinitionProperties withTimeGrain(String timeGrain) { + this.timeGrain = timeGrain; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public PrometheusMetricsSignalDefinitionProperties withDisplayName(String displayName) { + super.withDisplayName(displayName); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public PrometheusMetricsSignalDefinitionProperties withRefreshInterval(RefreshInterval refreshInterval) { + super.withRefreshInterval(refreshInterval); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public PrometheusMetricsSignalDefinitionProperties withLabels(Map labels) { + super.withLabels(labels); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public PrometheusMetricsSignalDefinitionProperties withDataUnit(String dataUnit) { + super.withDataUnit(dataUnit); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public PrometheusMetricsSignalDefinitionProperties withEvaluationRules(EvaluationRule evaluationRules) { + super.withEvaluationRules(evaluationRules); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + @Override + public void validate() { + if (queryText() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property queryText in model PrometheusMetricsSignalDefinitionProperties")); + } + if (evaluationRules() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property evaluationRules in model PrometheusMetricsSignalDefinitionProperties")); + } else { + evaluationRules().validate(); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(PrometheusMetricsSignalDefinitionProperties.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("evaluationRules", evaluationRules()); + jsonWriter.writeStringField("displayName", displayName()); + jsonWriter.writeStringField("refreshInterval", refreshInterval() == null ? null : refreshInterval().toString()); + jsonWriter.writeMapField("labels", labels(), (writer, element) -> writer.writeString(element)); + jsonWriter.writeStringField("dataUnit", dataUnit()); + jsonWriter.writeStringField("queryText", this.queryText); + jsonWriter.writeStringField("signalKind", this.signalKind == null ? null : this.signalKind.toString()); + jsonWriter.writeStringField("timeGrain", this.timeGrain); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of PrometheusMetricsSignalDefinitionProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of PrometheusMetricsSignalDefinitionProperties if the JsonReader was pointing to an instance + * of it, or null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the PrometheusMetricsSignalDefinitionProperties. + */ + public static PrometheusMetricsSignalDefinitionProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + PrometheusMetricsSignalDefinitionProperties deserializedPrometheusMetricsSignalDefinitionProperties + = new PrometheusMetricsSignalDefinitionProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("evaluationRules".equals(fieldName)) { + deserializedPrometheusMetricsSignalDefinitionProperties + .withEvaluationRules(EvaluationRule.fromJson(reader)); + } else if ("provisioningState".equals(fieldName)) { + deserializedPrometheusMetricsSignalDefinitionProperties + .withProvisioningState(HealthModelProvisioningState.fromString(reader.getString())); + } else if ("displayName".equals(fieldName)) { + deserializedPrometheusMetricsSignalDefinitionProperties.withDisplayName(reader.getString()); + } else if ("refreshInterval".equals(fieldName)) { + deserializedPrometheusMetricsSignalDefinitionProperties + .withRefreshInterval(RefreshInterval.fromString(reader.getString())); + } else if ("labels".equals(fieldName)) { + Map labels = reader.readMap(reader1 -> reader1.getString()); + deserializedPrometheusMetricsSignalDefinitionProperties.withLabels(labels); + } else if ("dataUnit".equals(fieldName)) { + deserializedPrometheusMetricsSignalDefinitionProperties.withDataUnit(reader.getString()); + } else if ("deletionDate".equals(fieldName)) { + deserializedPrometheusMetricsSignalDefinitionProperties.withDeletionDate(reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()))); + } else if ("queryText".equals(fieldName)) { + deserializedPrometheusMetricsSignalDefinitionProperties.queryText = reader.getString(); + } else if ("signalKind".equals(fieldName)) { + deserializedPrometheusMetricsSignalDefinitionProperties.signalKind + = SignalKind.fromString(reader.getString()); + } else if ("timeGrain".equals(fieldName)) { + deserializedPrometheusMetricsSignalDefinitionProperties.timeGrain = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedPrometheusMetricsSignalDefinitionProperties; + }); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/RefreshInterval.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/RefreshInterval.java new file mode 100644 index 000000000000..faa15dcf9478 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/RefreshInterval.java @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Refresh interval in ISO duration format. + */ +public final class RefreshInterval extends ExpandableStringEnum { + /** + * One Minute. + */ + public static final RefreshInterval PT1M = fromString("PT1M"); + + /** + * Five Minutes. + */ + public static final RefreshInterval PT5M = fromString("PT5M"); + + /** + * Ten Minutes. + */ + public static final RefreshInterval PT10M = fromString("PT10M"); + + /** + * Thirty Minutes. + */ + public static final RefreshInterval PT30M = fromString("PT30M"); + + /** + * One Hour. + */ + public static final RefreshInterval PT1H = fromString("PT1H"); + + /** + * Two Hours. + */ + public static final RefreshInterval PT2H = fromString("PT2H"); + + /** + * Creates a new instance of RefreshInterval value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public RefreshInterval() { + } + + /** + * Creates or finds a RefreshInterval from its string representation. + * + * @param name a name to look for. + * @return the corresponding RefreshInterval. + */ + public static RefreshInterval fromString(String name) { + return fromString(name, RefreshInterval.class); + } + + /** + * Gets known RefreshInterval values. + * + * @return known RefreshInterval values. + */ + public static Collection values() { + return values(RefreshInterval.class); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/Relationship.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/Relationship.java new file mode 100644 index 000000000000..94e162a84310 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/Relationship.java @@ -0,0 +1,189 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.azure.resourcemanager.cloudhealth.fluent.models.RelationshipInner; + +/** + * An immutable client-side representation of Relationship. + */ +public interface Relationship { + /** + * Gets the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + String id(); + + /** + * Gets the name property: The name of the resource. + * + * @return the name value. + */ + String name(); + + /** + * Gets the type property: The type of the resource. + * + * @return the type value. + */ + String type(); + + /** + * Gets the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + RelationshipProperties properties(); + + /** + * Gets the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + SystemData systemData(); + + /** + * Gets the name of the resource group. + * + * @return the name of the resource group. + */ + String resourceGroupName(); + + /** + * Gets the inner com.azure.resourcemanager.cloudhealth.fluent.models.RelationshipInner object. + * + * @return the inner object. + */ + RelationshipInner innerModel(); + + /** + * The entirety of the Relationship definition. + */ + interface Definition + extends DefinitionStages.Blank, DefinitionStages.WithParentResource, DefinitionStages.WithCreate { + } + + /** + * The Relationship definition stages. + */ + interface DefinitionStages { + /** + * The first stage of the Relationship definition. + */ + interface Blank extends WithParentResource { + } + + /** + * The stage of the Relationship definition allowing to specify parent resource. + */ + interface WithParentResource { + /** + * Specifies resourceGroupName, healthModelName. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @return the next definition stage. + */ + WithCreate withExistingHealthmodel(String resourceGroupName, String healthModelName); + } + + /** + * The stage of the Relationship definition which contains all the minimum required properties for the resource + * to be created, but also allows for any other optional properties to be specified. + */ + interface WithCreate extends DefinitionStages.WithProperties { + /** + * Executes the create request. + * + * @return the created resource. + */ + Relationship create(); + + /** + * Executes the create request. + * + * @param context The context to associate with this operation. + * @return the created resource. + */ + Relationship create(Context context); + } + + /** + * The stage of the Relationship definition allowing to specify properties. + */ + interface WithProperties { + /** + * Specifies the properties property: The resource-specific properties for this resource.. + * + * @param properties The resource-specific properties for this resource. + * @return the next definition stage. + */ + WithCreate withProperties(RelationshipProperties properties); + } + } + + /** + * Begins update for the Relationship resource. + * + * @return the stage of resource update. + */ + Relationship.Update update(); + + /** + * The template for Relationship update. + */ + interface Update extends UpdateStages.WithProperties { + /** + * Executes the update request. + * + * @return the updated resource. + */ + Relationship apply(); + + /** + * Executes the update request. + * + * @param context The context to associate with this operation. + * @return the updated resource. + */ + Relationship apply(Context context); + } + + /** + * The Relationship update stages. + */ + interface UpdateStages { + /** + * The stage of the Relationship update allowing to specify properties. + */ + interface WithProperties { + /** + * Specifies the properties property: The resource-specific properties for this resource.. + * + * @param properties The resource-specific properties for this resource. + * @return the next definition stage. + */ + Update withProperties(RelationshipProperties properties); + } + } + + /** + * Refreshes the resource to sync with Azure. + * + * @return the refreshed resource. + */ + Relationship refresh(); + + /** + * Refreshes the resource to sync with Azure. + * + * @param context The context to associate with this operation. + * @return the refreshed resource. + */ + Relationship refresh(Context context); +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/RelationshipProperties.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/RelationshipProperties.java new file mode 100644 index 000000000000..028ff2d1d30b --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/RelationshipProperties.java @@ -0,0 +1,246 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.Map; + +/** + * Relationship properties. + */ +@Fluent +public final class RelationshipProperties implements JsonSerializable { + /* + * The status of the last operation. + */ + private HealthModelProvisioningState provisioningState; + + /* + * Display name + */ + private String displayName; + + /* + * Resource name of the parent entity + */ + private String parentEntityName; + + /* + * Resource name of the child entity + */ + private String childEntityName; + + /* + * Optional set of labels (key-value pairs) + */ + private Map labels; + + /* + * Discovered by which discovery rule. If set, the relationship cannot be deleted manually. + */ + private String discoveredBy; + + /* + * Date when the relationship was (soft-)deleted + */ + private OffsetDateTime deletionDate; + + /** + * Creates an instance of RelationshipProperties class. + */ + public RelationshipProperties() { + } + + /** + * Get the provisioningState property: The status of the last operation. + * + * @return the provisioningState value. + */ + public HealthModelProvisioningState provisioningState() { + return this.provisioningState; + } + + /** + * Get the displayName property: Display name. + * + * @return the displayName value. + */ + public String displayName() { + return this.displayName; + } + + /** + * Set the displayName property: Display name. + * + * @param displayName the displayName value to set. + * @return the RelationshipProperties object itself. + */ + public RelationshipProperties withDisplayName(String displayName) { + this.displayName = displayName; + return this; + } + + /** + * Get the parentEntityName property: Resource name of the parent entity. + * + * @return the parentEntityName value. + */ + public String parentEntityName() { + return this.parentEntityName; + } + + /** + * Set the parentEntityName property: Resource name of the parent entity. + * + * @param parentEntityName the parentEntityName value to set. + * @return the RelationshipProperties object itself. + */ + public RelationshipProperties withParentEntityName(String parentEntityName) { + this.parentEntityName = parentEntityName; + return this; + } + + /** + * Get the childEntityName property: Resource name of the child entity. + * + * @return the childEntityName value. + */ + public String childEntityName() { + return this.childEntityName; + } + + /** + * Set the childEntityName property: Resource name of the child entity. + * + * @param childEntityName the childEntityName value to set. + * @return the RelationshipProperties object itself. + */ + public RelationshipProperties withChildEntityName(String childEntityName) { + this.childEntityName = childEntityName; + return this; + } + + /** + * Get the labels property: Optional set of labels (key-value pairs). + * + * @return the labels value. + */ + public Map labels() { + return this.labels; + } + + /** + * Set the labels property: Optional set of labels (key-value pairs). + * + * @param labels the labels value to set. + * @return the RelationshipProperties object itself. + */ + public RelationshipProperties withLabels(Map labels) { + this.labels = labels; + return this; + } + + /** + * Get the discoveredBy property: Discovered by which discovery rule. If set, the relationship cannot be deleted + * manually. + * + * @return the discoveredBy value. + */ + public String discoveredBy() { + return this.discoveredBy; + } + + /** + * Get the deletionDate property: Date when the relationship was (soft-)deleted. + * + * @return the deletionDate value. + */ + public OffsetDateTime deletionDate() { + return this.deletionDate; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (parentEntityName() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property parentEntityName in model RelationshipProperties")); + } + if (childEntityName() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property childEntityName in model RelationshipProperties")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(RelationshipProperties.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("parentEntityName", this.parentEntityName); + jsonWriter.writeStringField("childEntityName", this.childEntityName); + jsonWriter.writeStringField("displayName", this.displayName); + jsonWriter.writeMapField("labels", this.labels, (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RelationshipProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RelationshipProperties if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the RelationshipProperties. + */ + public static RelationshipProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + RelationshipProperties deserializedRelationshipProperties = new RelationshipProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("parentEntityName".equals(fieldName)) { + deserializedRelationshipProperties.parentEntityName = reader.getString(); + } else if ("childEntityName".equals(fieldName)) { + deserializedRelationshipProperties.childEntityName = reader.getString(); + } else if ("provisioningState".equals(fieldName)) { + deserializedRelationshipProperties.provisioningState + = HealthModelProvisioningState.fromString(reader.getString()); + } else if ("displayName".equals(fieldName)) { + deserializedRelationshipProperties.displayName = reader.getString(); + } else if ("labels".equals(fieldName)) { + Map labels = reader.readMap(reader1 -> reader1.getString()); + deserializedRelationshipProperties.labels = labels; + } else if ("discoveredBy".equals(fieldName)) { + deserializedRelationshipProperties.discoveredBy = reader.getString(); + } else if ("deletionDate".equals(fieldName)) { + deserializedRelationshipProperties.deletionDate = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else { + reader.skipChildren(); + } + } + + return deserializedRelationshipProperties; + }); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/Relationships.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/Relationships.java new file mode 100644 index 000000000000..86882111b70c --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/Relationships.java @@ -0,0 +1,155 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; +import java.time.OffsetDateTime; + +/** + * Resource collection API of Relationships. + */ +public interface Relationships { + /** + * Get a Relationship. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param relationshipName Name of the relationship. Must be unique within a health model. For example, a + * concatenation of parentEntityName and childEntityName can be used as the name. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Relationship along with {@link Response}. + */ + Response getWithResponse(String resourceGroupName, String healthModelName, String relationshipName, + Context context); + + /** + * Get a Relationship. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param relationshipName Name of the relationship. Must be unique within a health model. For example, a + * concatenation of parentEntityName and childEntityName can be used as the name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Relationship. + */ + Relationship get(String resourceGroupName, String healthModelName, String relationshipName); + + /** + * Delete a Relationship. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param relationshipName Name of the relationship. Must be unique within a health model. For example, a + * concatenation of parentEntityName and childEntityName can be used as the name. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + Response deleteWithResponse(String resourceGroupName, String healthModelName, String relationshipName, + Context context); + + /** + * Delete a Relationship. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param relationshipName Name of the relationship. Must be unique within a health model. For example, a + * concatenation of parentEntityName and childEntityName can be used as the name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void delete(String resourceGroupName, String healthModelName, String relationshipName); + + /** + * List Relationship resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Relationship list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable listByHealthModel(String resourceGroupName, String healthModelName); + + /** + * List Relationship resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param timestamp Timestamp to use for the operation. When specified, the version of the resource at this point in + * time is retrieved. If not specified, the latest version is used. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Relationship list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable listByHealthModel(String resourceGroupName, String healthModelName, + OffsetDateTime timestamp, Context context); + + /** + * Get a Relationship. + * + * @param id the resource ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Relationship along with {@link Response}. + */ + Relationship getById(String id); + + /** + * Get a Relationship. + * + * @param id the resource ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Relationship along with {@link Response}. + */ + Response getByIdWithResponse(String id, Context context); + + /** + * Delete a Relationship. + * + * @param id the resource ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void deleteById(String id); + + /** + * Delete a Relationship. + * + * @param id the resource ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + Response deleteByIdWithResponse(String id, Context context); + + /** + * Begins definition for a new Relationship resource. + * + * @param name resource name. + * @return the first stage of the new Relationship definition. + */ + Relationship.DefinitionStages.Blank define(String name); +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/ResourceMetricSignalDefinitionProperties.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/ResourceMetricSignalDefinitionProperties.java new file mode 100644 index 000000000000..a60b2bd92dd6 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/ResourceMetricSignalDefinitionProperties.java @@ -0,0 +1,359 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.Map; + +/** + * Azure Resource Metric Signal Definition properties. + */ +@Fluent +public final class ResourceMetricSignalDefinitionProperties extends SignalDefinitionProperties { + /* + * Kind of the signal definition + */ + private SignalKind signalKind = SignalKind.AZURE_RESOURCE_METRIC; + + /* + * Metric namespace + */ + private String metricNamespace; + + /* + * Name of the metric + */ + private String metricName; + + /* + * Time range of signal. ISO duration format like PT10M. + */ + private String timeGrain; + + /* + * Type of aggregation to apply to the metric + */ + private MetricAggregationType aggregationType; + + /* + * Optional: Dimension to split by + */ + private String dimension; + + /* + * Optional: Dimension filter to apply to the dimension. Must only be set if also Dimension is set. + */ + private String dimensionFilter; + + /** + * Creates an instance of ResourceMetricSignalDefinitionProperties class. + */ + public ResourceMetricSignalDefinitionProperties() { + } + + /** + * Get the signalKind property: Kind of the signal definition. + * + * @return the signalKind value. + */ + @Override + public SignalKind signalKind() { + return this.signalKind; + } + + /** + * Get the metricNamespace property: Metric namespace. + * + * @return the metricNamespace value. + */ + public String metricNamespace() { + return this.metricNamespace; + } + + /** + * Set the metricNamespace property: Metric namespace. + * + * @param metricNamespace the metricNamespace value to set. + * @return the ResourceMetricSignalDefinitionProperties object itself. + */ + public ResourceMetricSignalDefinitionProperties withMetricNamespace(String metricNamespace) { + this.metricNamespace = metricNamespace; + return this; + } + + /** + * Get the metricName property: Name of the metric. + * + * @return the metricName value. + */ + public String metricName() { + return this.metricName; + } + + /** + * Set the metricName property: Name of the metric. + * + * @param metricName the metricName value to set. + * @return the ResourceMetricSignalDefinitionProperties object itself. + */ + public ResourceMetricSignalDefinitionProperties withMetricName(String metricName) { + this.metricName = metricName; + return this; + } + + /** + * Get the timeGrain property: Time range of signal. ISO duration format like PT10M. + * + * @return the timeGrain value. + */ + public String timeGrain() { + return this.timeGrain; + } + + /** + * Set the timeGrain property: Time range of signal. ISO duration format like PT10M. + * + * @param timeGrain the timeGrain value to set. + * @return the ResourceMetricSignalDefinitionProperties object itself. + */ + public ResourceMetricSignalDefinitionProperties withTimeGrain(String timeGrain) { + this.timeGrain = timeGrain; + return this; + } + + /** + * Get the aggregationType property: Type of aggregation to apply to the metric. + * + * @return the aggregationType value. + */ + public MetricAggregationType aggregationType() { + return this.aggregationType; + } + + /** + * Set the aggregationType property: Type of aggregation to apply to the metric. + * + * @param aggregationType the aggregationType value to set. + * @return the ResourceMetricSignalDefinitionProperties object itself. + */ + public ResourceMetricSignalDefinitionProperties withAggregationType(MetricAggregationType aggregationType) { + this.aggregationType = aggregationType; + return this; + } + + /** + * Get the dimension property: Optional: Dimension to split by. + * + * @return the dimension value. + */ + public String dimension() { + return this.dimension; + } + + /** + * Set the dimension property: Optional: Dimension to split by. + * + * @param dimension the dimension value to set. + * @return the ResourceMetricSignalDefinitionProperties object itself. + */ + public ResourceMetricSignalDefinitionProperties withDimension(String dimension) { + this.dimension = dimension; + return this; + } + + /** + * Get the dimensionFilter property: Optional: Dimension filter to apply to the dimension. Must only be set if also + * Dimension is set. + * + * @return the dimensionFilter value. + */ + public String dimensionFilter() { + return this.dimensionFilter; + } + + /** + * Set the dimensionFilter property: Optional: Dimension filter to apply to the dimension. Must only be set if also + * Dimension is set. + * + * @param dimensionFilter the dimensionFilter value to set. + * @return the ResourceMetricSignalDefinitionProperties object itself. + */ + public ResourceMetricSignalDefinitionProperties withDimensionFilter(String dimensionFilter) { + this.dimensionFilter = dimensionFilter; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ResourceMetricSignalDefinitionProperties withDisplayName(String displayName) { + super.withDisplayName(displayName); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ResourceMetricSignalDefinitionProperties withRefreshInterval(RefreshInterval refreshInterval) { + super.withRefreshInterval(refreshInterval); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ResourceMetricSignalDefinitionProperties withLabels(Map labels) { + super.withLabels(labels); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ResourceMetricSignalDefinitionProperties withDataUnit(String dataUnit) { + super.withDataUnit(dataUnit); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ResourceMetricSignalDefinitionProperties withEvaluationRules(EvaluationRule evaluationRules) { + super.withEvaluationRules(evaluationRules); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + @Override + public void validate() { + if (metricNamespace() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property metricNamespace in model ResourceMetricSignalDefinitionProperties")); + } + if (metricName() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property metricName in model ResourceMetricSignalDefinitionProperties")); + } + if (timeGrain() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property timeGrain in model ResourceMetricSignalDefinitionProperties")); + } + if (aggregationType() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property aggregationType in model ResourceMetricSignalDefinitionProperties")); + } + if (evaluationRules() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property evaluationRules in model ResourceMetricSignalDefinitionProperties")); + } else { + evaluationRules().validate(); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(ResourceMetricSignalDefinitionProperties.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("evaluationRules", evaluationRules()); + jsonWriter.writeStringField("displayName", displayName()); + jsonWriter.writeStringField("refreshInterval", refreshInterval() == null ? null : refreshInterval().toString()); + jsonWriter.writeMapField("labels", labels(), (writer, element) -> writer.writeString(element)); + jsonWriter.writeStringField("dataUnit", dataUnit()); + jsonWriter.writeStringField("metricNamespace", this.metricNamespace); + jsonWriter.writeStringField("metricName", this.metricName); + jsonWriter.writeStringField("timeGrain", this.timeGrain); + jsonWriter.writeStringField("aggregationType", + this.aggregationType == null ? null : this.aggregationType.toString()); + jsonWriter.writeStringField("signalKind", this.signalKind == null ? null : this.signalKind.toString()); + jsonWriter.writeStringField("dimension", this.dimension); + jsonWriter.writeStringField("dimensionFilter", this.dimensionFilter); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ResourceMetricSignalDefinitionProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ResourceMetricSignalDefinitionProperties if the JsonReader was pointing to an instance of + * it, or null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ResourceMetricSignalDefinitionProperties. + */ + public static ResourceMetricSignalDefinitionProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ResourceMetricSignalDefinitionProperties deserializedResourceMetricSignalDefinitionProperties + = new ResourceMetricSignalDefinitionProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("evaluationRules".equals(fieldName)) { + deserializedResourceMetricSignalDefinitionProperties + .withEvaluationRules(EvaluationRule.fromJson(reader)); + } else if ("provisioningState".equals(fieldName)) { + deserializedResourceMetricSignalDefinitionProperties + .withProvisioningState(HealthModelProvisioningState.fromString(reader.getString())); + } else if ("displayName".equals(fieldName)) { + deserializedResourceMetricSignalDefinitionProperties.withDisplayName(reader.getString()); + } else if ("refreshInterval".equals(fieldName)) { + deserializedResourceMetricSignalDefinitionProperties + .withRefreshInterval(RefreshInterval.fromString(reader.getString())); + } else if ("labels".equals(fieldName)) { + Map labels = reader.readMap(reader1 -> reader1.getString()); + deserializedResourceMetricSignalDefinitionProperties.withLabels(labels); + } else if ("dataUnit".equals(fieldName)) { + deserializedResourceMetricSignalDefinitionProperties.withDataUnit(reader.getString()); + } else if ("deletionDate".equals(fieldName)) { + deserializedResourceMetricSignalDefinitionProperties.withDeletionDate(reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()))); + } else if ("metricNamespace".equals(fieldName)) { + deserializedResourceMetricSignalDefinitionProperties.metricNamespace = reader.getString(); + } else if ("metricName".equals(fieldName)) { + deserializedResourceMetricSignalDefinitionProperties.metricName = reader.getString(); + } else if ("timeGrain".equals(fieldName)) { + deserializedResourceMetricSignalDefinitionProperties.timeGrain = reader.getString(); + } else if ("aggregationType".equals(fieldName)) { + deserializedResourceMetricSignalDefinitionProperties.aggregationType + = MetricAggregationType.fromString(reader.getString()); + } else if ("signalKind".equals(fieldName)) { + deserializedResourceMetricSignalDefinitionProperties.signalKind + = SignalKind.fromString(reader.getString()); + } else if ("dimension".equals(fieldName)) { + deserializedResourceMetricSignalDefinitionProperties.dimension = reader.getString(); + } else if ("dimensionFilter".equals(fieldName)) { + deserializedResourceMetricSignalDefinitionProperties.dimensionFilter = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedResourceMetricSignalDefinitionProperties; + }); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/SignalAssignment.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/SignalAssignment.java new file mode 100644 index 000000000000..9b10f21571e1 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/SignalAssignment.java @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * Group of signal definition assignments. + */ +@Fluent +public final class SignalAssignment implements JsonSerializable { + /* + * Signal definitions referenced by their names. All definitions are combined with an AND operator. + */ + private List signalDefinitions; + + /** + * Creates an instance of SignalAssignment class. + */ + public SignalAssignment() { + } + + /** + * Get the signalDefinitions property: Signal definitions referenced by their names. All definitions are combined + * with an AND operator. + * + * @return the signalDefinitions value. + */ + public List signalDefinitions() { + return this.signalDefinitions; + } + + /** + * Set the signalDefinitions property: Signal definitions referenced by their names. All definitions are combined + * with an AND operator. + * + * @param signalDefinitions the signalDefinitions value to set. + * @return the SignalAssignment object itself. + */ + public SignalAssignment withSignalDefinitions(List signalDefinitions) { + this.signalDefinitions = signalDefinitions; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (signalDefinitions() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property signalDefinitions in model SignalAssignment")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(SignalAssignment.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("signalDefinitions", this.signalDefinitions, + (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SignalAssignment from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SignalAssignment if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the SignalAssignment. + */ + public static SignalAssignment fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SignalAssignment deserializedSignalAssignment = new SignalAssignment(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("signalDefinitions".equals(fieldName)) { + List signalDefinitions = reader.readArray(reader1 -> reader1.getString()); + deserializedSignalAssignment.signalDefinitions = signalDefinitions; + } else { + reader.skipChildren(); + } + } + + return deserializedSignalAssignment; + }); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/SignalDefinition.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/SignalDefinition.java new file mode 100644 index 000000000000..6a75faa4fe85 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/SignalDefinition.java @@ -0,0 +1,189 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.azure.resourcemanager.cloudhealth.fluent.models.SignalDefinitionInner; + +/** + * An immutable client-side representation of SignalDefinition. + */ +public interface SignalDefinition { + /** + * Gets the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + String id(); + + /** + * Gets the name property: The name of the resource. + * + * @return the name value. + */ + String name(); + + /** + * Gets the type property: The type of the resource. + * + * @return the type value. + */ + String type(); + + /** + * Gets the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + SignalDefinitionProperties properties(); + + /** + * Gets the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + SystemData systemData(); + + /** + * Gets the name of the resource group. + * + * @return the name of the resource group. + */ + String resourceGroupName(); + + /** + * Gets the inner com.azure.resourcemanager.cloudhealth.fluent.models.SignalDefinitionInner object. + * + * @return the inner object. + */ + SignalDefinitionInner innerModel(); + + /** + * The entirety of the SignalDefinition definition. + */ + interface Definition + extends DefinitionStages.Blank, DefinitionStages.WithParentResource, DefinitionStages.WithCreate { + } + + /** + * The SignalDefinition definition stages. + */ + interface DefinitionStages { + /** + * The first stage of the SignalDefinition definition. + */ + interface Blank extends WithParentResource { + } + + /** + * The stage of the SignalDefinition definition allowing to specify parent resource. + */ + interface WithParentResource { + /** + * Specifies resourceGroupName, healthModelName. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @return the next definition stage. + */ + WithCreate withExistingHealthmodel(String resourceGroupName, String healthModelName); + } + + /** + * The stage of the SignalDefinition definition which contains all the minimum required properties for the + * resource to be created, but also allows for any other optional properties to be specified. + */ + interface WithCreate extends DefinitionStages.WithProperties { + /** + * Executes the create request. + * + * @return the created resource. + */ + SignalDefinition create(); + + /** + * Executes the create request. + * + * @param context The context to associate with this operation. + * @return the created resource. + */ + SignalDefinition create(Context context); + } + + /** + * The stage of the SignalDefinition definition allowing to specify properties. + */ + interface WithProperties { + /** + * Specifies the properties property: The resource-specific properties for this resource.. + * + * @param properties The resource-specific properties for this resource. + * @return the next definition stage. + */ + WithCreate withProperties(SignalDefinitionProperties properties); + } + } + + /** + * Begins update for the SignalDefinition resource. + * + * @return the stage of resource update. + */ + SignalDefinition.Update update(); + + /** + * The template for SignalDefinition update. + */ + interface Update extends UpdateStages.WithProperties { + /** + * Executes the update request. + * + * @return the updated resource. + */ + SignalDefinition apply(); + + /** + * Executes the update request. + * + * @param context The context to associate with this operation. + * @return the updated resource. + */ + SignalDefinition apply(Context context); + } + + /** + * The SignalDefinition update stages. + */ + interface UpdateStages { + /** + * The stage of the SignalDefinition update allowing to specify properties. + */ + interface WithProperties { + /** + * Specifies the properties property: The resource-specific properties for this resource.. + * + * @param properties The resource-specific properties for this resource. + * @return the next definition stage. + */ + Update withProperties(SignalDefinitionProperties properties); + } + } + + /** + * Refreshes the resource to sync with Azure. + * + * @return the refreshed resource. + */ + SignalDefinition refresh(); + + /** + * Refreshes the resource to sync with Azure. + * + * @param context The context to associate with this operation. + * @return the refreshed resource. + */ + SignalDefinition refresh(Context context); +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/SignalDefinitionProperties.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/SignalDefinitionProperties.java new file mode 100644 index 000000000000..699b18d47113 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/SignalDefinitionProperties.java @@ -0,0 +1,324 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.Map; + +/** + * SignalDefinition properties. + */ +@Fluent +public class SignalDefinitionProperties implements JsonSerializable { + /* + * Kind of the signal definition + */ + private SignalKind signalKind = SignalKind.fromString("SignalDefinitionProperties"); + + /* + * The status of the last operation. + */ + private HealthModelProvisioningState provisioningState; + + /* + * Display name + */ + private String displayName; + + /* + * Interval in which the signal is being evaluated. Defaults to PT1M (1 minute). + */ + private RefreshInterval refreshInterval; + + /* + * Optional set of labels (key-value pairs) + */ + private Map labels; + + /* + * Unit of the signal result (e.g. Bytes, MilliSeconds, Percent, Count)) + */ + private String dataUnit; + + /* + * Evaluation rules for the signal definition + */ + private EvaluationRule evaluationRules; + + /* + * Date when the signal definition was (soft-)deleted + */ + private OffsetDateTime deletionDate; + + /** + * Creates an instance of SignalDefinitionProperties class. + */ + public SignalDefinitionProperties() { + } + + /** + * Get the signalKind property: Kind of the signal definition. + * + * @return the signalKind value. + */ + public SignalKind signalKind() { + return this.signalKind; + } + + /** + * Get the provisioningState property: The status of the last operation. + * + * @return the provisioningState value. + */ + public HealthModelProvisioningState provisioningState() { + return this.provisioningState; + } + + /** + * Set the provisioningState property: The status of the last operation. + * + * @param provisioningState the provisioningState value to set. + * @return the SignalDefinitionProperties object itself. + */ + SignalDefinitionProperties withProvisioningState(HealthModelProvisioningState provisioningState) { + this.provisioningState = provisioningState; + return this; + } + + /** + * Get the displayName property: Display name. + * + * @return the displayName value. + */ + public String displayName() { + return this.displayName; + } + + /** + * Set the displayName property: Display name. + * + * @param displayName the displayName value to set. + * @return the SignalDefinitionProperties object itself. + */ + public SignalDefinitionProperties withDisplayName(String displayName) { + this.displayName = displayName; + return this; + } + + /** + * Get the refreshInterval property: Interval in which the signal is being evaluated. Defaults to PT1M (1 minute). + * + * @return the refreshInterval value. + */ + public RefreshInterval refreshInterval() { + return this.refreshInterval; + } + + /** + * Set the refreshInterval property: Interval in which the signal is being evaluated. Defaults to PT1M (1 minute). + * + * @param refreshInterval the refreshInterval value to set. + * @return the SignalDefinitionProperties object itself. + */ + public SignalDefinitionProperties withRefreshInterval(RefreshInterval refreshInterval) { + this.refreshInterval = refreshInterval; + return this; + } + + /** + * Get the labels property: Optional set of labels (key-value pairs). + * + * @return the labels value. + */ + public Map labels() { + return this.labels; + } + + /** + * Set the labels property: Optional set of labels (key-value pairs). + * + * @param labels the labels value to set. + * @return the SignalDefinitionProperties object itself. + */ + public SignalDefinitionProperties withLabels(Map labels) { + this.labels = labels; + return this; + } + + /** + * Get the dataUnit property: Unit of the signal result (e.g. Bytes, MilliSeconds, Percent, Count)). + * + * @return the dataUnit value. + */ + public String dataUnit() { + return this.dataUnit; + } + + /** + * Set the dataUnit property: Unit of the signal result (e.g. Bytes, MilliSeconds, Percent, Count)). + * + * @param dataUnit the dataUnit value to set. + * @return the SignalDefinitionProperties object itself. + */ + public SignalDefinitionProperties withDataUnit(String dataUnit) { + this.dataUnit = dataUnit; + return this; + } + + /** + * Get the evaluationRules property: Evaluation rules for the signal definition. + * + * @return the evaluationRules value. + */ + public EvaluationRule evaluationRules() { + return this.evaluationRules; + } + + /** + * Set the evaluationRules property: Evaluation rules for the signal definition. + * + * @param evaluationRules the evaluationRules value to set. + * @return the SignalDefinitionProperties object itself. + */ + public SignalDefinitionProperties withEvaluationRules(EvaluationRule evaluationRules) { + this.evaluationRules = evaluationRules; + return this; + } + + /** + * Get the deletionDate property: Date when the signal definition was (soft-)deleted. + * + * @return the deletionDate value. + */ + public OffsetDateTime deletionDate() { + return this.deletionDate; + } + + /** + * Set the deletionDate property: Date when the signal definition was (soft-)deleted. + * + * @param deletionDate the deletionDate value to set. + * @return the SignalDefinitionProperties object itself. + */ + SignalDefinitionProperties withDeletionDate(OffsetDateTime deletionDate) { + this.deletionDate = deletionDate; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (evaluationRules() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property evaluationRules in model SignalDefinitionProperties")); + } else { + evaluationRules().validate(); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(SignalDefinitionProperties.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("evaluationRules", this.evaluationRules); + jsonWriter.writeStringField("signalKind", this.signalKind == null ? null : this.signalKind.toString()); + jsonWriter.writeStringField("displayName", this.displayName); + jsonWriter.writeStringField("refreshInterval", + this.refreshInterval == null ? null : this.refreshInterval.toString()); + jsonWriter.writeMapField("labels", this.labels, (writer, element) -> writer.writeString(element)); + jsonWriter.writeStringField("dataUnit", this.dataUnit); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SignalDefinitionProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SignalDefinitionProperties if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the SignalDefinitionProperties. + */ + public static SignalDefinitionProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + readerToUse.nextToken(); // Prepare for reading + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("signalKind".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("AzureResourceMetric".equals(discriminatorValue)) { + return ResourceMetricSignalDefinitionProperties.fromJson(readerToUse.reset()); + } else if ("LogAnalyticsQuery".equals(discriminatorValue)) { + return LogAnalyticsQuerySignalDefinitionProperties.fromJson(readerToUse.reset()); + } else if ("PrometheusMetricsQuery".equals(discriminatorValue)) { + return PrometheusMetricsSignalDefinitionProperties.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + static SignalDefinitionProperties fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SignalDefinitionProperties deserializedSignalDefinitionProperties = new SignalDefinitionProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("evaluationRules".equals(fieldName)) { + deserializedSignalDefinitionProperties.evaluationRules = EvaluationRule.fromJson(reader); + } else if ("signalKind".equals(fieldName)) { + deserializedSignalDefinitionProperties.signalKind = SignalKind.fromString(reader.getString()); + } else if ("provisioningState".equals(fieldName)) { + deserializedSignalDefinitionProperties.provisioningState + = HealthModelProvisioningState.fromString(reader.getString()); + } else if ("displayName".equals(fieldName)) { + deserializedSignalDefinitionProperties.displayName = reader.getString(); + } else if ("refreshInterval".equals(fieldName)) { + deserializedSignalDefinitionProperties.refreshInterval + = RefreshInterval.fromString(reader.getString()); + } else if ("labels".equals(fieldName)) { + Map labels = reader.readMap(reader1 -> reader1.getString()); + deserializedSignalDefinitionProperties.labels = labels; + } else if ("dataUnit".equals(fieldName)) { + deserializedSignalDefinitionProperties.dataUnit = reader.getString(); + } else if ("deletionDate".equals(fieldName)) { + deserializedSignalDefinitionProperties.deletionDate = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else { + reader.skipChildren(); + } + } + + return deserializedSignalDefinitionProperties; + }); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/SignalDefinitions.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/SignalDefinitions.java new file mode 100644 index 000000000000..813b8600653e --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/SignalDefinitions.java @@ -0,0 +1,151 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; +import java.time.OffsetDateTime; + +/** + * Resource collection API of SignalDefinitions. + */ +public interface SignalDefinitions { + /** + * Get a SignalDefinition. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param signalDefinitionName Name of the signal definition. Must be unique within a health model. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a SignalDefinition along with {@link Response}. + */ + Response getWithResponse(String resourceGroupName, String healthModelName, + String signalDefinitionName, Context context); + + /** + * Get a SignalDefinition. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param signalDefinitionName Name of the signal definition. Must be unique within a health model. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a SignalDefinition. + */ + SignalDefinition get(String resourceGroupName, String healthModelName, String signalDefinitionName); + + /** + * Delete a SignalDefinition. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param signalDefinitionName Name of the signal definition. Must be unique within a health model. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + Response deleteWithResponse(String resourceGroupName, String healthModelName, String signalDefinitionName, + Context context); + + /** + * Delete a SignalDefinition. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param signalDefinitionName Name of the signal definition. Must be unique within a health model. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void delete(String resourceGroupName, String healthModelName, String signalDefinitionName); + + /** + * List SignalDefinition resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a SignalDefinition list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable listByHealthModel(String resourceGroupName, String healthModelName); + + /** + * List SignalDefinition resources by HealthModel. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param healthModelName Name of health model resource. + * @param timestamp Timestamp to use for the operation. When specified, the version of the resource at this point in + * time is retrieved. If not specified, the latest version is used. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a SignalDefinition list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable listByHealthModel(String resourceGroupName, String healthModelName, + OffsetDateTime timestamp, Context context); + + /** + * Get a SignalDefinition. + * + * @param id the resource ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a SignalDefinition along with {@link Response}. + */ + SignalDefinition getById(String id); + + /** + * Get a SignalDefinition. + * + * @param id the resource ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a SignalDefinition along with {@link Response}. + */ + Response getByIdWithResponse(String id, Context context); + + /** + * Delete a SignalDefinition. + * + * @param id the resource ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void deleteById(String id); + + /** + * Delete a SignalDefinition. + * + * @param id the resource ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + Response deleteByIdWithResponse(String id, Context context); + + /** + * Begins definition for a new SignalDefinition resource. + * + * @param name resource name. + * @return the first stage of the new SignalDefinition definition. + */ + SignalDefinition.DefinitionStages.Blank define(String name); +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/SignalGroup.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/SignalGroup.java new file mode 100644 index 000000000000..8689187ccd79 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/SignalGroup.java @@ -0,0 +1,192 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Contains various signal groups that can be assigned to an entity. + */ +@Fluent +public final class SignalGroup implements JsonSerializable { + /* + * Azure Resource Signal Group + */ + private AzureResourceSignalGroup azureResource; + + /* + * Log Analytics Signal Group + */ + private LogAnalyticsSignalGroup azureLogAnalytics; + + /* + * Azure Monitor Workspace Signal Group + */ + private AzureMonitorWorkspaceSignalGroup azureMonitorWorkspace; + + /* + * Settings for dependency signals to control how the health state of child entities influences the health state of + * the parent entity. + */ + private DependenciesSignalGroup dependencies; + + /** + * Creates an instance of SignalGroup class. + */ + public SignalGroup() { + } + + /** + * Get the azureResource property: Azure Resource Signal Group. + * + * @return the azureResource value. + */ + public AzureResourceSignalGroup azureResource() { + return this.azureResource; + } + + /** + * Set the azureResource property: Azure Resource Signal Group. + * + * @param azureResource the azureResource value to set. + * @return the SignalGroup object itself. + */ + public SignalGroup withAzureResource(AzureResourceSignalGroup azureResource) { + this.azureResource = azureResource; + return this; + } + + /** + * Get the azureLogAnalytics property: Log Analytics Signal Group. + * + * @return the azureLogAnalytics value. + */ + public LogAnalyticsSignalGroup azureLogAnalytics() { + return this.azureLogAnalytics; + } + + /** + * Set the azureLogAnalytics property: Log Analytics Signal Group. + * + * @param azureLogAnalytics the azureLogAnalytics value to set. + * @return the SignalGroup object itself. + */ + public SignalGroup withAzureLogAnalytics(LogAnalyticsSignalGroup azureLogAnalytics) { + this.azureLogAnalytics = azureLogAnalytics; + return this; + } + + /** + * Get the azureMonitorWorkspace property: Azure Monitor Workspace Signal Group. + * + * @return the azureMonitorWorkspace value. + */ + public AzureMonitorWorkspaceSignalGroup azureMonitorWorkspace() { + return this.azureMonitorWorkspace; + } + + /** + * Set the azureMonitorWorkspace property: Azure Monitor Workspace Signal Group. + * + * @param azureMonitorWorkspace the azureMonitorWorkspace value to set. + * @return the SignalGroup object itself. + */ + public SignalGroup withAzureMonitorWorkspace(AzureMonitorWorkspaceSignalGroup azureMonitorWorkspace) { + this.azureMonitorWorkspace = azureMonitorWorkspace; + return this; + } + + /** + * Get the dependencies property: Settings for dependency signals to control how the health state of child entities + * influences the health state of the parent entity. + * + * @return the dependencies value. + */ + public DependenciesSignalGroup dependencies() { + return this.dependencies; + } + + /** + * Set the dependencies property: Settings for dependency signals to control how the health state of child entities + * influences the health state of the parent entity. + * + * @param dependencies the dependencies value to set. + * @return the SignalGroup object itself. + */ + public SignalGroup withDependencies(DependenciesSignalGroup dependencies) { + this.dependencies = dependencies; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (azureResource() != null) { + azureResource().validate(); + } + if (azureLogAnalytics() != null) { + azureLogAnalytics().validate(); + } + if (azureMonitorWorkspace() != null) { + azureMonitorWorkspace().validate(); + } + if (dependencies() != null) { + dependencies().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("azureResource", this.azureResource); + jsonWriter.writeJsonField("azureLogAnalytics", this.azureLogAnalytics); + jsonWriter.writeJsonField("azureMonitorWorkspace", this.azureMonitorWorkspace); + jsonWriter.writeJsonField("dependencies", this.dependencies); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SignalGroup from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SignalGroup if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the SignalGroup. + */ + public static SignalGroup fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SignalGroup deserializedSignalGroup = new SignalGroup(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("azureResource".equals(fieldName)) { + deserializedSignalGroup.azureResource = AzureResourceSignalGroup.fromJson(reader); + } else if ("azureLogAnalytics".equals(fieldName)) { + deserializedSignalGroup.azureLogAnalytics = LogAnalyticsSignalGroup.fromJson(reader); + } else if ("azureMonitorWorkspace".equals(fieldName)) { + deserializedSignalGroup.azureMonitorWorkspace = AzureMonitorWorkspaceSignalGroup.fromJson(reader); + } else if ("dependencies".equals(fieldName)) { + deserializedSignalGroup.dependencies = DependenciesSignalGroup.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedSignalGroup; + }); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/SignalKind.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/SignalKind.java new file mode 100644 index 000000000000..0869d843cc50 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/SignalKind.java @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Supported signal kinds as discriminator. + */ +public final class SignalKind extends ExpandableStringEnum { + /** + * Static value AzureResourceMetric for SignalKind. + */ + public static final SignalKind AZURE_RESOURCE_METRIC = fromString("AzureResourceMetric"); + + /** + * Static value LogAnalyticsQuery for SignalKind. + */ + public static final SignalKind LOG_ANALYTICS_QUERY = fromString("LogAnalyticsQuery"); + + /** + * Static value PrometheusMetricsQuery for SignalKind. + */ + public static final SignalKind PROMETHEUS_METRICS_QUERY = fromString("PrometheusMetricsQuery"); + + /** + * Creates a new instance of SignalKind value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public SignalKind() { + } + + /** + * Creates or finds a SignalKind from its string representation. + * + * @param name a name to look for. + * @return the corresponding SignalKind. + */ + public static SignalKind fromString(String name) { + return fromString(name, SignalKind.class); + } + + /** + * Gets known SignalKind values. + * + * @return known SignalKind values. + */ + public static Collection values() { + return values(SignalKind.class); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/SignalOperator.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/SignalOperator.java new file mode 100644 index 000000000000..f085a89baa30 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/SignalOperator.java @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Signal operator. + */ +public final class SignalOperator extends ExpandableStringEnum { + /** + * Lower than. + */ + public static final SignalOperator LOWER_THAN = fromString("LowerThan"); + + /** + * Lower than or equal to. + */ + public static final SignalOperator LOWER_OR_EQUALS = fromString("LowerOrEquals"); + + /** + * Greater than. + */ + public static final SignalOperator GREATER_THAN = fromString("GreaterThan"); + + /** + * Greater than or equal to. + */ + public static final SignalOperator GREATER_OR_EQUALS = fromString("GreaterOrEquals"); + + /** + * Equal to. + */ + public static final SignalOperator EQUALS = fromString("Equals"); + + /** + * Creates a new instance of SignalOperator value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public SignalOperator() { + } + + /** + * Creates or finds a SignalOperator from its string representation. + * + * @param name a name to look for. + * @return the corresponding SignalOperator. + */ + public static SignalOperator fromString(String name) { + return fromString(name, SignalOperator.class); + } + + /** + * Gets known SignalOperator values. + * + * @return known SignalOperator values. + */ + public static Collection values() { + return values(SignalOperator.class); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/ThresholdRule.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/ThresholdRule.java new file mode 100644 index 000000000000..3b616224cca2 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/ThresholdRule.java @@ -0,0 +1,133 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Threshold-based evaluation rule for a signal definition. + */ +@Fluent +public final class ThresholdRule implements JsonSerializable { + /* + * Operator how to compare the signal value with the threshold + */ + private SignalOperator operator; + + /* + * Threshold value + */ + private String threshold; + + /** + * Creates an instance of ThresholdRule class. + */ + public ThresholdRule() { + } + + /** + * Get the operator property: Operator how to compare the signal value with the threshold. + * + * @return the operator value. + */ + public SignalOperator operator() { + return this.operator; + } + + /** + * Set the operator property: Operator how to compare the signal value with the threshold. + * + * @param operator the operator value to set. + * @return the ThresholdRule object itself. + */ + public ThresholdRule withOperator(SignalOperator operator) { + this.operator = operator; + return this; + } + + /** + * Get the threshold property: Threshold value. + * + * @return the threshold value. + */ + public String threshold() { + return this.threshold; + } + + /** + * Set the threshold property: Threshold value. + * + * @param threshold the threshold value to set. + * @return the ThresholdRule object itself. + */ + public ThresholdRule withThreshold(String threshold) { + this.threshold = threshold; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (operator() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property operator in model ThresholdRule")); + } + if (threshold() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property threshold in model ThresholdRule")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(ThresholdRule.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("operator", this.operator == null ? null : this.operator.toString()); + jsonWriter.writeStringField("threshold", this.threshold); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ThresholdRule from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ThresholdRule if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ThresholdRule. + */ + public static ThresholdRule fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ThresholdRule deserializedThresholdRule = new ThresholdRule(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("operator".equals(fieldName)) { + deserializedThresholdRule.operator = SignalOperator.fromString(reader.getString()); + } else if ("threshold".equals(fieldName)) { + deserializedThresholdRule.threshold = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedThresholdRule; + }); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/UserAssignedIdentity.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/UserAssignedIdentity.java new file mode 100644 index 000000000000..08ecee59d335 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/UserAssignedIdentity.java @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.models; + +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * User assigned identity properties. + */ +@Immutable +public final class UserAssignedIdentity implements JsonSerializable { + /* + * The principal ID of the assigned identity. + */ + private String principalId; + + /* + * The client ID of the assigned identity. + */ + private String clientId; + + /** + * Creates an instance of UserAssignedIdentity class. + */ + public UserAssignedIdentity() { + } + + /** + * Get the principalId property: The principal ID of the assigned identity. + * + * @return the principalId value. + */ + public String principalId() { + return this.principalId; + } + + /** + * Get the clientId property: The client ID of the assigned identity. + * + * @return the clientId value. + */ + public String clientId() { + return this.clientId; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of UserAssignedIdentity from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of UserAssignedIdentity if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IOException If an error occurs while reading the UserAssignedIdentity. + */ + public static UserAssignedIdentity fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + UserAssignedIdentity deserializedUserAssignedIdentity = new UserAssignedIdentity(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("principalId".equals(fieldName)) { + deserializedUserAssignedIdentity.principalId = reader.getString(); + } else if ("clientId".equals(fieldName)) { + deserializedUserAssignedIdentity.clientId = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedUserAssignedIdentity; + }); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/package-info.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/package-info.java new file mode 100644 index 000000000000..461c0c90c5a0 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/models/package-info.java @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the data models for CloudHealth. + */ +package com.azure.resourcemanager.cloudhealth.models; diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/package-info.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/package-info.java new file mode 100644 index 000000000000..44c0702980c1 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/com/azure/resourcemanager/cloudhealth/package-info.java @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for CloudHealth. + */ +package com.azure.resourcemanager.cloudhealth; diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/module-info.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/module-info.java new file mode 100644 index 000000000000..5ab9b23bfb35 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/java/module-info.java @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +module com.azure.resourcemanager.cloudhealth { + requires transitive com.azure.core.management; + + exports com.azure.resourcemanager.cloudhealth; + exports com.azure.resourcemanager.cloudhealth.fluent; + exports com.azure.resourcemanager.cloudhealth.fluent.models; + exports com.azure.resourcemanager.cloudhealth.models; + + opens com.azure.resourcemanager.cloudhealth.fluent.models to com.azure.core; + opens com.azure.resourcemanager.cloudhealth.models to com.azure.core; + opens com.azure.resourcemanager.cloudhealth.implementation.models to com.azure.core; +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-cloudhealth/proxy-config.json b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-cloudhealth/proxy-config.json new file mode 100644 index 000000000000..e4e1ba29c50d --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-cloudhealth/proxy-config.json @@ -0,0 +1 @@ +[["com.azure.resourcemanager.cloudhealth.implementation.AuthenticationSettingsClientImpl$AuthenticationSettingsService"],["com.azure.resourcemanager.cloudhealth.implementation.DiscoveryRulesClientImpl$DiscoveryRulesService"],["com.azure.resourcemanager.cloudhealth.implementation.EntitiesClientImpl$EntitiesService"],["com.azure.resourcemanager.cloudhealth.implementation.HealthModelsClientImpl$HealthModelsService"],["com.azure.resourcemanager.cloudhealth.implementation.OperationsClientImpl$OperationsService"],["com.azure.resourcemanager.cloudhealth.implementation.RelationshipsClientImpl$RelationshipsService"],["com.azure.resourcemanager.cloudhealth.implementation.SignalDefinitionsClientImpl$SignalDefinitionsService"]] \ No newline at end of file diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-cloudhealth/reflect-config.json b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-cloudhealth/reflect-config.json new file mode 100644 index 000000000000..0637a088a01e --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-cloudhealth/reflect-config.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/resources/azure-resourcemanager-cloudhealth.properties b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/resources/azure-resourcemanager-cloudhealth.properties new file mode 100644 index 000000000000..defbd48204e4 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/main/resources/azure-resourcemanager-cloudhealth.properties @@ -0,0 +1 @@ +version=${project.version} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/AuthenticationSettingsCreateOrUpdateSamples.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/AuthenticationSettingsCreateOrUpdateSamples.java new file mode 100644 index 000000000000..93a00db55b23 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/AuthenticationSettingsCreateOrUpdateSamples.java @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.resourcemanager.cloudhealth.models.ManagedIdentityAuthenticationSettingProperties; + +/** + * Samples for AuthenticationSettings CreateOrUpdate. + */ +public final class AuthenticationSettingsCreateOrUpdateSamples { + /* + * x-ms-original-file: 2023-10-01-preview/AuthenticationSettings_CreateOrUpdate.json + */ + /** + * Sample code: AuthenticationSettings_CreateOrUpdate. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void + authenticationSettingsCreateOrUpdate(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.authenticationSettings() + .define("myAuthSetting") + .withExistingHealthmodel("myResourceGroup", "myHealthModel") + .withProperties(new ManagedIdentityAuthenticationSettingProperties().withDisplayName("myDisplayName") + .withManagedIdentityName("SystemAssigned")) + .create(); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/AuthenticationSettingsDeleteSamples.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/AuthenticationSettingsDeleteSamples.java new file mode 100644 index 000000000000..6ce3b9f66f9a --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/AuthenticationSettingsDeleteSamples.java @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +/** + * Samples for AuthenticationSettings Delete. + */ +public final class AuthenticationSettingsDeleteSamples { + /* + * x-ms-original-file: 2023-10-01-preview/AuthenticationSettings_Delete.json + */ + /** + * Sample code: AuthenticationSettings_Delete. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void authenticationSettingsDelete(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.authenticationSettings() + .deleteWithResponse("my-resource-group", "my-health-model", "my-auth-setting", + com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/AuthenticationSettingsGetSamples.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/AuthenticationSettingsGetSamples.java new file mode 100644 index 000000000000..357dc9290f40 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/AuthenticationSettingsGetSamples.java @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +/** + * Samples for AuthenticationSettings Get. + */ +public final class AuthenticationSettingsGetSamples { + /* + * x-ms-original-file: 2023-10-01-preview/AuthenticationSettings_Get.json + */ + /** + * Sample code: AuthenticationSettings_Get. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void authenticationSettingsGet(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.authenticationSettings() + .getWithResponse("my-resource-group", "my-health-model", "my-auth-setting", + com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/AuthenticationSettingsListByHealthModelSamples.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/AuthenticationSettingsListByHealthModelSamples.java new file mode 100644 index 000000000000..8536041ebf82 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/AuthenticationSettingsListByHealthModelSamples.java @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +/** + * Samples for AuthenticationSettings ListByHealthModel. + */ +public final class AuthenticationSettingsListByHealthModelSamples { + /* + * x-ms-original-file: 2023-10-01-preview/AuthenticationSettings_ListByHealthModel.json + */ + /** + * Sample code: AuthenticationSettings_ListByHealthModel. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void + authenticationSettingsListByHealthModel(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.authenticationSettings() + .listByHealthModel("my-resource-group", "my-health-model", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/DiscoveryRulesCreateOrUpdateSamples.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/DiscoveryRulesCreateOrUpdateSamples.java new file mode 100644 index 000000000000..0eb0b9127e29 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/DiscoveryRulesCreateOrUpdateSamples.java @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.resourcemanager.cloudhealth.models.DiscoveryRuleProperties; +import com.azure.resourcemanager.cloudhealth.models.DiscoveryRuleRecommendedSignalsBehavior; +import com.azure.resourcemanager.cloudhealth.models.DiscoveryRuleRelationshipDiscoveryBehavior; + +/** + * Samples for DiscoveryRules CreateOrUpdate. + */ +public final class DiscoveryRulesCreateOrUpdateSamples { + /* + * x-ms-original-file: 2023-10-01-preview/DiscoveryRules_CreateOrUpdate.json + */ + /** + * Sample code: DiscoveryRules_CreateOrUpdate. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void discoveryRulesCreateOrUpdate(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.discoveryRules() + .define("myDiscoveryRule") + .withExistingHealthmodel("myResourceGroup", "myHealthModel") + .withProperties(new DiscoveryRuleProperties().withDisplayName("myDisplayName") + .withResourceGraphQuery( + "resources | where subscriptionId == '7ddfffd7-9b32-40df-1234-828cbd55d6f4' | where resourceGroup == 'my-rg'") + .withAuthenticationSetting("authSetting1") + .withDiscoverRelationships(DiscoveryRuleRelationshipDiscoveryBehavior.ENABLED) + .withAddRecommendedSignals(DiscoveryRuleRecommendedSignalsBehavior.ENABLED)) + .create(); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/DiscoveryRulesDeleteSamples.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/DiscoveryRulesDeleteSamples.java new file mode 100644 index 000000000000..edfa8f95b5f9 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/DiscoveryRulesDeleteSamples.java @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +/** + * Samples for DiscoveryRules Delete. + */ +public final class DiscoveryRulesDeleteSamples { + /* + * x-ms-original-file: 2023-10-01-preview/DiscoveryRules_Delete.json + */ + /** + * Sample code: DiscoveryRules_Delete. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void discoveryRulesDelete(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.discoveryRules() + .deleteWithResponse("my-resource-group", "my-health-model", "my-discovery-rule", + com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/DiscoveryRulesGetSamples.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/DiscoveryRulesGetSamples.java new file mode 100644 index 000000000000..65196e99f8d4 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/DiscoveryRulesGetSamples.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +/** + * Samples for DiscoveryRules Get. + */ +public final class DiscoveryRulesGetSamples { + /* + * x-ms-original-file: 2023-10-01-preview/DiscoveryRules_Get.json + */ + /** + * Sample code: DiscoveryRules_Get. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void discoveryRulesGet(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.discoveryRules() + .getWithResponse("myResourceGroup", "myHealthModel", "myDiscoveryRule", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/DiscoveryRulesListByHealthModelSamples.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/DiscoveryRulesListByHealthModelSamples.java new file mode 100644 index 000000000000..466494eea548 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/DiscoveryRulesListByHealthModelSamples.java @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +/** + * Samples for DiscoveryRules ListByHealthModel. + */ +public final class DiscoveryRulesListByHealthModelSamples { + /* + * x-ms-original-file: 2023-10-01-preview/DiscoveryRules_ListByHealthModel.json + */ + /** + * Sample code: DiscoveryRules_ListByHealthModel. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void + discoveryRulesListByHealthModel(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.discoveryRules() + .listByHealthModel("my-resource-group", "my-health-model", null, com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/EntitiesCreateOrUpdateSamples.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/EntitiesCreateOrUpdateSamples.java new file mode 100644 index 000000000000..20301c2054a7 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/EntitiesCreateOrUpdateSamples.java @@ -0,0 +1,90 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.resourcemanager.cloudhealth.models.AlertConfiguration; +import com.azure.resourcemanager.cloudhealth.models.AlertSeverity; +import com.azure.resourcemanager.cloudhealth.models.AzureMonitorWorkspaceSignalGroup; +import com.azure.resourcemanager.cloudhealth.models.AzureResourceSignalGroup; +import com.azure.resourcemanager.cloudhealth.models.DependenciesAggregationType; +import com.azure.resourcemanager.cloudhealth.models.DependenciesSignalGroup; +import com.azure.resourcemanager.cloudhealth.models.EntityAlerts; +import com.azure.resourcemanager.cloudhealth.models.EntityCoordinates; +import com.azure.resourcemanager.cloudhealth.models.EntityImpact; +import com.azure.resourcemanager.cloudhealth.models.EntityProperties; +import com.azure.resourcemanager.cloudhealth.models.IconDefinition; +import com.azure.resourcemanager.cloudhealth.models.LogAnalyticsSignalGroup; +import com.azure.resourcemanager.cloudhealth.models.SignalAssignment; +import com.azure.resourcemanager.cloudhealth.models.SignalGroup; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +/** + * Samples for Entities CreateOrUpdate. + */ +public final class EntitiesCreateOrUpdateSamples { + /* + * x-ms-original-file: 2023-10-01-preview/Entities_CreateOrUpdate.json + */ + /** + * Sample code: Entities_CreateOrUpdate. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void entitiesCreateOrUpdate(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.entities() + .define("uszrxbdkxesdrxhmagmzywebgbjj") + .withExistingHealthmodel("rgopenapi", "myHealthModel") + .withProperties(new EntityProperties().withDisplayName("My entity") + .withCanvasPosition(new EntityCoordinates().withX(14.0).withY(13.0)) + .withIcon(new IconDefinition().withIconName("Custom").withCustomData("rcitntvapruccrhtxmkqjphbxunkz")) + .withHealthObjective(62.0D) + .withImpact(EntityImpact.STANDARD) + .withLabels(mapOf("key1376", "fakeTokenPlaceholder")) + .withSignals(new SignalGroup().withAzureResource(new AzureResourceSignalGroup() + .withSignalAssignments( + Arrays.asList(new SignalAssignment().withSignalDefinitions(Arrays.asList("sigdef1")))) + .withAuthenticationSetting("B3P1X3e-FZtZ-4Ak-2VLHGQ-4m4-05DE-XNW5zW3P-46XY-DC3SSX") + .withAzureResourceId( + "/subscriptions/12345678-1234-1234-1234-123456789012/resourceGroups/rg1/providers/Microsoft.Compute/virtualMachines/vm1")) + .withAzureLogAnalytics(new LogAnalyticsSignalGroup() + .withSignalAssignments(Arrays.asList(new SignalAssignment().withSignalDefinitions( + Arrays.asList("B3P1X3e-FZtZ-4Ak-2VLHGQ-4m4-05DE-XNW5zW3P-46XY-DC3SSX")))) + .withAuthenticationSetting("B3P1X3e-FZtZ-4Ak-2VLHGQ-4m4-05DE-XNW5zW3P-46XY-DC3SSX") + .withLogAnalyticsWorkspaceResourceId( + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg/providers/Microsoft.OperationalInsights/workspaces/myworkspace")) + .withAzureMonitorWorkspace(new AzureMonitorWorkspaceSignalGroup() + .withSignalAssignments( + Arrays.asList(new SignalAssignment().withSignalDefinitions(Arrays.asList("sigdef2")), + new SignalAssignment().withSignalDefinitions(Arrays.asList("sigdef3")))) + .withAuthenticationSetting("B3P1X3e-FZtZ-4Ak-2VLHGQ-4m4-05DE-XNW5zW3P-46XY-DC3SSX") + .withAzureMonitorWorkspaceResourceId( + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg/providers/Microsoft.OperationalInsights/workspaces/myworkspace")) + .withDependencies( + new DependenciesSignalGroup().withAggregationType(DependenciesAggregationType.WORST_OF))) + .withAlerts(new EntityAlerts().withUnhealthy(new AlertConfiguration().withSeverity(AlertSeverity.SEV1) + .withDescription("Alert description") + .withActionGroupIds(Arrays.asList( + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg/providers/Microsoft.Insights/actionGroups/myactiongroup"))) + .withDegraded(new AlertConfiguration().withSeverity(AlertSeverity.SEV4) + .withDescription("Alert description") + .withActionGroupIds(Arrays.asList( + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg/providers/Microsoft.Insights/actionGroups/myactiongroup"))))) + .create(); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/EntitiesDeleteSamples.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/EntitiesDeleteSamples.java new file mode 100644 index 000000000000..4f3eb42846d4 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/EntitiesDeleteSamples.java @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +/** + * Samples for Entities Delete. + */ +public final class EntitiesDeleteSamples { + /* + * x-ms-original-file: 2023-10-01-preview/Entities_Delete.json + */ + /** + * Sample code: Entities_Delete. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void entitiesDelete(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.entities() + .deleteWithResponse("rgopenapi", "model1", "U4VTRFlUkm9kR6H23-c-6U-XHq7n", + com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/EntitiesGetSamples.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/EntitiesGetSamples.java new file mode 100644 index 000000000000..db9c1a8dd361 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/EntitiesGetSamples.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +/** + * Samples for Entities Get. + */ +public final class EntitiesGetSamples { + /* + * x-ms-original-file: 2023-10-01-preview/Entities_Get.json + */ + /** + * Sample code: Entities_Get. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void entitiesGet(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.entities().getWithResponse("rgopenapi", "myHealthModel", "entity1", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/EntitiesListByHealthModelSamples.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/EntitiesListByHealthModelSamples.java new file mode 100644 index 000000000000..ae9fcd20d66f --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/EntitiesListByHealthModelSamples.java @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +/** + * Samples for Entities ListByHealthModel. + */ +public final class EntitiesListByHealthModelSamples { + /* + * x-ms-original-file: 2023-10-01-preview/Entities_ListByHealthModel.json + */ + /** + * Sample code: Entities_ListByHealthModel. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void entitiesListByHealthModel(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.entities() + .listByHealthModel("rgopenapi", "gPWT6GP85xRV248L7LhNRTD--2Yc73wu-5Qk-0tS", null, + com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelsCreateSamples.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelsCreateSamples.java new file mode 100644 index 000000000000..d75412f83933 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelsCreateSamples.java @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.resourcemanager.cloudhealth.models.DiscoveryRuleRecommendedSignalsBehavior; +import com.azure.resourcemanager.cloudhealth.models.HealthModelProperties; +import com.azure.resourcemanager.cloudhealth.models.ManagedServiceIdentity; +import com.azure.resourcemanager.cloudhealth.models.ManagedServiceIdentityType; +import com.azure.resourcemanager.cloudhealth.models.ModelDiscoverySettings; +import com.azure.resourcemanager.cloudhealth.models.UserAssignedIdentity; +import java.util.HashMap; +import java.util.Map; + +/** + * Samples for HealthModels Create. + */ +public final class HealthModelsCreateSamples { + /* + * x-ms-original-file: 2023-10-01-preview/HealthModels_Create.json + */ + /** + * Sample code: HealthModels_Create. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void healthModelsCreate(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.healthModels() + .define("model1") + .withRegion("eastus2") + .withExistingResourceGroup("rgopenapi") + .withTags(mapOf("key2961", "fakeTokenPlaceholder")) + .withProperties(new HealthModelProperties().withDiscovery( + new ModelDiscoverySettings().withScope("/providers/Microsoft.Management/serviceGroups/myServiceGroup") + .withAddRecommendedSignals(DiscoveryRuleRecommendedSignalsBehavior.ENABLED) + .withIdentity("SystemAssigned"))) + .withIdentity(new ManagedServiceIdentity() + .withType(ManagedServiceIdentityType.fromString("SystemAssigned, UserAssigned")) + .withUserAssignedIdentities(mapOf( + "/subscriptions/4980D7D5-4E07-47AD-AD34-E76C6BC9F061/resourceGroups/rgopenapi/providers/Microsoft.ManagedIdentity/userAssignedIdentities/ua1", + new UserAssignedIdentity()))) + .create(); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelsDeleteSamples.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelsDeleteSamples.java new file mode 100644 index 000000000000..e404a03543b7 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelsDeleteSamples.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +/** + * Samples for HealthModels Delete. + */ +public final class HealthModelsDeleteSamples { + /* + * x-ms-original-file: 2023-10-01-preview/HealthModels_Delete.json + */ + /** + * Sample code: HealthModels_Delete. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void healthModelsDelete(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.healthModels().delete("rgopenapi", "model1", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelsGetByResourceGroupSamples.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelsGetByResourceGroupSamples.java new file mode 100644 index 000000000000..5ec258552d58 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelsGetByResourceGroupSamples.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +/** + * Samples for HealthModels GetByResourceGroup. + */ +public final class HealthModelsGetByResourceGroupSamples { + /* + * x-ms-original-file: 2023-10-01-preview/HealthModels_Get.json + */ + /** + * Sample code: HealthModels_Get. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void healthModelsGet(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.healthModels() + .getByResourceGroupWithResponse("rgopenapi", "myHealthModel", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelsListByResourceGroupSamples.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelsListByResourceGroupSamples.java new file mode 100644 index 000000000000..546b592f33a5 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelsListByResourceGroupSamples.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +/** + * Samples for HealthModels ListByResourceGroup. + */ +public final class HealthModelsListByResourceGroupSamples { + /* + * x-ms-original-file: 2023-10-01-preview/HealthModels_ListByResourceGroup.json + */ + /** + * Sample code: HealthModels_ListByResourceGroup. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void + healthModelsListByResourceGroup(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.healthModels().listByResourceGroup("rgopenapi", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelsListSamples.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelsListSamples.java new file mode 100644 index 000000000000..17e0bf0d7e8e --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelsListSamples.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +/** + * Samples for HealthModels List. + */ +public final class HealthModelsListSamples { + /* + * x-ms-original-file: 2023-10-01-preview/HealthModels_ListBySubscription.json + */ + /** + * Sample code: HealthModels_ListBySubscription. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void + healthModelsListBySubscription(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.healthModels().list(com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelsUpdateSamples.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelsUpdateSamples.java new file mode 100644 index 000000000000..9fc3f2a3d922 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelsUpdateSamples.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.resourcemanager.cloudhealth.models.HealthModel; +import com.azure.resourcemanager.cloudhealth.models.ManagedServiceIdentity; +import com.azure.resourcemanager.cloudhealth.models.ManagedServiceIdentityType; +import com.azure.resourcemanager.cloudhealth.models.UserAssignedIdentity; +import java.util.HashMap; +import java.util.Map; + +/** + * Samples for HealthModels Update. + */ +public final class HealthModelsUpdateSamples { + /* + * x-ms-original-file: 2023-10-01-preview/HealthModels_Update.json + */ + /** + * Sample code: HealthModels_Update. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void healthModelsUpdate(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + HealthModel resource = manager.healthModels() + .getByResourceGroupWithResponse("rgopenapi", "model1", com.azure.core.util.Context.NONE) + .getValue(); + resource.update() + .withTags(mapOf("key21", "fakeTokenPlaceholder")) + .withIdentity(new ManagedServiceIdentity() + .withType(ManagedServiceIdentityType.fromString("SystemAssigned, UserAssigned")) + .withUserAssignedIdentities(mapOf( + "/subscriptions/4980D7D5-4E07-47AD-AD34-E76C6BC9F061/resourceGroups/rgopenapi/providers/Microsoft.ManagedIdentity/userAssignedIdentities/ua1", + new UserAssignedIdentity()))) + .apply(); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/OperationsListSamples.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/OperationsListSamples.java new file mode 100644 index 000000000000..811299a8150c --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/OperationsListSamples.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +/** + * Samples for Operations List. + */ +public final class OperationsListSamples { + /* + * x-ms-original-file: 2023-10-01-preview/Operations_List.json + */ + /** + * Sample code: Operations_List. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void operationsList(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.operations().list(com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/RelationshipsCreateOrUpdateSamples.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/RelationshipsCreateOrUpdateSamples.java new file mode 100644 index 000000000000..393f01cf8019 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/RelationshipsCreateOrUpdateSamples.java @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.resourcemanager.cloudhealth.models.RelationshipProperties; +import java.util.HashMap; +import java.util.Map; + +/** + * Samples for Relationships CreateOrUpdate. + */ +public final class RelationshipsCreateOrUpdateSamples { + /* + * x-ms-original-file: 2023-10-01-preview/Relationships_CreateOrUpdate.json + */ + /** + * Sample code: Relationships_CreateOrUpdate. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void relationshipsCreateOrUpdate(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.relationships() + .define("rel1") + .withExistingHealthmodel("rgopenapi", "model1") + .withProperties(new RelationshipProperties().withDisplayName("My relationship") + .withParentEntityName("Entity1") + .withChildEntityName("Entity2") + .withLabels(mapOf("key9681", "fakeTokenPlaceholder"))) + .create(); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/RelationshipsDeleteSamples.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/RelationshipsDeleteSamples.java new file mode 100644 index 000000000000..32fd41d9a2a9 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/RelationshipsDeleteSamples.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +/** + * Samples for Relationships Delete. + */ +public final class RelationshipsDeleteSamples { + /* + * x-ms-original-file: 2023-10-01-preview/Relationships_Delete.json + */ + /** + * Sample code: Relationships_Delete. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void relationshipsDelete(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.relationships().deleteWithResponse("rgopenapi", "model1", "rel1", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/RelationshipsGetSamples.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/RelationshipsGetSamples.java new file mode 100644 index 000000000000..61b6096fea55 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/RelationshipsGetSamples.java @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +/** + * Samples for Relationships Get. + */ +public final class RelationshipsGetSamples { + /* + * x-ms-original-file: 2023-10-01-preview/Relationships_Get.json + */ + /** + * Sample code: Relationships_Get. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void relationshipsGet(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.relationships() + .getWithResponse("rgopenapi", "myHealthModel", "Ue-21-F3M12V3w-13x18F8H-7HOk--kq6tP-HB", + com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/RelationshipsListByHealthModelSamples.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/RelationshipsListByHealthModelSamples.java new file mode 100644 index 000000000000..6a55f3f36a69 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/RelationshipsListByHealthModelSamples.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +/** + * Samples for Relationships ListByHealthModel. + */ +public final class RelationshipsListByHealthModelSamples { + /* + * x-ms-original-file: 2023-10-01-preview/Relationships_ListByHealthModel.json + */ + /** + * Sample code: Relationships_ListByHealthModel. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void + relationshipsListByHealthModel(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.relationships().listByHealthModel("rgopenapi", "model1", null, com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/SignalDefinitionsCreateOrUpdateSamples.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/SignalDefinitionsCreateOrUpdateSamples.java new file mode 100644 index 000000000000..b70c53c27f2b --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/SignalDefinitionsCreateOrUpdateSamples.java @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.resourcemanager.cloudhealth.models.EvaluationRule; +import com.azure.resourcemanager.cloudhealth.models.MetricAggregationType; +import com.azure.resourcemanager.cloudhealth.models.RefreshInterval; +import com.azure.resourcemanager.cloudhealth.models.ResourceMetricSignalDefinitionProperties; +import com.azure.resourcemanager.cloudhealth.models.SignalOperator; +import com.azure.resourcemanager.cloudhealth.models.ThresholdRule; +import java.util.HashMap; +import java.util.Map; + +/** + * Samples for SignalDefinitions CreateOrUpdate. + */ +public final class SignalDefinitionsCreateOrUpdateSamples { + /* + * x-ms-original-file: 2023-10-01-preview/SignalDefinitions_CreateOrUpdate.json + */ + /** + * Sample code: SignalDefinitions_CreateOrUpdate. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void + signalDefinitionsCreateOrUpdate(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.signalDefinitions() + .define("sig1") + .withExistingHealthmodel("rgopenapi", "myHealthModel") + .withProperties(new ResourceMetricSignalDefinitionProperties().withDisplayName("cpu usage") + .withRefreshInterval(RefreshInterval.PT1M) + .withLabels(mapOf("key4788", "fakeTokenPlaceholder")) + .withDataUnit("byte") + .withEvaluationRules(new EvaluationRule() + .withDegradedRule(new ThresholdRule().withOperator(SignalOperator.LOWER_THAN).withThreshold("65")) + .withUnhealthyRule(new ThresholdRule().withOperator(SignalOperator.LOWER_THAN).withThreshold("60"))) + .withMetricNamespace("microsoft.compute/virtualMachines") + .withMetricName("cpuusage") + .withTimeGrain("PT1M") + .withAggregationType(MetricAggregationType.NONE) + .withDimension("nodename") + .withDimensionFilter("node1")) + .create(); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/SignalDefinitionsDeleteSamples.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/SignalDefinitionsDeleteSamples.java new file mode 100644 index 000000000000..b2c1d9aa36fb --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/SignalDefinitionsDeleteSamples.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +/** + * Samples for SignalDefinitions Delete. + */ +public final class SignalDefinitionsDeleteSamples { + /* + * x-ms-original-file: 2023-10-01-preview/SignalDefinitions_Delete.json + */ + /** + * Sample code: SignalDefinitions_Delete. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void signalDefinitionsDelete(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.signalDefinitions().deleteWithResponse("rgopenapi", "model1", "sig", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/SignalDefinitionsGetSamples.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/SignalDefinitionsGetSamples.java new file mode 100644 index 000000000000..e0275fbbde4c --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/SignalDefinitionsGetSamples.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +/** + * Samples for SignalDefinitions Get. + */ +public final class SignalDefinitionsGetSamples { + /* + * x-ms-original-file: 2023-10-01-preview/SignalDefinitions_Get.json + */ + /** + * Sample code: SignalDefinitions_Get. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void signalDefinitionsGet(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.signalDefinitions() + .getWithResponse("rgopenapi", "myHealthModel", "sig1", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/SignalDefinitionsListByHealthModelSamples.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/SignalDefinitionsListByHealthModelSamples.java new file mode 100644 index 000000000000..aba97404d0bc --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/samples/java/com/azure/resourcemanager/cloudhealth/generated/SignalDefinitionsListByHealthModelSamples.java @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +/** + * Samples for SignalDefinitions ListByHealthModel. + */ +public final class SignalDefinitionsListByHealthModelSamples { + /* + * x-ms-original-file: 2023-10-01-preview/SignalDefinitions_ListByHealthModel.json + */ + /** + * Sample code: SignalDefinitions_ListByHealthModel. + * + * @param manager Entry point to CloudHealthManager. + */ + public static void + signalDefinitionsListByHealthModel(com.azure.resourcemanager.cloudhealth.CloudHealthManager manager) { + manager.signalDefinitions() + .listByHealthModel("rgopenapi", "myHealthModel", null, com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/AlertConfigurationTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/AlertConfigurationTests.java new file mode 100644 index 000000000000..1c64ff62caa0 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/AlertConfigurationTests.java @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.cloudhealth.models.AlertConfiguration; +import com.azure.resourcemanager.cloudhealth.models.AlertSeverity; +import java.util.Arrays; +import org.junit.jupiter.api.Assertions; + +public final class AlertConfigurationTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + AlertConfiguration model = BinaryData + .fromString( + "{\"severity\":\"Sev4\",\"description\":\"rhhuaopppcqeqx\",\"actionGroupIds\":[\"dahzxctobg\"]}") + .toObject(AlertConfiguration.class); + Assertions.assertEquals(AlertSeverity.SEV4, model.severity()); + Assertions.assertEquals("rhhuaopppcqeqx", model.description()); + Assertions.assertEquals("dahzxctobg", model.actionGroupIds().get(0)); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + AlertConfiguration model = new AlertConfiguration().withSeverity(AlertSeverity.SEV4) + .withDescription("rhhuaopppcqeqx") + .withActionGroupIds(Arrays.asList("dahzxctobg")); + model = BinaryData.fromObject(model).toObject(AlertConfiguration.class); + Assertions.assertEquals(AlertSeverity.SEV4, model.severity()); + Assertions.assertEquals("rhhuaopppcqeqx", model.description()); + Assertions.assertEquals("dahzxctobg", model.actionGroupIds().get(0)); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/AuthenticationSettingInnerTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/AuthenticationSettingInnerTests.java new file mode 100644 index 000000000000..a9b9e72ee303 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/AuthenticationSettingInnerTests.java @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.cloudhealth.fluent.models.AuthenticationSettingInner; +import com.azure.resourcemanager.cloudhealth.models.AuthenticationSettingProperties; +import org.junit.jupiter.api.Assertions; + +public final class AuthenticationSettingInnerTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + AuthenticationSettingInner model = BinaryData.fromString( + "{\"properties\":{\"authenticationKind\":\"AuthenticationSettingProperties\",\"provisioningState\":\"Failed\",\"displayName\":\"kcciwwzjuqkhr\"},\"id\":\"jiwkuofoskghsau\",\"name\":\"imjm\",\"type\":\"xieduugidyjrr\"}") + .toObject(AuthenticationSettingInner.class); + Assertions.assertEquals("kcciwwzjuqkhr", model.properties().displayName()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + AuthenticationSettingInner model = new AuthenticationSettingInner() + .withProperties(new AuthenticationSettingProperties().withDisplayName("kcciwwzjuqkhr")); + model = BinaryData.fromObject(model).toObject(AuthenticationSettingInner.class); + Assertions.assertEquals("kcciwwzjuqkhr", model.properties().displayName()); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/AuthenticationSettingListResultTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/AuthenticationSettingListResultTests.java new file mode 100644 index 000000000000..110c9dc2405d --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/AuthenticationSettingListResultTests.java @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.cloudhealth.implementation.models.AuthenticationSettingListResult; +import org.junit.jupiter.api.Assertions; + +public final class AuthenticationSettingListResultTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + AuthenticationSettingListResult model = BinaryData.fromString( + "{\"value\":[{\"properties\":{\"authenticationKind\":\"AuthenticationSettingProperties\",\"provisioningState\":\"Canceled\",\"displayName\":\"v\"},\"id\":\"xmzsbbzogg\",\"name\":\"grxwbu\",\"type\":\"vjxxjnsp\"},{\"properties\":{\"authenticationKind\":\"AuthenticationSettingProperties\",\"provisioningState\":\"Creating\",\"displayName\":\"oenkouknvudwti\"},\"id\":\"bldngkpoc\",\"name\":\"pazyxoegukg\",\"type\":\"npiucgygevqznty\"}],\"nextLink\":\"rbpizc\"}") + .toObject(AuthenticationSettingListResult.class); + Assertions.assertEquals("v", model.value().get(0).properties().displayName()); + Assertions.assertEquals("rbpizc", model.nextLink()); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/AuthenticationSettingPropertiesTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/AuthenticationSettingPropertiesTests.java new file mode 100644 index 000000000000..9c0dc6a0c568 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/AuthenticationSettingPropertiesTests.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.cloudhealth.models.AuthenticationSettingProperties; +import org.junit.jupiter.api.Assertions; + +public final class AuthenticationSettingPropertiesTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + AuthenticationSettingProperties model = BinaryData.fromString( + "{\"authenticationKind\":\"AuthenticationSettingProperties\",\"provisioningState\":\"Failed\",\"displayName\":\"osvexcsonpclhoc\"}") + .toObject(AuthenticationSettingProperties.class); + Assertions.assertEquals("osvexcsonpclhoc", model.displayName()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + AuthenticationSettingProperties model + = new AuthenticationSettingProperties().withDisplayName("osvexcsonpclhoc"); + model = BinaryData.fromObject(model).toObject(AuthenticationSettingProperties.class); + Assertions.assertEquals("osvexcsonpclhoc", model.displayName()); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/AuthenticationSettingsCreateOrUpdateWithResponseMockTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/AuthenticationSettingsCreateOrUpdateWithResponseMockTests.java new file mode 100644 index 000000000000..a994b66062f5 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/AuthenticationSettingsCreateOrUpdateWithResponseMockTests.java @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.cloudhealth.CloudHealthManager; +import com.azure.resourcemanager.cloudhealth.models.AuthenticationSetting; +import com.azure.resourcemanager.cloudhealth.models.AuthenticationSettingProperties; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class AuthenticationSettingsCreateOrUpdateWithResponseMockTests { + @Test + public void testCreateOrUpdateWithResponse() throws Exception { + String responseStr + = "{\"properties\":{\"authenticationKind\":\"AuthenticationSettingProperties\",\"provisioningState\":\"Succeeded\",\"displayName\":\"tjsyin\"},\"id\":\"fq\",\"name\":\"tmtdhtmdvypgik\",\"type\":\"gszywk\"}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + CloudHealthManager manager = CloudHealthManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + AuthenticationSetting response = manager.authenticationSettings() + .define("elvezrypq") + .withExistingHealthmodel("pfcqdp", "qxqvpsvuoymgc") + .withProperties(new AuthenticationSettingProperties().withDisplayName("kerqwkyh")) + .create(); + + Assertions.assertEquals("tjsyin", response.properties().displayName()); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/AuthenticationSettingsDeleteWithResponseMockTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/AuthenticationSettingsDeleteWithResponseMockTests.java new file mode 100644 index 000000000000..594fad9218fa --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/AuthenticationSettingsDeleteWithResponseMockTests.java @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.cloudhealth.CloudHealthManager; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class AuthenticationSettingsDeleteWithResponseMockTests { + @Test + public void testDeleteWithResponse() throws Exception { + String responseStr = "{}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + CloudHealthManager manager = CloudHealthManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + manager.authenticationSettings() + .deleteWithResponse("dphqamv", "kfwynw", "vtbvkayh", com.azure.core.util.Context.NONE); + + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/AuthenticationSettingsGetWithResponseMockTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/AuthenticationSettingsGetWithResponseMockTests.java new file mode 100644 index 000000000000..b612e8ee0215 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/AuthenticationSettingsGetWithResponseMockTests.java @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.cloudhealth.CloudHealthManager; +import com.azure.resourcemanager.cloudhealth.models.AuthenticationSetting; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class AuthenticationSettingsGetWithResponseMockTests { + @Test + public void testGetWithResponse() throws Exception { + String responseStr + = "{\"properties\":{\"authenticationKind\":\"AuthenticationSettingProperties\",\"provisioningState\":\"Deleting\",\"displayName\":\"uufzdmsyqtfihw\"},\"id\":\"otzi\",\"name\":\"gamv\",\"type\":\"phoszqz\"}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + CloudHealthManager manager = CloudHealthManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + AuthenticationSetting response = manager.authenticationSettings() + .getWithResponse("wws", "ughftqsx", "qxujxukndxd", com.azure.core.util.Context.NONE) + .getValue(); + + Assertions.assertEquals("uufzdmsyqtfihw", response.properties().displayName()); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/AuthenticationSettingsListByHealthModelMockTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/AuthenticationSettingsListByHealthModelMockTests.java new file mode 100644 index 000000000000..a93ac04a7552 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/AuthenticationSettingsListByHealthModelMockTests.java @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.cloudhealth.CloudHealthManager; +import com.azure.resourcemanager.cloudhealth.models.AuthenticationSetting; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class AuthenticationSettingsListByHealthModelMockTests { + @Test + public void testListByHealthModel() throws Exception { + String responseStr + = "{\"value\":[{\"properties\":{\"authenticationKind\":\"AuthenticationSettingProperties\",\"provisioningState\":\"Succeeded\",\"displayName\":\"cyajguqf\"},\"id\":\"ygz\",\"name\":\"vdnkfxusem\",\"type\":\"wzrmuh\"}]}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + CloudHealthManager manager = CloudHealthManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + PagedIterable response = manager.authenticationSettings() + .listByHealthModel("tnvyqiatkzwp", "npwzcjaes", com.azure.core.util.Context.NONE); + + Assertions.assertEquals("cyajguqf", response.iterator().next().properties().displayName()); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/AzureMonitorWorkspaceSignalGroupTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/AzureMonitorWorkspaceSignalGroupTests.java new file mode 100644 index 000000000000..753790208cf0 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/AzureMonitorWorkspaceSignalGroupTests.java @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.cloudhealth.models.AzureMonitorWorkspaceSignalGroup; +import com.azure.resourcemanager.cloudhealth.models.SignalAssignment; +import java.util.Arrays; +import org.junit.jupiter.api.Assertions; + +public final class AzureMonitorWorkspaceSignalGroupTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + AzureMonitorWorkspaceSignalGroup model = BinaryData.fromString( + "{\"signalAssignments\":[{\"signalDefinitions\":[\"sd\"]},{\"signalDefinitions\":[\"ouwaboekqvkeln\",\"mvb\",\"wyjsflhhcaalnjix\"]},{\"signalDefinitions\":[\"xyawj\",\"yaqcslyjpkiidz\",\"exznelixhnr\"]}],\"authenticationSetting\":\"tfolhbnx\",\"azureMonitorWorkspaceResourceId\":\"nalaulppg\"}") + .toObject(AzureMonitorWorkspaceSignalGroup.class); + Assertions.assertEquals("sd", model.signalAssignments().get(0).signalDefinitions().get(0)); + Assertions.assertEquals("tfolhbnx", model.authenticationSetting()); + Assertions.assertEquals("nalaulppg", model.azureMonitorWorkspaceResourceId()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + AzureMonitorWorkspaceSignalGroup model = new AzureMonitorWorkspaceSignalGroup() + .withSignalAssignments(Arrays.asList(new SignalAssignment().withSignalDefinitions(Arrays.asList("sd")), + new SignalAssignment() + .withSignalDefinitions(Arrays.asList("ouwaboekqvkeln", "mvb", "wyjsflhhcaalnjix")), + new SignalAssignment().withSignalDefinitions(Arrays.asList("xyawj", "yaqcslyjpkiidz", "exznelixhnr")))) + .withAuthenticationSetting("tfolhbnx") + .withAzureMonitorWorkspaceResourceId("nalaulppg"); + model = BinaryData.fromObject(model).toObject(AzureMonitorWorkspaceSignalGroup.class); + Assertions.assertEquals("sd", model.signalAssignments().get(0).signalDefinitions().get(0)); + Assertions.assertEquals("tfolhbnx", model.authenticationSetting()); + Assertions.assertEquals("nalaulppg", model.azureMonitorWorkspaceResourceId()); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/AzureResourceSignalGroupTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/AzureResourceSignalGroupTests.java new file mode 100644 index 000000000000..dfb86b75dcc7 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/AzureResourceSignalGroupTests.java @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.cloudhealth.models.AzureResourceSignalGroup; +import com.azure.resourcemanager.cloudhealth.models.SignalAssignment; +import java.util.Arrays; +import org.junit.jupiter.api.Assertions; + +public final class AzureResourceSignalGroupTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + AzureResourceSignalGroup model = BinaryData.fromString( + "{\"signalAssignments\":[{\"signalDefinitions\":[\"t\"]},{\"signalDefinitions\":[\"xiebwwaloayqcg\",\"rtzju\"]},{\"signalDefinitions\":[\"wyzmhtxon\",\"mtsavjcbpwxqp\"]},{\"signalDefinitions\":[\"knftguvriuh\",\"rwmdyvxqtay\",\"iwwroyqbexrmc\",\"ibycno\"]}],\"authenticationSetting\":\"v\",\"azureResourceId\":\"nmefqsgzvahapj\"}") + .toObject(AzureResourceSignalGroup.class); + Assertions.assertEquals("t", model.signalAssignments().get(0).signalDefinitions().get(0)); + Assertions.assertEquals("v", model.authenticationSetting()); + Assertions.assertEquals("nmefqsgzvahapj", model.azureResourceId()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + AzureResourceSignalGroup model = new AzureResourceSignalGroup() + .withSignalAssignments(Arrays.asList(new SignalAssignment().withSignalDefinitions(Arrays.asList("t")), + new SignalAssignment().withSignalDefinitions(Arrays.asList("xiebwwaloayqcg", "rtzju")), + new SignalAssignment().withSignalDefinitions(Arrays.asList("wyzmhtxon", "mtsavjcbpwxqp")), + new SignalAssignment() + .withSignalDefinitions(Arrays.asList("knftguvriuh", "rwmdyvxqtay", "iwwroyqbexrmc", "ibycno")))) + .withAuthenticationSetting("v") + .withAzureResourceId("nmefqsgzvahapj"); + model = BinaryData.fromObject(model).toObject(AzureResourceSignalGroup.class); + Assertions.assertEquals("t", model.signalAssignments().get(0).signalDefinitions().get(0)); + Assertions.assertEquals("v", model.authenticationSetting()); + Assertions.assertEquals("nmefqsgzvahapj", model.azureResourceId()); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/DependenciesSignalGroupTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/DependenciesSignalGroupTests.java new file mode 100644 index 000000000000..43ca383afc4b --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/DependenciesSignalGroupTests.java @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.cloudhealth.models.DependenciesAggregationType; +import com.azure.resourcemanager.cloudhealth.models.DependenciesSignalGroup; +import org.junit.jupiter.api.Assertions; + +public final class DependenciesSignalGroupTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + DependenciesSignalGroup model = BinaryData.fromString( + "{\"aggregationType\":\"Thresholds\",\"degradedThreshold\":\"pnapnyiropuh\",\"unhealthyThreshold\":\"gvpgy\"}") + .toObject(DependenciesSignalGroup.class); + Assertions.assertEquals(DependenciesAggregationType.THRESHOLDS, model.aggregationType()); + Assertions.assertEquals("pnapnyiropuh", model.degradedThreshold()); + Assertions.assertEquals("gvpgy", model.unhealthyThreshold()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + DependenciesSignalGroup model + = new DependenciesSignalGroup().withAggregationType(DependenciesAggregationType.THRESHOLDS) + .withDegradedThreshold("pnapnyiropuh") + .withUnhealthyThreshold("gvpgy"); + model = BinaryData.fromObject(model).toObject(DependenciesSignalGroup.class); + Assertions.assertEquals(DependenciesAggregationType.THRESHOLDS, model.aggregationType()); + Assertions.assertEquals("pnapnyiropuh", model.degradedThreshold()); + Assertions.assertEquals("gvpgy", model.unhealthyThreshold()); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/DiscoveryRuleInnerTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/DiscoveryRuleInnerTests.java new file mode 100644 index 000000000000..f41d6cc5e44b --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/DiscoveryRuleInnerTests.java @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.cloudhealth.fluent.models.DiscoveryRuleInner; +import com.azure.resourcemanager.cloudhealth.models.DiscoveryRuleProperties; +import com.azure.resourcemanager.cloudhealth.models.DiscoveryRuleRecommendedSignalsBehavior; +import com.azure.resourcemanager.cloudhealth.models.DiscoveryRuleRelationshipDiscoveryBehavior; +import org.junit.jupiter.api.Assertions; + +public final class DiscoveryRuleInnerTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + DiscoveryRuleInner model = BinaryData.fromString( + "{\"properties\":{\"provisioningState\":\"Failed\",\"displayName\":\"nqxwbp\",\"resourceGraphQuery\":\"kulpiujwaasi\",\"authenticationSetting\":\"qiiobyuqer\",\"discoverRelationships\":\"Disabled\",\"addRecommendedSignals\":\"Enabled\",\"deletionDate\":\"2021-08-06T10:56:27Z\",\"errorMessage\":\"cciuqgbdbutau\",\"numberOfDiscoveredEntities\":1736041382,\"entityName\":\"tkuwhhmhykojo\"},\"id\":\"fnndl\",\"name\":\"ichkoymkcdyhb\",\"type\":\"kkpwdreqnovvq\"}") + .toObject(DiscoveryRuleInner.class); + Assertions.assertEquals("nqxwbp", model.properties().displayName()); + Assertions.assertEquals("kulpiujwaasi", model.properties().resourceGraphQuery()); + Assertions.assertEquals("qiiobyuqer", model.properties().authenticationSetting()); + Assertions.assertEquals(DiscoveryRuleRelationshipDiscoveryBehavior.DISABLED, + model.properties().discoverRelationships()); + Assertions.assertEquals(DiscoveryRuleRecommendedSignalsBehavior.ENABLED, + model.properties().addRecommendedSignals()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + DiscoveryRuleInner model + = new DiscoveryRuleInner().withProperties(new DiscoveryRuleProperties().withDisplayName("nqxwbp") + .withResourceGraphQuery("kulpiujwaasi") + .withAuthenticationSetting("qiiobyuqer") + .withDiscoverRelationships(DiscoveryRuleRelationshipDiscoveryBehavior.DISABLED) + .withAddRecommendedSignals(DiscoveryRuleRecommendedSignalsBehavior.ENABLED)); + model = BinaryData.fromObject(model).toObject(DiscoveryRuleInner.class); + Assertions.assertEquals("nqxwbp", model.properties().displayName()); + Assertions.assertEquals("kulpiujwaasi", model.properties().resourceGraphQuery()); + Assertions.assertEquals("qiiobyuqer", model.properties().authenticationSetting()); + Assertions.assertEquals(DiscoveryRuleRelationshipDiscoveryBehavior.DISABLED, + model.properties().discoverRelationships()); + Assertions.assertEquals(DiscoveryRuleRecommendedSignalsBehavior.ENABLED, + model.properties().addRecommendedSignals()); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/DiscoveryRuleListResultTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/DiscoveryRuleListResultTests.java new file mode 100644 index 000000000000..0663606bb1b1 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/DiscoveryRuleListResultTests.java @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.cloudhealth.implementation.models.DiscoveryRuleListResult; +import com.azure.resourcemanager.cloudhealth.models.DiscoveryRuleRecommendedSignalsBehavior; +import com.azure.resourcemanager.cloudhealth.models.DiscoveryRuleRelationshipDiscoveryBehavior; +import org.junit.jupiter.api.Assertions; + +public final class DiscoveryRuleListResultTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + DiscoveryRuleListResult model = BinaryData.fromString( + "{\"value\":[{\"properties\":{\"provisioningState\":\"Succeeded\",\"displayName\":\"kvpuvksgplsaknyn\",\"resourceGraphQuery\":\"synljphuopxodl\",\"authenticationSetting\":\"iyntorzihle\",\"discoverRelationships\":\"Enabled\",\"addRecommendedSignals\":\"Disabled\",\"deletionDate\":\"2021-11-21T17:53:40Z\",\"errorMessage\":\"rmslyzrpzbchckqq\",\"numberOfDiscoveredEntities\":893832741,\"entityName\":\"ox\"},\"id\":\"suiizynkedyat\",\"name\":\"wyhqmibzyhwits\",\"type\":\"ypyynpcdpumnzg\"}],\"nextLink\":\"z\"}") + .toObject(DiscoveryRuleListResult.class); + Assertions.assertEquals("kvpuvksgplsaknyn", model.value().get(0).properties().displayName()); + Assertions.assertEquals("synljphuopxodl", model.value().get(0).properties().resourceGraphQuery()); + Assertions.assertEquals("iyntorzihle", model.value().get(0).properties().authenticationSetting()); + Assertions.assertEquals(DiscoveryRuleRelationshipDiscoveryBehavior.ENABLED, + model.value().get(0).properties().discoverRelationships()); + Assertions.assertEquals(DiscoveryRuleRecommendedSignalsBehavior.DISABLED, + model.value().get(0).properties().addRecommendedSignals()); + Assertions.assertEquals("z", model.nextLink()); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/DiscoveryRulePropertiesTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/DiscoveryRulePropertiesTests.java new file mode 100644 index 000000000000..cdc67bbdd27f --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/DiscoveryRulePropertiesTests.java @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.cloudhealth.models.DiscoveryRuleProperties; +import com.azure.resourcemanager.cloudhealth.models.DiscoveryRuleRecommendedSignalsBehavior; +import com.azure.resourcemanager.cloudhealth.models.DiscoveryRuleRelationshipDiscoveryBehavior; +import org.junit.jupiter.api.Assertions; + +public final class DiscoveryRulePropertiesTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + DiscoveryRuleProperties model = BinaryData.fromString( + "{\"provisioningState\":\"Canceled\",\"displayName\":\"jxywsuws\",\"resourceGraphQuery\":\"rsndsytgadgvra\",\"authenticationSetting\":\"aeneqnzarrwl\",\"discoverRelationships\":\"Enabled\",\"addRecommendedSignals\":\"Enabled\",\"deletionDate\":\"2021-04-01T07:49:28Z\",\"errorMessage\":\"qkacewii\",\"numberOfDiscoveredEntities\":1703781779,\"entityName\":\"ubjibww\"}") + .toObject(DiscoveryRuleProperties.class); + Assertions.assertEquals("jxywsuws", model.displayName()); + Assertions.assertEquals("rsndsytgadgvra", model.resourceGraphQuery()); + Assertions.assertEquals("aeneqnzarrwl", model.authenticationSetting()); + Assertions.assertEquals(DiscoveryRuleRelationshipDiscoveryBehavior.ENABLED, model.discoverRelationships()); + Assertions.assertEquals(DiscoveryRuleRecommendedSignalsBehavior.ENABLED, model.addRecommendedSignals()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + DiscoveryRuleProperties model = new DiscoveryRuleProperties().withDisplayName("jxywsuws") + .withResourceGraphQuery("rsndsytgadgvra") + .withAuthenticationSetting("aeneqnzarrwl") + .withDiscoverRelationships(DiscoveryRuleRelationshipDiscoveryBehavior.ENABLED) + .withAddRecommendedSignals(DiscoveryRuleRecommendedSignalsBehavior.ENABLED); + model = BinaryData.fromObject(model).toObject(DiscoveryRuleProperties.class); + Assertions.assertEquals("jxywsuws", model.displayName()); + Assertions.assertEquals("rsndsytgadgvra", model.resourceGraphQuery()); + Assertions.assertEquals("aeneqnzarrwl", model.authenticationSetting()); + Assertions.assertEquals(DiscoveryRuleRelationshipDiscoveryBehavior.ENABLED, model.discoverRelationships()); + Assertions.assertEquals(DiscoveryRuleRecommendedSignalsBehavior.ENABLED, model.addRecommendedSignals()); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/DiscoveryRulesCreateOrUpdateWithResponseMockTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/DiscoveryRulesCreateOrUpdateWithResponseMockTests.java new file mode 100644 index 000000000000..1c29c47bc551 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/DiscoveryRulesCreateOrUpdateWithResponseMockTests.java @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.cloudhealth.CloudHealthManager; +import com.azure.resourcemanager.cloudhealth.models.DiscoveryRule; +import com.azure.resourcemanager.cloudhealth.models.DiscoveryRuleProperties; +import com.azure.resourcemanager.cloudhealth.models.DiscoveryRuleRecommendedSignalsBehavior; +import com.azure.resourcemanager.cloudhealth.models.DiscoveryRuleRelationshipDiscoveryBehavior; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class DiscoveryRulesCreateOrUpdateWithResponseMockTests { + @Test + public void testCreateOrUpdateWithResponse() throws Exception { + String responseStr + = "{\"properties\":{\"provisioningState\":\"Succeeded\",\"displayName\":\"yjt\",\"resourceGraphQuery\":\"vofqzhvfc\",\"authenticationSetting\":\"byfmowuxr\",\"discoverRelationships\":\"Enabled\",\"addRecommendedSignals\":\"Enabled\",\"deletionDate\":\"2021-11-01T00:27:01Z\",\"errorMessage\":\"xfzwi\",\"numberOfDiscoveredEntities\":1157352083,\"entityName\":\"zjb\"},\"id\":\"zsxjrkambtrneg\",\"name\":\"mnvuqe\",\"type\":\"vldspa\"}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + CloudHealthManager manager = CloudHealthManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + DiscoveryRule response = manager.discoveryRules() + .define("g") + .withExistingHealthmodel("widf", "xsspuunnoxyhk") + .withProperties(new DiscoveryRuleProperties().withDisplayName("hp") + .withResourceGraphQuery("hoqca") + .withAuthenticationSetting("ewda") + .withDiscoverRelationships(DiscoveryRuleRelationshipDiscoveryBehavior.ENABLED) + .withAddRecommendedSignals(DiscoveryRuleRecommendedSignalsBehavior.ENABLED)) + .create(); + + Assertions.assertEquals("yjt", response.properties().displayName()); + Assertions.assertEquals("vofqzhvfc", response.properties().resourceGraphQuery()); + Assertions.assertEquals("byfmowuxr", response.properties().authenticationSetting()); + Assertions.assertEquals(DiscoveryRuleRelationshipDiscoveryBehavior.ENABLED, + response.properties().discoverRelationships()); + Assertions.assertEquals(DiscoveryRuleRecommendedSignalsBehavior.ENABLED, + response.properties().addRecommendedSignals()); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/DiscoveryRulesDeleteWithResponseMockTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/DiscoveryRulesDeleteWithResponseMockTests.java new file mode 100644 index 000000000000..3718a0030bda --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/DiscoveryRulesDeleteWithResponseMockTests.java @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.cloudhealth.CloudHealthManager; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class DiscoveryRulesDeleteWithResponseMockTests { + @Test + public void testDeleteWithResponse() throws Exception { + String responseStr = "{}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + CloudHealthManager manager = CloudHealthManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + manager.discoveryRules().deleteWithResponse("akkud", "px", "wjplma", com.azure.core.util.Context.NONE); + + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/DiscoveryRulesGetWithResponseMockTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/DiscoveryRulesGetWithResponseMockTests.java new file mode 100644 index 000000000000..64ec7fb3d620 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/DiscoveryRulesGetWithResponseMockTests.java @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.cloudhealth.CloudHealthManager; +import com.azure.resourcemanager.cloudhealth.models.DiscoveryRule; +import com.azure.resourcemanager.cloudhealth.models.DiscoveryRuleRecommendedSignalsBehavior; +import com.azure.resourcemanager.cloudhealth.models.DiscoveryRuleRelationshipDiscoveryBehavior; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class DiscoveryRulesGetWithResponseMockTests { + @Test + public void testGetWithResponse() throws Exception { + String responseStr + = "{\"properties\":{\"provisioningState\":\"Failed\",\"displayName\":\"bfhjxakvvjgsl\",\"resourceGraphQuery\":\"r\",\"authenticationSetting\":\"il\",\"discoverRelationships\":\"Enabled\",\"addRecommendedSignals\":\"Enabled\",\"deletionDate\":\"2021-09-07T03:23:04Z\",\"errorMessage\":\"gkxnyedabg\",\"numberOfDiscoveredEntities\":110774994,\"entityName\":\"dtj\"},\"id\":\"wbcihxuuwh\",\"name\":\"j\",\"type\":\"xccybvpa\"}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + CloudHealthManager manager = CloudHealthManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + DiscoveryRule response = manager.discoveryRules() + .getWithResponse("dmligovibrxk", "mloazuru", "cbgoor", com.azure.core.util.Context.NONE) + .getValue(); + + Assertions.assertEquals("bfhjxakvvjgsl", response.properties().displayName()); + Assertions.assertEquals("r", response.properties().resourceGraphQuery()); + Assertions.assertEquals("il", response.properties().authenticationSetting()); + Assertions.assertEquals(DiscoveryRuleRelationshipDiscoveryBehavior.ENABLED, + response.properties().discoverRelationships()); + Assertions.assertEquals(DiscoveryRuleRecommendedSignalsBehavior.ENABLED, + response.properties().addRecommendedSignals()); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/DiscoveryRulesListByHealthModelMockTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/DiscoveryRulesListByHealthModelMockTests.java new file mode 100644 index 000000000000..1e905977d1d6 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/DiscoveryRulesListByHealthModelMockTests.java @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.cloudhealth.CloudHealthManager; +import com.azure.resourcemanager.cloudhealth.models.DiscoveryRule; +import com.azure.resourcemanager.cloudhealth.models.DiscoveryRuleRecommendedSignalsBehavior; +import com.azure.resourcemanager.cloudhealth.models.DiscoveryRuleRelationshipDiscoveryBehavior; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class DiscoveryRulesListByHealthModelMockTests { + @Test + public void testListByHealthModel() throws Exception { + String responseStr + = "{\"value\":[{\"properties\":{\"provisioningState\":\"Creating\",\"displayName\":\"yhddvia\",\"resourceGraphQuery\":\"egfnmntfpmvmemfn\",\"authenticationSetting\":\"zdwvvbalxl\",\"discoverRelationships\":\"Disabled\",\"addRecommendedSignals\":\"Enabled\",\"deletionDate\":\"2021-02-04T22:36:53Z\",\"errorMessage\":\"db\",\"numberOfDiscoveredEntities\":1253836101,\"entityName\":\"wrd\"},\"id\":\"fukuvsjcswsmystu\",\"name\":\"uqypfcvle\",\"type\":\"chpqbmfpjba\"}]}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + CloudHealthManager manager = CloudHealthManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + PagedIterable response = manager.discoveryRules() + .listByHealthModel("stcyohpfkyrkdbd", "iogsjkmnwq", OffsetDateTime.parse("2021-04-07T00:43:37Z"), + com.azure.core.util.Context.NONE); + + Assertions.assertEquals("yhddvia", response.iterator().next().properties().displayName()); + Assertions.assertEquals("egfnmntfpmvmemfn", response.iterator().next().properties().resourceGraphQuery()); + Assertions.assertEquals("zdwvvbalxl", response.iterator().next().properties().authenticationSetting()); + Assertions.assertEquals(DiscoveryRuleRelationshipDiscoveryBehavior.DISABLED, + response.iterator().next().properties().discoverRelationships()); + Assertions.assertEquals(DiscoveryRuleRecommendedSignalsBehavior.ENABLED, + response.iterator().next().properties().addRecommendedSignals()); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/DynamicDetectionRuleTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/DynamicDetectionRuleTests.java new file mode 100644 index 000000000000..b2621fd2ace5 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/DynamicDetectionRuleTests.java @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.cloudhealth.models.DynamicDetectionRule; +import com.azure.resourcemanager.cloudhealth.models.DynamicThresholdDirection; +import com.azure.resourcemanager.cloudhealth.models.DynamicThresholdModel; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Assertions; + +public final class DynamicDetectionRuleTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + DynamicDetectionRule model = BinaryData.fromString( + "{\"dynamicThresholdModel\":\"AnomalyDetection\",\"modelSensitivity\":85.08706843049872,\"dynamicThresholdDirection\":\"LowerThan\",\"trainingStartTime\":\"2021-08-19T21:44:29Z\"}") + .toObject(DynamicDetectionRule.class); + Assertions.assertEquals(DynamicThresholdModel.ANOMALY_DETECTION, model.dynamicThresholdModel()); + Assertions.assertEquals(85.08706843049872, model.modelSensitivity()); + Assertions.assertEquals(DynamicThresholdDirection.LOWER_THAN, model.dynamicThresholdDirection()); + Assertions.assertEquals(OffsetDateTime.parse("2021-08-19T21:44:29Z"), model.trainingStartTime()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + DynamicDetectionRule model + = new DynamicDetectionRule().withDynamicThresholdModel(DynamicThresholdModel.ANOMALY_DETECTION) + .withModelSensitivity(85.08706843049872) + .withDynamicThresholdDirection(DynamicThresholdDirection.LOWER_THAN) + .withTrainingStartTime(OffsetDateTime.parse("2021-08-19T21:44:29Z")); + model = BinaryData.fromObject(model).toObject(DynamicDetectionRule.class); + Assertions.assertEquals(DynamicThresholdModel.ANOMALY_DETECTION, model.dynamicThresholdModel()); + Assertions.assertEquals(85.08706843049872, model.modelSensitivity()); + Assertions.assertEquals(DynamicThresholdDirection.LOWER_THAN, model.dynamicThresholdDirection()); + Assertions.assertEquals(OffsetDateTime.parse("2021-08-19T21:44:29Z"), model.trainingStartTime()); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/EntitiesCreateOrUpdateWithResponseMockTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/EntitiesCreateOrUpdateWithResponseMockTests.java new file mode 100644 index 000000000000..d20e4c47d41a --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/EntitiesCreateOrUpdateWithResponseMockTests.java @@ -0,0 +1,135 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.cloudhealth.CloudHealthManager; +import com.azure.resourcemanager.cloudhealth.models.AlertConfiguration; +import com.azure.resourcemanager.cloudhealth.models.AlertSeverity; +import com.azure.resourcemanager.cloudhealth.models.AzureMonitorWorkspaceSignalGroup; +import com.azure.resourcemanager.cloudhealth.models.AzureResourceSignalGroup; +import com.azure.resourcemanager.cloudhealth.models.DependenciesAggregationType; +import com.azure.resourcemanager.cloudhealth.models.DependenciesSignalGroup; +import com.azure.resourcemanager.cloudhealth.models.Entity; +import com.azure.resourcemanager.cloudhealth.models.EntityAlerts; +import com.azure.resourcemanager.cloudhealth.models.EntityCoordinates; +import com.azure.resourcemanager.cloudhealth.models.EntityImpact; +import com.azure.resourcemanager.cloudhealth.models.EntityProperties; +import com.azure.resourcemanager.cloudhealth.models.IconDefinition; +import com.azure.resourcemanager.cloudhealth.models.LogAnalyticsSignalGroup; +import com.azure.resourcemanager.cloudhealth.models.SignalAssignment; +import com.azure.resourcemanager.cloudhealth.models.SignalGroup; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class EntitiesCreateOrUpdateWithResponseMockTests { + @Test + public void testCreateOrUpdateWithResponse() throws Exception { + String responseStr + = "{\"properties\":{\"provisioningState\":\"Canceled\",\"displayName\":\"ygdyftumrtw\",\"kind\":\"wjslbiwkojgcyzt\",\"canvasPosition\":{\"x\":63.722844500684204,\"y\":65.66619491167963},\"icon\":{\"iconName\":\"eqphchqnrnr\",\"customData\":\"ehuwrykqgaifmvik\"},\"healthObjective\":15.228066092335435,\"impact\":\"Limited\",\"labels\":{\"nxcvds\":\"ejd\",\"v\":\"hnjivo\",\"jdftuljltd\":\"novqfzge\"},\"signals\":{\"azureResource\":{\"signalAssignments\":[{\"signalDefinitions\":[]},{\"signalDefinitions\":[]},{\"signalDefinitions\":[]}],\"authenticationSetting\":\"tmczuomejwcwwqi\",\"azureResourceId\":\"knssxmojm\"},\"azureLogAnalytics\":{\"signalAssignments\":[{\"signalDefinitions\":[]},{\"signalDefinitions\":[]}],\"authenticationSetting\":\"jpr\",\"logAnalyticsWorkspaceResourceId\":\"kwcf\"},\"azureMonitorWorkspace\":{\"signalAssignments\":[{\"signalDefinitions\":[]},{\"signalDefinitions\":[]}],\"authenticationSetting\":\"yxgtczh\",\"azureMonitorWorkspaceResourceId\":\"ydbsd\"},\"dependencies\":{\"aggregationType\":\"WorstOf\",\"degradedThreshold\":\"xmaehvbbxu\",\"unhealthyThreshold\":\"pltfnhtba\"}},\"discoveredBy\":\"gx\",\"deletionDate\":\"2021-06-15T04:05:50Z\",\"healthState\":\"Unknown\",\"alerts\":{\"unhealthy\":{\"severity\":\"Sev1\",\"description\":\"yhpluodpvruudlgz\",\"actionGroupIds\":[\"hostgktstvdxecl\",\"edqbc\"]},\"degraded\":{\"severity\":\"Sev0\",\"description\":\"h\",\"actionGroupIds\":[\"dqkdlwwqfbu\",\"lkxt\",\"qjfsmlmbtxhw\"]}}},\"id\":\"wsrt\",\"name\":\"wcoezbrhub\",\"type\":\"kh\"}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + CloudHealthManager manager = CloudHealthManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + Entity response = manager.entities() + .define("bshrnsvbuswd") + .withExistingHealthmodel("gf", "pdso") + .withProperties(new EntityProperties().withDisplayName("ycnunvjsrtk") + .withKind("wnopqgikyzirtx") + .withCanvasPosition(new EntityCoordinates().withX(62.656083708137785).withY(37.982496917873455)) + .withIcon(new IconDefinition().withIconName("ntps").withCustomData("gioilqu")) + .withHealthObjective(33.91036481131239D) + .withImpact(EntityImpact.STANDARD) + .withLabels( + mapOf("ghhavgrvkffo", "ieoxorggufhyaomt", "mv", "jzhpjbibgjmfx", "zzxscyhwzdgiruj", "cluyovwxnbkf")) + .withSignals(new SignalGroup() + .withAzureResource(new AzureResourceSignalGroup() + .withSignalAssignments( + Arrays.asList(new SignalAssignment().withSignalDefinitions(Arrays.asList()), + new SignalAssignment().withSignalDefinitions(Arrays.asList()), + new SignalAssignment().withSignalDefinitions(Arrays.asList()))) + .withAuthenticationSetting("vzzbtdcq") + .withAzureResourceId("pniyujviyl")) + .withAzureLogAnalytics(new LogAnalyticsSignalGroup() + .withSignalAssignments( + Arrays.asList(new SignalAssignment().withSignalDefinitions(Arrays.asList()), + new SignalAssignment().withSignalDefinitions(Arrays.asList()))) + .withAuthenticationSetting("fssnrbgyefrymsga") + .withLogAnalyticsWorkspaceResourceId("j")) + .withAzureMonitorWorkspace(new AzureMonitorWorkspaceSignalGroup() + .withSignalAssignments( + Arrays.asList(new SignalAssignment().withSignalDefinitions(Arrays.asList()))) + .withAuthenticationSetting("cotmr") + .withAzureMonitorWorkspaceResourceId("hirctymoxoftpipi")) + .withDependencies( + new DependenciesSignalGroup().withAggregationType(DependenciesAggregationType.THRESHOLDS) + .withDegradedThreshold("uh") + .withUnhealthyThreshold("cpqjlihhyu"))) + .withAlerts(new EntityAlerts() + .withUnhealthy(new AlertConfiguration().withSeverity(AlertSeverity.SEV2) + .withDescription("reuzvxurisjn") + .withActionGroupIds(Arrays.asList("txifqj", "gxmrhublwp", "esutrgjupauutpw", "qhih"))) + .withDegraded(new AlertConfiguration().withSeverity(AlertSeverity.SEV4) + .withDescription("w") + .withActionGroupIds(Arrays.asList("fqntcyp"))))) + .create(); + + Assertions.assertEquals("ygdyftumrtw", response.properties().displayName()); + Assertions.assertEquals("wjslbiwkojgcyzt", response.properties().kind()); + Assertions.assertEquals(63.722844500684204, response.properties().canvasPosition().x()); + Assertions.assertEquals(65.66619491167963, response.properties().canvasPosition().y()); + Assertions.assertEquals("eqphchqnrnr", response.properties().icon().iconName()); + Assertions.assertEquals("ehuwrykqgaifmvik", response.properties().icon().customData()); + Assertions.assertEquals(15.228066092335435D, response.properties().healthObjective()); + Assertions.assertEquals(EntityImpact.LIMITED, response.properties().impact()); + Assertions.assertEquals("ejd", response.properties().labels().get("nxcvds")); + Assertions.assertEquals("tmczuomejwcwwqi", + response.properties().signals().azureResource().authenticationSetting()); + Assertions.assertEquals("knssxmojm", response.properties().signals().azureResource().azureResourceId()); + Assertions.assertEquals("jpr", response.properties().signals().azureLogAnalytics().authenticationSetting()); + Assertions.assertEquals("kwcf", + response.properties().signals().azureLogAnalytics().logAnalyticsWorkspaceResourceId()); + Assertions.assertEquals("yxgtczh", + response.properties().signals().azureMonitorWorkspace().authenticationSetting()); + Assertions.assertEquals("ydbsd", + response.properties().signals().azureMonitorWorkspace().azureMonitorWorkspaceResourceId()); + Assertions.assertEquals(DependenciesAggregationType.WORST_OF, + response.properties().signals().dependencies().aggregationType()); + Assertions.assertEquals("xmaehvbbxu", response.properties().signals().dependencies().degradedThreshold()); + Assertions.assertEquals("pltfnhtba", response.properties().signals().dependencies().unhealthyThreshold()); + Assertions.assertEquals(AlertSeverity.SEV1, response.properties().alerts().unhealthy().severity()); + Assertions.assertEquals("yhpluodpvruudlgz", response.properties().alerts().unhealthy().description()); + Assertions.assertEquals("hostgktstvdxecl", response.properties().alerts().unhealthy().actionGroupIds().get(0)); + Assertions.assertEquals(AlertSeverity.SEV0, response.properties().alerts().degraded().severity()); + Assertions.assertEquals("h", response.properties().alerts().degraded().description()); + Assertions.assertEquals("dqkdlwwqfbu", response.properties().alerts().degraded().actionGroupIds().get(0)); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/EntitiesDeleteWithResponseMockTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/EntitiesDeleteWithResponseMockTests.java new file mode 100644 index 000000000000..e2d98d0bc8df --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/EntitiesDeleteWithResponseMockTests.java @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.cloudhealth.CloudHealthManager; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class EntitiesDeleteWithResponseMockTests { + @Test + public void testDeleteWithResponse() throws Exception { + String responseStr = "{}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + CloudHealthManager manager = CloudHealthManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + manager.entities().deleteWithResponse("uenvrkp", "ou", "ibreb", com.azure.core.util.Context.NONE); + + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/EntitiesGetWithResponseMockTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/EntitiesGetWithResponseMockTests.java new file mode 100644 index 000000000000..c6f4b737a8fc --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/EntitiesGetWithResponseMockTests.java @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.cloudhealth.CloudHealthManager; +import com.azure.resourcemanager.cloudhealth.models.AlertSeverity; +import com.azure.resourcemanager.cloudhealth.models.DependenciesAggregationType; +import com.azure.resourcemanager.cloudhealth.models.Entity; +import com.azure.resourcemanager.cloudhealth.models.EntityImpact; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class EntitiesGetWithResponseMockTests { + @Test + public void testGetWithResponse() throws Exception { + String responseStr + = "{\"properties\":{\"provisioningState\":\"Creating\",\"displayName\":\"vrwxkv\",\"kind\":\"k\",\"canvasPosition\":{\"x\":82.80639125467376,\"y\":93.13111838664105},\"icon\":{\"iconName\":\"gvjayvblmh\",\"customData\":\"zuhbxvvyhgsopb\"},\"healthObjective\":77.12165867646767,\"impact\":\"Suppressed\",\"labels\":{\"mctlpdngitv\":\"uvwzfbnh\"},\"signals\":{\"azureResource\":{\"signalAssignments\":[{\"signalDefinitions\":[]},{\"signalDefinitions\":[]},{\"signalDefinitions\":[]},{\"signalDefinitions\":[]}],\"authenticationSetting\":\"ixkwmyijejveg\",\"azureResourceId\":\"hbpnaixexccbd\"},\"azureLogAnalytics\":{\"signalAssignments\":[{\"signalDefinitions\":[]},{\"signalDefinitions\":[]},{\"signalDefinitions\":[]},{\"signalDefinitions\":[]}],\"authenticationSetting\":\"hcexdrrvqa\",\"logAnalyticsWorkspaceResourceId\":\"qkghtpwijnhy\"},\"azureMonitorWorkspace\":{\"signalAssignments\":[{\"signalDefinitions\":[]}],\"authenticationSetting\":\"ycxzbfvoo\",\"azureMonitorWorkspaceResourceId\":\"vrvmtgjqppyost\"},\"dependencies\":{\"aggregationType\":\"WorstOf\",\"degradedThreshold\":\"myhgfipnsxkmc\",\"unhealthyThreshold\":\"ekrrjr\"}},\"discoveredBy\":\"fxtsgum\",\"deletionDate\":\"2021-06-07T04:38:31Z\",\"healthState\":\"Healthy\",\"alerts\":{\"unhealthy\":{\"severity\":\"Sev0\",\"description\":\"slol\",\"actionGroupIds\":[\"vuzlm\",\"felfktg\"]},\"degraded\":{\"severity\":\"Sev3\",\"description\":\"pwjxezn\",\"actionGroupIds\":[\"brnjwmw\"]}}},\"id\":\"nbsazejjoqkag\",\"name\":\"hsxttaugzxnf\",\"type\":\"azpxdtnkdmkqjjl\"}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + CloudHealthManager manager = CloudHealthManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + Entity response = manager.entities() + .getWithResponse("irryuzhlh", "joqrvqqaatj", "nrvgoupmfiibfgg", com.azure.core.util.Context.NONE) + .getValue(); + + Assertions.assertEquals("vrwxkv", response.properties().displayName()); + Assertions.assertEquals("k", response.properties().kind()); + Assertions.assertEquals(82.80639125467376, response.properties().canvasPosition().x()); + Assertions.assertEquals(93.13111838664105, response.properties().canvasPosition().y()); + Assertions.assertEquals("gvjayvblmh", response.properties().icon().iconName()); + Assertions.assertEquals("zuhbxvvyhgsopb", response.properties().icon().customData()); + Assertions.assertEquals(77.12165867646767D, response.properties().healthObjective()); + Assertions.assertEquals(EntityImpact.SUPPRESSED, response.properties().impact()); + Assertions.assertEquals("uvwzfbnh", response.properties().labels().get("mctlpdngitv")); + Assertions.assertEquals("ixkwmyijejveg", + response.properties().signals().azureResource().authenticationSetting()); + Assertions.assertEquals("hbpnaixexccbd", response.properties().signals().azureResource().azureResourceId()); + Assertions.assertEquals("hcexdrrvqa", + response.properties().signals().azureLogAnalytics().authenticationSetting()); + Assertions.assertEquals("qkghtpwijnhy", + response.properties().signals().azureLogAnalytics().logAnalyticsWorkspaceResourceId()); + Assertions.assertEquals("ycxzbfvoo", + response.properties().signals().azureMonitorWorkspace().authenticationSetting()); + Assertions.assertEquals("vrvmtgjqppyost", + response.properties().signals().azureMonitorWorkspace().azureMonitorWorkspaceResourceId()); + Assertions.assertEquals(DependenciesAggregationType.WORST_OF, + response.properties().signals().dependencies().aggregationType()); + Assertions.assertEquals("myhgfipnsxkmc", response.properties().signals().dependencies().degradedThreshold()); + Assertions.assertEquals("ekrrjr", response.properties().signals().dependencies().unhealthyThreshold()); + Assertions.assertEquals(AlertSeverity.SEV0, response.properties().alerts().unhealthy().severity()); + Assertions.assertEquals("slol", response.properties().alerts().unhealthy().description()); + Assertions.assertEquals("vuzlm", response.properties().alerts().unhealthy().actionGroupIds().get(0)); + Assertions.assertEquals(AlertSeverity.SEV3, response.properties().alerts().degraded().severity()); + Assertions.assertEquals("pwjxezn", response.properties().alerts().degraded().description()); + Assertions.assertEquals("brnjwmw", response.properties().alerts().degraded().actionGroupIds().get(0)); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/EntitiesListByHealthModelMockTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/EntitiesListByHealthModelMockTests.java new file mode 100644 index 000000000000..1b3203855231 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/EntitiesListByHealthModelMockTests.java @@ -0,0 +1,85 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.cloudhealth.CloudHealthManager; +import com.azure.resourcemanager.cloudhealth.models.AlertSeverity; +import com.azure.resourcemanager.cloudhealth.models.DependenciesAggregationType; +import com.azure.resourcemanager.cloudhealth.models.Entity; +import com.azure.resourcemanager.cloudhealth.models.EntityImpact; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class EntitiesListByHealthModelMockTests { + @Test + public void testListByHealthModel() throws Exception { + String responseStr + = "{\"value\":[{\"properties\":{\"provisioningState\":\"Succeeded\",\"displayName\":\"fiakpjpqqm\",\"kind\":\"d\",\"canvasPosition\":{\"x\":23.946302596011293,\"y\":23.23506119623675},\"icon\":{\"iconName\":\"yeozphvwauyqncy\",\"customData\":\"p\"},\"healthObjective\":47.120863278217264,\"impact\":\"Limited\",\"labels\":{\"upev\":\"wx\",\"lmcuvhixb\":\"hfstotxhojujbyp\"},\"signals\":{\"azureResource\":{\"signalAssignments\":[{\"signalDefinitions\":[]}],\"authenticationSetting\":\"n\",\"azureResourceId\":\"lrcoolsttpki\"},\"azureLogAnalytics\":{\"signalAssignments\":[{\"signalDefinitions\":[]},{\"signalDefinitions\":[]},{\"signalDefinitions\":[]},{\"signalDefinitions\":[]}],\"authenticationSetting\":\"nujrywvtyl\",\"logAnalyticsWorkspaceResourceId\":\"fpncurdo\"},\"azureMonitorWorkspace\":{\"signalAssignments\":[{\"signalDefinitions\":[]},{\"signalDefinitions\":[]}],\"authenticationSetting\":\"thtywub\",\"azureMonitorWorkspaceResourceId\":\"cbihwqk\"},\"dependencies\":{\"aggregationType\":\"Thresholds\",\"degradedThreshold\":\"twjchrdg\",\"unhealthyThreshold\":\"hxumwctondzj\"}},\"discoveredBy\":\"udfdlwgg\",\"deletionDate\":\"2021-07-30T14:09:03Z\",\"healthState\":\"Healthy\",\"alerts\":{\"unhealthy\":{\"severity\":\"Sev2\",\"description\":\"tgseinqfiufxqkn\",\"actionGroupIds\":[\"gnepttwqmsni\",\"fcdmqnrojlpijn\",\"rxfrddhc\",\"atiz\"]},\"degraded\":{\"severity\":\"Sev1\",\"description\":\"asxifto\",\"actionGroupIds\":[\"zh\",\"tw\",\"sgogczhonnxk\",\"lgnyhmo\"]}}},\"id\":\"xkk\",\"name\":\"thrrgh\",\"type\":\"jbdhqxvc\"}]}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + CloudHealthManager manager = CloudHealthManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + PagedIterable response = manager.entities() + .listByHealthModel("aays", "kixqtnqtt", OffsetDateTime.parse("2021-01-22T12:04:18Z"), + com.azure.core.util.Context.NONE); + + Assertions.assertEquals("fiakpjpqqm", response.iterator().next().properties().displayName()); + Assertions.assertEquals("d", response.iterator().next().properties().kind()); + Assertions.assertEquals(23.946302596011293, response.iterator().next().properties().canvasPosition().x()); + Assertions.assertEquals(23.23506119623675, response.iterator().next().properties().canvasPosition().y()); + Assertions.assertEquals("yeozphvwauyqncy", response.iterator().next().properties().icon().iconName()); + Assertions.assertEquals("p", response.iterator().next().properties().icon().customData()); + Assertions.assertEquals(47.120863278217264D, response.iterator().next().properties().healthObjective()); + Assertions.assertEquals(EntityImpact.LIMITED, response.iterator().next().properties().impact()); + Assertions.assertEquals("wx", response.iterator().next().properties().labels().get("upev")); + Assertions.assertEquals("n", + response.iterator().next().properties().signals().azureResource().authenticationSetting()); + Assertions.assertEquals("lrcoolsttpki", + response.iterator().next().properties().signals().azureResource().azureResourceId()); + Assertions.assertEquals("nujrywvtyl", + response.iterator().next().properties().signals().azureLogAnalytics().authenticationSetting()); + Assertions.assertEquals("fpncurdo", + response.iterator().next().properties().signals().azureLogAnalytics().logAnalyticsWorkspaceResourceId()); + Assertions.assertEquals("thtywub", + response.iterator().next().properties().signals().azureMonitorWorkspace().authenticationSetting()); + Assertions.assertEquals("cbihwqk", + response.iterator() + .next() + .properties() + .signals() + .azureMonitorWorkspace() + .azureMonitorWorkspaceResourceId()); + Assertions.assertEquals(DependenciesAggregationType.THRESHOLDS, + response.iterator().next().properties().signals().dependencies().aggregationType()); + Assertions.assertEquals("twjchrdg", + response.iterator().next().properties().signals().dependencies().degradedThreshold()); + Assertions.assertEquals("hxumwctondzj", + response.iterator().next().properties().signals().dependencies().unhealthyThreshold()); + Assertions.assertEquals(AlertSeverity.SEV2, + response.iterator().next().properties().alerts().unhealthy().severity()); + Assertions.assertEquals("tgseinqfiufxqkn", + response.iterator().next().properties().alerts().unhealthy().description()); + Assertions.assertEquals("gnepttwqmsni", + response.iterator().next().properties().alerts().unhealthy().actionGroupIds().get(0)); + Assertions.assertEquals(AlertSeverity.SEV1, + response.iterator().next().properties().alerts().degraded().severity()); + Assertions.assertEquals("asxifto", response.iterator().next().properties().alerts().degraded().description()); + Assertions.assertEquals("zh", + response.iterator().next().properties().alerts().degraded().actionGroupIds().get(0)); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/EntityAlertsTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/EntityAlertsTests.java new file mode 100644 index 000000000000..ea67302579ac --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/EntityAlertsTests.java @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.cloudhealth.models.AlertConfiguration; +import com.azure.resourcemanager.cloudhealth.models.AlertSeverity; +import com.azure.resourcemanager.cloudhealth.models.EntityAlerts; +import java.util.Arrays; +import org.junit.jupiter.api.Assertions; + +public final class EntityAlertsTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + EntityAlerts model = BinaryData.fromString( + "{\"unhealthy\":{\"severity\":\"Sev4\",\"description\":\"itxmedjvcslynqww\",\"actionGroupIds\":[\"zzhxgktrm\"]},\"degraded\":{\"severity\":\"Sev0\",\"description\":\"apkteoellwptfdyg\",\"actionGroupIds\":[\"b\",\"ac\",\"op\"]}}") + .toObject(EntityAlerts.class); + Assertions.assertEquals(AlertSeverity.SEV4, model.unhealthy().severity()); + Assertions.assertEquals("itxmedjvcslynqww", model.unhealthy().description()); + Assertions.assertEquals("zzhxgktrm", model.unhealthy().actionGroupIds().get(0)); + Assertions.assertEquals(AlertSeverity.SEV0, model.degraded().severity()); + Assertions.assertEquals("apkteoellwptfdyg", model.degraded().description()); + Assertions.assertEquals("b", model.degraded().actionGroupIds().get(0)); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + EntityAlerts model = new EntityAlerts() + .withUnhealthy(new AlertConfiguration().withSeverity(AlertSeverity.SEV4) + .withDescription("itxmedjvcslynqww") + .withActionGroupIds(Arrays.asList("zzhxgktrm"))) + .withDegraded(new AlertConfiguration().withSeverity(AlertSeverity.SEV0) + .withDescription("apkteoellwptfdyg") + .withActionGroupIds(Arrays.asList("b", "ac", "op"))); + model = BinaryData.fromObject(model).toObject(EntityAlerts.class); + Assertions.assertEquals(AlertSeverity.SEV4, model.unhealthy().severity()); + Assertions.assertEquals("itxmedjvcslynqww", model.unhealthy().description()); + Assertions.assertEquals("zzhxgktrm", model.unhealthy().actionGroupIds().get(0)); + Assertions.assertEquals(AlertSeverity.SEV0, model.degraded().severity()); + Assertions.assertEquals("apkteoellwptfdyg", model.degraded().description()); + Assertions.assertEquals("b", model.degraded().actionGroupIds().get(0)); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/EntityCoordinatesTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/EntityCoordinatesTests.java new file mode 100644 index 000000000000..906b4d632935 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/EntityCoordinatesTests.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.cloudhealth.models.EntityCoordinates; +import org.junit.jupiter.api.Assertions; + +public final class EntityCoordinatesTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + EntityCoordinates model = BinaryData.fromString("{\"x\":98.37234780605657,\"y\":7.795145831536255}") + .toObject(EntityCoordinates.class); + Assertions.assertEquals(98.37234780605657, model.x()); + Assertions.assertEquals(7.795145831536255, model.y()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + EntityCoordinates model = new EntityCoordinates().withX(98.37234780605657).withY(7.795145831536255); + model = BinaryData.fromObject(model).toObject(EntityCoordinates.class); + Assertions.assertEquals(98.37234780605657, model.x()); + Assertions.assertEquals(7.795145831536255, model.y()); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/EntityInnerTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/EntityInnerTests.java new file mode 100644 index 000000000000..e2a4cbf087b1 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/EntityInnerTests.java @@ -0,0 +1,170 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.cloudhealth.fluent.models.EntityInner; +import com.azure.resourcemanager.cloudhealth.models.AlertConfiguration; +import com.azure.resourcemanager.cloudhealth.models.AlertSeverity; +import com.azure.resourcemanager.cloudhealth.models.AzureMonitorWorkspaceSignalGroup; +import com.azure.resourcemanager.cloudhealth.models.AzureResourceSignalGroup; +import com.azure.resourcemanager.cloudhealth.models.DependenciesAggregationType; +import com.azure.resourcemanager.cloudhealth.models.DependenciesSignalGroup; +import com.azure.resourcemanager.cloudhealth.models.EntityAlerts; +import com.azure.resourcemanager.cloudhealth.models.EntityCoordinates; +import com.azure.resourcemanager.cloudhealth.models.EntityImpact; +import com.azure.resourcemanager.cloudhealth.models.EntityProperties; +import com.azure.resourcemanager.cloudhealth.models.IconDefinition; +import com.azure.resourcemanager.cloudhealth.models.LogAnalyticsSignalGroup; +import com.azure.resourcemanager.cloudhealth.models.SignalAssignment; +import com.azure.resourcemanager.cloudhealth.models.SignalGroup; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; + +public final class EntityInnerTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + EntityInner model = BinaryData.fromString( + "{\"properties\":{\"provisioningState\":\"Canceled\",\"displayName\":\"dpydn\",\"kind\":\"hxdeoejz\",\"canvasPosition\":{\"x\":3.966818601093458,\"y\":17.378484722859245},\"icon\":{\"iconName\":\"ttgzfbis\",\"customData\":\"bkh\"},\"healthObjective\":99.54184484128005,\"impact\":\"Suppressed\",\"labels\":{\"honowkgshwank\":\"dphagalpbuxwgip\"},\"signals\":{\"azureResource\":{\"signalAssignments\":[{\"signalDefinitions\":[\"jeputtmrywn\",\"zoqftiyqzrnkcqvy\",\"lwh\"]},{\"signalDefinitions\":[\"sicohoqqnwvlry\",\"vwhheunmmqhgyx\",\"konocu\"]}],\"authenticationSetting\":\"oklyaxuconuq\",\"azureResourceId\":\"zf\"},\"azureLogAnalytics\":{\"signalAssignments\":[{\"signalDefinitions\":[\"ewrmjmwvvjektc\"]},{\"signalDefinitions\":[\"enhwlrs\",\"frzpwvlqdqgb\"]},{\"signalDefinitions\":[\"ylihkaetckt\",\"fcivfsnkym\",\"ctq\"]},{\"signalDefinitions\":[\"fbebrjcxer\"]}],\"authenticationSetting\":\"uwutttxfvjrbi\",\"logAnalyticsWorkspaceResourceId\":\"phxepcyvahf\"},\"azureMonitorWorkspace\":{\"signalAssignments\":[{\"signalDefinitions\":[\"qxj\"]},{\"signalDefinitions\":[\"ujqgidok\",\"jljyoxgv\",\"ltbgsncghkj\",\"szzhbijhtxfvgxbf\"]},{\"signalDefinitions\":[\"xnehmpvec\",\"godebfqkkrbmpu\"]},{\"signalDefinitions\":[\"riwflzlfb\"]}],\"authenticationSetting\":\"zpuzycisp\",\"azureMonitorWorkspaceResourceId\":\"qzahmgkbrp\"},\"dependencies\":{\"aggregationType\":\"WorstOf\",\"degradedThreshold\":\"ibnuqqkpik\",\"unhealthyThreshold\":\"rgvtqag\"}},\"discoveredBy\":\"uynhijg\",\"deletionDate\":\"2021-02-22T23:18:30Z\",\"healthState\":\"Error\",\"alerts\":{\"unhealthy\":{\"severity\":\"Sev2\",\"description\":\"butr\",\"actionGroupIds\":[\"na\",\"zmhjrunmp\"]},\"degraded\":{\"severity\":\"Sev1\",\"description\":\"bh\",\"actionGroupIds\":[\"l\",\"nkxmyskpbhenbtk\",\"xywnytnrsynlqidy\"]}}},\"id\":\"xczfcl\",\"name\":\"aaxdbabphlwrq\",\"type\":\"fkts\"}") + .toObject(EntityInner.class); + Assertions.assertEquals("dpydn", model.properties().displayName()); + Assertions.assertEquals("hxdeoejz", model.properties().kind()); + Assertions.assertEquals(3.966818601093458, model.properties().canvasPosition().x()); + Assertions.assertEquals(17.378484722859245, model.properties().canvasPosition().y()); + Assertions.assertEquals("ttgzfbis", model.properties().icon().iconName()); + Assertions.assertEquals("bkh", model.properties().icon().customData()); + Assertions.assertEquals(99.54184484128005D, model.properties().healthObjective()); + Assertions.assertEquals(EntityImpact.SUPPRESSED, model.properties().impact()); + Assertions.assertEquals("dphagalpbuxwgip", model.properties().labels().get("honowkgshwank")); + Assertions.assertEquals("jeputtmrywn", + model.properties().signals().azureResource().signalAssignments().get(0).signalDefinitions().get(0)); + Assertions.assertEquals("oklyaxuconuq", model.properties().signals().azureResource().authenticationSetting()); + Assertions.assertEquals("zf", model.properties().signals().azureResource().azureResourceId()); + Assertions.assertEquals("ewrmjmwvvjektc", + model.properties().signals().azureLogAnalytics().signalAssignments().get(0).signalDefinitions().get(0)); + Assertions.assertEquals("uwutttxfvjrbi", + model.properties().signals().azureLogAnalytics().authenticationSetting()); + Assertions.assertEquals("phxepcyvahf", + model.properties().signals().azureLogAnalytics().logAnalyticsWorkspaceResourceId()); + Assertions.assertEquals("qxj", + model.properties().signals().azureMonitorWorkspace().signalAssignments().get(0).signalDefinitions().get(0)); + Assertions.assertEquals("zpuzycisp", + model.properties().signals().azureMonitorWorkspace().authenticationSetting()); + Assertions.assertEquals("qzahmgkbrp", + model.properties().signals().azureMonitorWorkspace().azureMonitorWorkspaceResourceId()); + Assertions.assertEquals(DependenciesAggregationType.WORST_OF, + model.properties().signals().dependencies().aggregationType()); + Assertions.assertEquals("ibnuqqkpik", model.properties().signals().dependencies().degradedThreshold()); + Assertions.assertEquals("rgvtqag", model.properties().signals().dependencies().unhealthyThreshold()); + Assertions.assertEquals(AlertSeverity.SEV2, model.properties().alerts().unhealthy().severity()); + Assertions.assertEquals("butr", model.properties().alerts().unhealthy().description()); + Assertions.assertEquals("na", model.properties().alerts().unhealthy().actionGroupIds().get(0)); + Assertions.assertEquals(AlertSeverity.SEV1, model.properties().alerts().degraded().severity()); + Assertions.assertEquals("bh", model.properties().alerts().degraded().description()); + Assertions.assertEquals("l", model.properties().alerts().degraded().actionGroupIds().get(0)); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + EntityInner model + = new EntityInner() + .withProperties(new EntityProperties().withDisplayName("dpydn") + .withKind("hxdeoejz") + .withCanvasPosition(new EntityCoordinates().withX(3.966818601093458).withY(17.378484722859245)) + .withIcon(new IconDefinition().withIconName("ttgzfbis").withCustomData("bkh")) + .withHealthObjective(99.54184484128005D) + .withImpact(EntityImpact.SUPPRESSED) + .withLabels(mapOf("honowkgshwank", "dphagalpbuxwgip")) + .withSignals(new SignalGroup() + .withAzureResource(new AzureResourceSignalGroup() + .withSignalAssignments(Arrays.asList( + new SignalAssignment() + .withSignalDefinitions(Arrays.asList("jeputtmrywn", "zoqftiyqzrnkcqvy", "lwh")), + new SignalAssignment().withSignalDefinitions( + Arrays.asList("sicohoqqnwvlry", "vwhheunmmqhgyx", "konocu")))) + .withAuthenticationSetting("oklyaxuconuq") + .withAzureResourceId("zf")) + .withAzureLogAnalytics(new LogAnalyticsSignalGroup() + .withSignalAssignments(Arrays.asList( + new SignalAssignment().withSignalDefinitions(Arrays.asList("ewrmjmwvvjektc")), + new SignalAssignment().withSignalDefinitions(Arrays.asList("enhwlrs", "frzpwvlqdqgb")), + new SignalAssignment() + .withSignalDefinitions(Arrays.asList("ylihkaetckt", "fcivfsnkym", "ctq")), + new SignalAssignment().withSignalDefinitions(Arrays.asList("fbebrjcxer")))) + .withAuthenticationSetting("uwutttxfvjrbi") + .withLogAnalyticsWorkspaceResourceId("phxepcyvahf")) + .withAzureMonitorWorkspace(new AzureMonitorWorkspaceSignalGroup() + .withSignalAssignments( + Arrays.asList(new SignalAssignment().withSignalDefinitions(Arrays.asList("qxj")), + new SignalAssignment().withSignalDefinitions( + Arrays.asList("ujqgidok", "jljyoxgv", "ltbgsncghkj", "szzhbijhtxfvgxbf")), + new SignalAssignment() + .withSignalDefinitions(Arrays.asList("xnehmpvec", "godebfqkkrbmpu")), + new SignalAssignment().withSignalDefinitions(Arrays.asList("riwflzlfb")))) + .withAuthenticationSetting("zpuzycisp") + .withAzureMonitorWorkspaceResourceId("qzahmgkbrp")) + .withDependencies( + new DependenciesSignalGroup().withAggregationType(DependenciesAggregationType.WORST_OF) + .withDegradedThreshold("ibnuqqkpik") + .withUnhealthyThreshold("rgvtqag"))) + .withAlerts(new EntityAlerts() + .withUnhealthy(new AlertConfiguration().withSeverity(AlertSeverity.SEV2) + .withDescription("butr") + .withActionGroupIds(Arrays.asList("na", "zmhjrunmp"))) + .withDegraded(new AlertConfiguration().withSeverity(AlertSeverity.SEV1) + .withDescription("bh") + .withActionGroupIds(Arrays.asList("l", "nkxmyskpbhenbtk", "xywnytnrsynlqidy"))))); + model = BinaryData.fromObject(model).toObject(EntityInner.class); + Assertions.assertEquals("dpydn", model.properties().displayName()); + Assertions.assertEquals("hxdeoejz", model.properties().kind()); + Assertions.assertEquals(3.966818601093458, model.properties().canvasPosition().x()); + Assertions.assertEquals(17.378484722859245, model.properties().canvasPosition().y()); + Assertions.assertEquals("ttgzfbis", model.properties().icon().iconName()); + Assertions.assertEquals("bkh", model.properties().icon().customData()); + Assertions.assertEquals(99.54184484128005D, model.properties().healthObjective()); + Assertions.assertEquals(EntityImpact.SUPPRESSED, model.properties().impact()); + Assertions.assertEquals("dphagalpbuxwgip", model.properties().labels().get("honowkgshwank")); + Assertions.assertEquals("jeputtmrywn", + model.properties().signals().azureResource().signalAssignments().get(0).signalDefinitions().get(0)); + Assertions.assertEquals("oklyaxuconuq", model.properties().signals().azureResource().authenticationSetting()); + Assertions.assertEquals("zf", model.properties().signals().azureResource().azureResourceId()); + Assertions.assertEquals("ewrmjmwvvjektc", + model.properties().signals().azureLogAnalytics().signalAssignments().get(0).signalDefinitions().get(0)); + Assertions.assertEquals("uwutttxfvjrbi", + model.properties().signals().azureLogAnalytics().authenticationSetting()); + Assertions.assertEquals("phxepcyvahf", + model.properties().signals().azureLogAnalytics().logAnalyticsWorkspaceResourceId()); + Assertions.assertEquals("qxj", + model.properties().signals().azureMonitorWorkspace().signalAssignments().get(0).signalDefinitions().get(0)); + Assertions.assertEquals("zpuzycisp", + model.properties().signals().azureMonitorWorkspace().authenticationSetting()); + Assertions.assertEquals("qzahmgkbrp", + model.properties().signals().azureMonitorWorkspace().azureMonitorWorkspaceResourceId()); + Assertions.assertEquals(DependenciesAggregationType.WORST_OF, + model.properties().signals().dependencies().aggregationType()); + Assertions.assertEquals("ibnuqqkpik", model.properties().signals().dependencies().degradedThreshold()); + Assertions.assertEquals("rgvtqag", model.properties().signals().dependencies().unhealthyThreshold()); + Assertions.assertEquals(AlertSeverity.SEV2, model.properties().alerts().unhealthy().severity()); + Assertions.assertEquals("butr", model.properties().alerts().unhealthy().description()); + Assertions.assertEquals("na", model.properties().alerts().unhealthy().actionGroupIds().get(0)); + Assertions.assertEquals(AlertSeverity.SEV1, model.properties().alerts().degraded().severity()); + Assertions.assertEquals("bh", model.properties().alerts().degraded().description()); + Assertions.assertEquals("l", model.properties().alerts().degraded().actionGroupIds().get(0)); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/EntityListResultTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/EntityListResultTests.java new file mode 100644 index 000000000000..389dacf3017c --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/EntityListResultTests.java @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.cloudhealth.implementation.models.EntityListResult; +import com.azure.resourcemanager.cloudhealth.models.AlertSeverity; +import com.azure.resourcemanager.cloudhealth.models.DependenciesAggregationType; +import com.azure.resourcemanager.cloudhealth.models.EntityImpact; +import org.junit.jupiter.api.Assertions; + +public final class EntityListResultTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + EntityListResult model = BinaryData.fromString( + "{\"value\":[{\"properties\":{\"provisioningState\":\"Deleting\",\"displayName\":\"zpostmgrcfbu\",\"kind\":\"mfqjhhkxbp\",\"canvasPosition\":{\"x\":93.7726067893376,\"y\":41.362515263932465},\"icon\":{\"iconName\":\"xjyngudivk\",\"customData\":\"swbxqz\"},\"healthObjective\":15.572520547165258,\"impact\":\"Limited\",\"labels\":{\"dxxiv\":\"j\",\"aqtdoqmcbx\":\"tvtc\"},\"signals\":{\"azureResource\":{\"signalAssignments\":[{\"signalDefinitions\":[]},{\"signalDefinitions\":[]},{\"signalDefinitions\":[]}],\"authenticationSetting\":\"slqb\",\"azureResourceId\":\"sfxobl\"},\"azureLogAnalytics\":{\"signalAssignments\":[{\"signalDefinitions\":[]},{\"signalDefinitions\":[]}],\"authenticationSetting\":\"lmpewwwfbkr\",\"logAnalyticsWorkspaceResourceId\":\"rn\"},\"azureMonitorWorkspace\":{\"signalAssignments\":[{\"signalDefinitions\":[]},{\"signalDefinitions\":[]},{\"signalDefinitions\":[]},{\"signalDefinitions\":[]}],\"authenticationSetting\":\"q\",\"azureMonitorWorkspaceResourceId\":\"ohxcrsbfova\"},\"dependencies\":{\"aggregationType\":\"WorstOf\",\"degradedThreshold\":\"v\",\"unhealthyThreshold\":\"hsqfsubcgjbirxbp\"}},\"discoveredBy\":\"srfbjfdtwss\",\"deletionDate\":\"2021-06-01T18:34:35Z\",\"healthState\":\"Error\",\"alerts\":{\"unhealthy\":{\"severity\":\"Sev4\",\"description\":\"exilzznfqqnvwpmq\",\"actionGroupIds\":[\"uoujmkcjhwqy\",\"jrybnwjewgdrjer\"]},\"degraded\":{\"severity\":\"Sev4\",\"description\":\"nqpeh\",\"actionGroupIds\":[\"oygmift\"]}}},\"id\":\"zdnds\",\"name\":\"gnayqigynduh\",\"type\":\"vhqlkthumaqo\"},{\"properties\":{\"provisioningState\":\"Deleting\",\"displayName\":\"duiertgcc\",\"kind\":\"vaolpsslqlf\",\"canvasPosition\":{\"x\":55.09905966116355,\"y\":76.73665651224995},\"icon\":{\"iconName\":\"lzpswiydm\",\"customData\":\"yhz\"},\"healthObjective\":9.457104362985113,\"impact\":\"Limited\",\"labels\":{\"daodvxzbncblyl\":\"mnvdfzn\",\"erscdntne\":\"stdbhhxsrzdzu\",\"tmweriofzpyq\":\"fiwjmygtdssls\",\"hhszh\":\"emwabnet\"},\"signals\":{\"azureResource\":{\"signalAssignments\":[{\"signalDefinitions\":[]},{\"signalDefinitions\":[]},{\"signalDefinitions\":[]},{\"signalDefinitions\":[]}],\"authenticationSetting\":\"wiwubm\",\"azureResourceId\":\"mbes\"},\"azureLogAnalytics\":{\"signalAssignments\":[{\"signalDefinitions\":[]}],\"authenticationSetting\":\"wwtppj\",\"logAnalyticsWorkspaceResourceId\":\"lcxog\"},\"azureMonitorWorkspace\":{\"signalAssignments\":[{\"signalDefinitions\":[]}],\"authenticationSetting\":\"nzmnsikvm\",\"azureMonitorWorkspaceResourceId\":\"qzeqqkdltfzxm\"},\"dependencies\":{\"aggregationType\":\"WorstOf\",\"degradedThreshold\":\"gureodkwobdag\",\"unhealthyThreshold\":\"ibqdxbxwakbogqx\"}},\"discoveredBy\":\"lkzgxhuriplbp\",\"deletionDate\":\"2021-08-20T16:40:33Z\",\"healthState\":\"Unknown\",\"alerts\":{\"unhealthy\":{\"severity\":\"Sev0\",\"description\":\"xmubyyntwlrbq\",\"actionGroupIds\":[\"ievseotgqrllt\",\"u\",\"lauwzizxbmpgcjef\",\"zmuvpbttdumorppx\"]},\"degraded\":{\"severity\":\"Sev2\",\"description\":\"zbtbhj\",\"actionGroupIds\":[\"kfgohdneue\"]}}},\"id\":\"phsdyhto\",\"name\":\"fikdowwqu\",\"type\":\"v\"}],\"nextLink\":\"xclvit\"}") + .toObject(EntityListResult.class); + Assertions.assertEquals("zpostmgrcfbu", model.value().get(0).properties().displayName()); + Assertions.assertEquals("mfqjhhkxbp", model.value().get(0).properties().kind()); + Assertions.assertEquals(93.7726067893376, model.value().get(0).properties().canvasPosition().x()); + Assertions.assertEquals(41.362515263932465, model.value().get(0).properties().canvasPosition().y()); + Assertions.assertEquals("xjyngudivk", model.value().get(0).properties().icon().iconName()); + Assertions.assertEquals("swbxqz", model.value().get(0).properties().icon().customData()); + Assertions.assertEquals(15.572520547165258D, model.value().get(0).properties().healthObjective()); + Assertions.assertEquals(EntityImpact.LIMITED, model.value().get(0).properties().impact()); + Assertions.assertEquals("j", model.value().get(0).properties().labels().get("dxxiv")); + Assertions.assertEquals("slqb", + model.value().get(0).properties().signals().azureResource().authenticationSetting()); + Assertions.assertEquals("sfxobl", + model.value().get(0).properties().signals().azureResource().azureResourceId()); + Assertions.assertEquals("lmpewwwfbkr", + model.value().get(0).properties().signals().azureLogAnalytics().authenticationSetting()); + Assertions.assertEquals("rn", + model.value().get(0).properties().signals().azureLogAnalytics().logAnalyticsWorkspaceResourceId()); + Assertions.assertEquals("q", + model.value().get(0).properties().signals().azureMonitorWorkspace().authenticationSetting()); + Assertions.assertEquals("ohxcrsbfova", + model.value().get(0).properties().signals().azureMonitorWorkspace().azureMonitorWorkspaceResourceId()); + Assertions.assertEquals(DependenciesAggregationType.WORST_OF, + model.value().get(0).properties().signals().dependencies().aggregationType()); + Assertions.assertEquals("v", model.value().get(0).properties().signals().dependencies().degradedThreshold()); + Assertions.assertEquals("hsqfsubcgjbirxbp", + model.value().get(0).properties().signals().dependencies().unhealthyThreshold()); + Assertions.assertEquals(AlertSeverity.SEV4, model.value().get(0).properties().alerts().unhealthy().severity()); + Assertions.assertEquals("exilzznfqqnvwpmq", + model.value().get(0).properties().alerts().unhealthy().description()); + Assertions.assertEquals("uoujmkcjhwqy", + model.value().get(0).properties().alerts().unhealthy().actionGroupIds().get(0)); + Assertions.assertEquals(AlertSeverity.SEV4, model.value().get(0).properties().alerts().degraded().severity()); + Assertions.assertEquals("nqpeh", model.value().get(0).properties().alerts().degraded().description()); + Assertions.assertEquals("oygmift", + model.value().get(0).properties().alerts().degraded().actionGroupIds().get(0)); + Assertions.assertEquals("xclvit", model.nextLink()); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/EntityPropertiesTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/EntityPropertiesTests.java new file mode 100644 index 000000000000..3f73993384fa --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/EntityPropertiesTests.java @@ -0,0 +1,157 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.cloudhealth.models.AlertConfiguration; +import com.azure.resourcemanager.cloudhealth.models.AlertSeverity; +import com.azure.resourcemanager.cloudhealth.models.AzureMonitorWorkspaceSignalGroup; +import com.azure.resourcemanager.cloudhealth.models.AzureResourceSignalGroup; +import com.azure.resourcemanager.cloudhealth.models.DependenciesAggregationType; +import com.azure.resourcemanager.cloudhealth.models.DependenciesSignalGroup; +import com.azure.resourcemanager.cloudhealth.models.EntityAlerts; +import com.azure.resourcemanager.cloudhealth.models.EntityCoordinates; +import com.azure.resourcemanager.cloudhealth.models.EntityImpact; +import com.azure.resourcemanager.cloudhealth.models.EntityProperties; +import com.azure.resourcemanager.cloudhealth.models.IconDefinition; +import com.azure.resourcemanager.cloudhealth.models.LogAnalyticsSignalGroup; +import com.azure.resourcemanager.cloudhealth.models.SignalAssignment; +import com.azure.resourcemanager.cloudhealth.models.SignalGroup; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; + +public final class EntityPropertiesTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + EntityProperties model = BinaryData.fromString( + "{\"provisioningState\":\"Creating\",\"displayName\":\"cocmnyyaztt\",\"kind\":\"wwrq\",\"canvasPosition\":{\"x\":92.70088471408752,\"y\":88.20154440709435},\"icon\":{\"iconName\":\"ywbiexzfeyueax\",\"customData\":\"xujwbhqwalmuzyo\"},\"healthObjective\":38.12073567925543,\"impact\":\"Suppressed\",\"labels\":{\"bavxbniwdjswzt\":\"ancuxrhd\",\"xbzpfzab\":\"dbpgnxytxhp\"},\"signals\":{\"azureResource\":{\"signalAssignments\":[{\"signalDefinitions\":[\"wtctyqi\",\"lbbovplw\",\"bhvgy\",\"gu\"]}],\"authenticationSetting\":\"svmkfssxquk\",\"azureResourceId\":\"fpl\"},\"azureLogAnalytics\":{\"signalAssignments\":[{\"signalDefinitions\":[\"nkjzkdeslpvlop\",\"i\",\"ighxpk\"]},{\"signalDefinitions\":[\"zb\",\"iuebbaumny\"]},{\"signalDefinitions\":[\"ped\",\"ojnabckhsmtxpsie\",\"tfhvpesapskrdqmh\",\"jdhtldwkyzxu\"]},{\"signalDefinitions\":[\"kn\",\"ws\"]}],\"authenticationSetting\":\"wsvlxotogtwrupqs\",\"logAnalyticsWorkspaceResourceId\":\"vnm\"},\"azureMonitorWorkspace\":{\"signalAssignments\":[{\"signalDefinitions\":[\"ceoveilovno\"]},{\"signalDefinitions\":[\"fj\",\"cnjbkcnxdhbt\",\"kphywpnvjto\"]},{\"signalDefinitions\":[\"ermclfplphoxuscr\",\"abgy\"]},{\"signalDefinitions\":[\"sbj\",\"azqugxywpmueefj\"]}],\"authenticationSetting\":\"wfqkquj\",\"azureMonitorWorkspaceResourceId\":\"dsuyonobgla\"},\"dependencies\":{\"aggregationType\":\"Thresholds\",\"degradedThreshold\":\"tcc\",\"unhealthyThreshold\":\"yudxytlmoy\"}},\"discoveredBy\":\"vwfudwpzntxhd\",\"deletionDate\":\"2021-06-26T07:36:51Z\",\"healthState\":\"Healthy\",\"alerts\":{\"unhealthy\":{\"severity\":\"Sev2\",\"description\":\"kfrlhrxsbky\",\"actionGroupIds\":[\"ca\",\"uzbpzkafku\",\"b\",\"rnwb\"]},\"degraded\":{\"severity\":\"Sev1\",\"description\":\"seyvj\",\"actionGroupIds\":[\"tslhspkdeem\"]}}}") + .toObject(EntityProperties.class); + Assertions.assertEquals("cocmnyyaztt", model.displayName()); + Assertions.assertEquals("wwrq", model.kind()); + Assertions.assertEquals(92.70088471408752, model.canvasPosition().x()); + Assertions.assertEquals(88.20154440709435, model.canvasPosition().y()); + Assertions.assertEquals("ywbiexzfeyueax", model.icon().iconName()); + Assertions.assertEquals("xujwbhqwalmuzyo", model.icon().customData()); + Assertions.assertEquals(38.12073567925543D, model.healthObjective()); + Assertions.assertEquals(EntityImpact.SUPPRESSED, model.impact()); + Assertions.assertEquals("ancuxrhd", model.labels().get("bavxbniwdjswzt")); + Assertions.assertEquals("wtctyqi", + model.signals().azureResource().signalAssignments().get(0).signalDefinitions().get(0)); + Assertions.assertEquals("svmkfssxquk", model.signals().azureResource().authenticationSetting()); + Assertions.assertEquals("fpl", model.signals().azureResource().azureResourceId()); + Assertions.assertEquals("nkjzkdeslpvlop", + model.signals().azureLogAnalytics().signalAssignments().get(0).signalDefinitions().get(0)); + Assertions.assertEquals("wsvlxotogtwrupqs", model.signals().azureLogAnalytics().authenticationSetting()); + Assertions.assertEquals("vnm", model.signals().azureLogAnalytics().logAnalyticsWorkspaceResourceId()); + Assertions.assertEquals("ceoveilovno", + model.signals().azureMonitorWorkspace().signalAssignments().get(0).signalDefinitions().get(0)); + Assertions.assertEquals("wfqkquj", model.signals().azureMonitorWorkspace().authenticationSetting()); + Assertions.assertEquals("dsuyonobgla", + model.signals().azureMonitorWorkspace().azureMonitorWorkspaceResourceId()); + Assertions.assertEquals(DependenciesAggregationType.THRESHOLDS, + model.signals().dependencies().aggregationType()); + Assertions.assertEquals("tcc", model.signals().dependencies().degradedThreshold()); + Assertions.assertEquals("yudxytlmoy", model.signals().dependencies().unhealthyThreshold()); + Assertions.assertEquals(AlertSeverity.SEV2, model.alerts().unhealthy().severity()); + Assertions.assertEquals("kfrlhrxsbky", model.alerts().unhealthy().description()); + Assertions.assertEquals("ca", model.alerts().unhealthy().actionGroupIds().get(0)); + Assertions.assertEquals(AlertSeverity.SEV1, model.alerts().degraded().severity()); + Assertions.assertEquals("seyvj", model.alerts().degraded().description()); + Assertions.assertEquals("tslhspkdeem", model.alerts().degraded().actionGroupIds().get(0)); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + EntityProperties model = new EntityProperties().withDisplayName("cocmnyyaztt") + .withKind("wwrq") + .withCanvasPosition(new EntityCoordinates().withX(92.70088471408752).withY(88.20154440709435)) + .withIcon(new IconDefinition().withIconName("ywbiexzfeyueax").withCustomData("xujwbhqwalmuzyo")) + .withHealthObjective(38.12073567925543D) + .withImpact(EntityImpact.SUPPRESSED) + .withLabels(mapOf("bavxbniwdjswzt", "ancuxrhd", "xbzpfzab", "dbpgnxytxhp")) + .withSignals(new SignalGroup() + .withAzureResource(new AzureResourceSignalGroup() + .withSignalAssignments(Arrays.asList(new SignalAssignment() + .withSignalDefinitions(Arrays.asList("wtctyqi", "lbbovplw", "bhvgy", "gu")))) + .withAuthenticationSetting("svmkfssxquk") + .withAzureResourceId("fpl")) + .withAzureLogAnalytics(new LogAnalyticsSignalGroup() + .withSignalAssignments(Arrays.asList( + new SignalAssignment().withSignalDefinitions(Arrays.asList("nkjzkdeslpvlop", "i", "ighxpk")), + new SignalAssignment().withSignalDefinitions(Arrays.asList("zb", "iuebbaumny")), + new SignalAssignment().withSignalDefinitions( + Arrays.asList("ped", "ojnabckhsmtxpsie", "tfhvpesapskrdqmh", "jdhtldwkyzxu")), + new SignalAssignment().withSignalDefinitions(Arrays.asList("kn", "ws")))) + .withAuthenticationSetting("wsvlxotogtwrupqs") + .withLogAnalyticsWorkspaceResourceId("vnm")) + .withAzureMonitorWorkspace(new AzureMonitorWorkspaceSignalGroup() + .withSignalAssignments( + Arrays.asList(new SignalAssignment().withSignalDefinitions(Arrays.asList("ceoveilovno")), + new SignalAssignment() + .withSignalDefinitions(Arrays.asList("fj", "cnjbkcnxdhbt", "kphywpnvjto")), + new SignalAssignment().withSignalDefinitions(Arrays.asList("ermclfplphoxuscr", "abgy")), + new SignalAssignment().withSignalDefinitions(Arrays.asList("sbj", "azqugxywpmueefj")))) + .withAuthenticationSetting("wfqkquj") + .withAzureMonitorWorkspaceResourceId("dsuyonobgla")) + .withDependencies( + new DependenciesSignalGroup().withAggregationType(DependenciesAggregationType.THRESHOLDS) + .withDegradedThreshold("tcc") + .withUnhealthyThreshold("yudxytlmoy"))) + .withAlerts(new EntityAlerts() + .withUnhealthy(new AlertConfiguration().withSeverity(AlertSeverity.SEV2) + .withDescription("kfrlhrxsbky") + .withActionGroupIds(Arrays.asList("ca", "uzbpzkafku", "b", "rnwb"))) + .withDegraded(new AlertConfiguration().withSeverity(AlertSeverity.SEV1) + .withDescription("seyvj") + .withActionGroupIds(Arrays.asList("tslhspkdeem")))); + model = BinaryData.fromObject(model).toObject(EntityProperties.class); + Assertions.assertEquals("cocmnyyaztt", model.displayName()); + Assertions.assertEquals("wwrq", model.kind()); + Assertions.assertEquals(92.70088471408752, model.canvasPosition().x()); + Assertions.assertEquals(88.20154440709435, model.canvasPosition().y()); + Assertions.assertEquals("ywbiexzfeyueax", model.icon().iconName()); + Assertions.assertEquals("xujwbhqwalmuzyo", model.icon().customData()); + Assertions.assertEquals(38.12073567925543D, model.healthObjective()); + Assertions.assertEquals(EntityImpact.SUPPRESSED, model.impact()); + Assertions.assertEquals("ancuxrhd", model.labels().get("bavxbniwdjswzt")); + Assertions.assertEquals("wtctyqi", + model.signals().azureResource().signalAssignments().get(0).signalDefinitions().get(0)); + Assertions.assertEquals("svmkfssxquk", model.signals().azureResource().authenticationSetting()); + Assertions.assertEquals("fpl", model.signals().azureResource().azureResourceId()); + Assertions.assertEquals("nkjzkdeslpvlop", + model.signals().azureLogAnalytics().signalAssignments().get(0).signalDefinitions().get(0)); + Assertions.assertEquals("wsvlxotogtwrupqs", model.signals().azureLogAnalytics().authenticationSetting()); + Assertions.assertEquals("vnm", model.signals().azureLogAnalytics().logAnalyticsWorkspaceResourceId()); + Assertions.assertEquals("ceoveilovno", + model.signals().azureMonitorWorkspace().signalAssignments().get(0).signalDefinitions().get(0)); + Assertions.assertEquals("wfqkquj", model.signals().azureMonitorWorkspace().authenticationSetting()); + Assertions.assertEquals("dsuyonobgla", + model.signals().azureMonitorWorkspace().azureMonitorWorkspaceResourceId()); + Assertions.assertEquals(DependenciesAggregationType.THRESHOLDS, + model.signals().dependencies().aggregationType()); + Assertions.assertEquals("tcc", model.signals().dependencies().degradedThreshold()); + Assertions.assertEquals("yudxytlmoy", model.signals().dependencies().unhealthyThreshold()); + Assertions.assertEquals(AlertSeverity.SEV2, model.alerts().unhealthy().severity()); + Assertions.assertEquals("kfrlhrxsbky", model.alerts().unhealthy().description()); + Assertions.assertEquals("ca", model.alerts().unhealthy().actionGroupIds().get(0)); + Assertions.assertEquals(AlertSeverity.SEV1, model.alerts().degraded().severity()); + Assertions.assertEquals("seyvj", model.alerts().degraded().description()); + Assertions.assertEquals("tslhspkdeem", model.alerts().degraded().actionGroupIds().get(0)); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/EvaluationRuleTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/EvaluationRuleTests.java new file mode 100644 index 000000000000..dd7d8ea06476 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/EvaluationRuleTests.java @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.cloudhealth.models.DynamicDetectionRule; +import com.azure.resourcemanager.cloudhealth.models.DynamicThresholdDirection; +import com.azure.resourcemanager.cloudhealth.models.DynamicThresholdModel; +import com.azure.resourcemanager.cloudhealth.models.EvaluationRule; +import com.azure.resourcemanager.cloudhealth.models.SignalOperator; +import com.azure.resourcemanager.cloudhealth.models.ThresholdRule; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Assertions; + +public final class EvaluationRuleTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + EvaluationRule model = BinaryData.fromString( + "{\"dynamicDetectionRule\":{\"dynamicThresholdModel\":\"AnomalyDetection\",\"modelSensitivity\":92.68480143402465,\"dynamicThresholdDirection\":\"LowerThan\",\"trainingStartTime\":\"2021-07-20T08:46:51Z\"},\"degradedRule\":{\"operator\":\"LowerOrEquals\",\"threshold\":\"uofqwe\"},\"unhealthyRule\":{\"operator\":\"GreaterThan\",\"threshold\":\"menevfyexfwh\"}}") + .toObject(EvaluationRule.class); + Assertions.assertEquals(DynamicThresholdModel.ANOMALY_DETECTION, + model.dynamicDetectionRule().dynamicThresholdModel()); + Assertions.assertEquals(92.68480143402465, model.dynamicDetectionRule().modelSensitivity()); + Assertions.assertEquals(DynamicThresholdDirection.LOWER_THAN, + model.dynamicDetectionRule().dynamicThresholdDirection()); + Assertions.assertEquals(OffsetDateTime.parse("2021-07-20T08:46:51Z"), + model.dynamicDetectionRule().trainingStartTime()); + Assertions.assertEquals(SignalOperator.LOWER_OR_EQUALS, model.degradedRule().operator()); + Assertions.assertEquals("uofqwe", model.degradedRule().threshold()); + Assertions.assertEquals(SignalOperator.GREATER_THAN, model.unhealthyRule().operator()); + Assertions.assertEquals("menevfyexfwh", model.unhealthyRule().threshold()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + EvaluationRule model = new EvaluationRule() + .withDynamicDetectionRule( + new DynamicDetectionRule().withDynamicThresholdModel(DynamicThresholdModel.ANOMALY_DETECTION) + .withModelSensitivity(92.68480143402465) + .withDynamicThresholdDirection(DynamicThresholdDirection.LOWER_THAN) + .withTrainingStartTime(OffsetDateTime.parse("2021-07-20T08:46:51Z"))) + .withDegradedRule(new ThresholdRule().withOperator(SignalOperator.LOWER_OR_EQUALS).withThreshold("uofqwe")) + .withUnhealthyRule( + new ThresholdRule().withOperator(SignalOperator.GREATER_THAN).withThreshold("menevfyexfwh")); + model = BinaryData.fromObject(model).toObject(EvaluationRule.class); + Assertions.assertEquals(DynamicThresholdModel.ANOMALY_DETECTION, + model.dynamicDetectionRule().dynamicThresholdModel()); + Assertions.assertEquals(92.68480143402465, model.dynamicDetectionRule().modelSensitivity()); + Assertions.assertEquals(DynamicThresholdDirection.LOWER_THAN, + model.dynamicDetectionRule().dynamicThresholdDirection()); + Assertions.assertEquals(OffsetDateTime.parse("2021-07-20T08:46:51Z"), + model.dynamicDetectionRule().trainingStartTime()); + Assertions.assertEquals(SignalOperator.LOWER_OR_EQUALS, model.degradedRule().operator()); + Assertions.assertEquals("uofqwe", model.degradedRule().threshold()); + Assertions.assertEquals(SignalOperator.GREATER_THAN, model.unhealthyRule().operator()); + Assertions.assertEquals("menevfyexfwh", model.unhealthyRule().threshold()); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelInnerTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelInnerTests.java new file mode 100644 index 000000000000..9847d3d0c3ff --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelInnerTests.java @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.cloudhealth.fluent.models.HealthModelInner; +import com.azure.resourcemanager.cloudhealth.models.DiscoveryRuleRecommendedSignalsBehavior; +import com.azure.resourcemanager.cloudhealth.models.HealthModelProperties; +import com.azure.resourcemanager.cloudhealth.models.ManagedServiceIdentity; +import com.azure.resourcemanager.cloudhealth.models.ManagedServiceIdentityType; +import com.azure.resourcemanager.cloudhealth.models.ModelDiscoverySettings; +import com.azure.resourcemanager.cloudhealth.models.UserAssignedIdentity; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; + +public final class HealthModelInnerTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + HealthModelInner model = BinaryData.fromString( + "{\"properties\":{\"dataplaneEndpoint\":\"jbpzvgnwzsymg\",\"provisioningState\":\"Deleting\",\"discovery\":{\"scope\":\"cyzkohdbihanuf\",\"addRecommendedSignals\":\"Disabled\",\"identity\":\"bj\"}},\"identity\":{\"principalId\":\"git\",\"tenantId\":\"qhabifpikxwcz\",\"type\":\"SystemAssigned\",\"userAssignedIdentities\":{\"iwbybrkxvdumjg\":{\"principalId\":\"pqxu\",\"clientId\":\"vyq\"},\"cnyejhkryhtnapcz\":{\"principalId\":\"fwvuk\",\"clientId\":\"audccsnhs\"},\"nchgej\":{\"principalId\":\"okjye\",\"clientId\":\"kvnipjoxz\"},\"wyahuxinpmqnja\":{\"principalId\":\"odmailzyd\",\"clientId\":\"o\"}}},\"location\":\"ixjsprozvcputeg\",\"tags\":{\"u\":\"mfdatscmdvpj\",\"kjozkrwfnd\":\"suuv\",\"vwryoqpso\":\"odjpslwejd\",\"yffdfdos\":\"cctazakljlahbc\"},\"id\":\"gexpaojakhmsbz\",\"name\":\"hcrzevd\",\"type\":\"hlxaolthqtr\"}") + .toObject(HealthModelInner.class); + Assertions.assertEquals("ixjsprozvcputeg", model.location()); + Assertions.assertEquals("mfdatscmdvpj", model.tags().get("u")); + Assertions.assertEquals("cyzkohdbihanuf", model.properties().discovery().scope()); + Assertions.assertEquals(DiscoveryRuleRecommendedSignalsBehavior.DISABLED, + model.properties().discovery().addRecommendedSignals()); + Assertions.assertEquals("bj", model.properties().discovery().identity()); + Assertions.assertEquals(ManagedServiceIdentityType.SYSTEM_ASSIGNED, model.identity().type()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + HealthModelInner model + = new HealthModelInner().withLocation("ixjsprozvcputeg") + .withTags(mapOf("u", "mfdatscmdvpj", "kjozkrwfnd", "suuv", "vwryoqpso", "odjpslwejd", "yffdfdos", + "cctazakljlahbc")) + .withProperties( + new HealthModelProperties().withDiscovery(new ModelDiscoverySettings().withScope("cyzkohdbihanuf") + .withAddRecommendedSignals(DiscoveryRuleRecommendedSignalsBehavior.DISABLED) + .withIdentity("bj"))) + .withIdentity(new ManagedServiceIdentity().withType(ManagedServiceIdentityType.SYSTEM_ASSIGNED) + .withUserAssignedIdentities(mapOf("iwbybrkxvdumjg", new UserAssignedIdentity(), "cnyejhkryhtnapcz", + new UserAssignedIdentity(), "nchgej", new UserAssignedIdentity(), "wyahuxinpmqnja", + new UserAssignedIdentity()))); + model = BinaryData.fromObject(model).toObject(HealthModelInner.class); + Assertions.assertEquals("ixjsprozvcputeg", model.location()); + Assertions.assertEquals("mfdatscmdvpj", model.tags().get("u")); + Assertions.assertEquals("cyzkohdbihanuf", model.properties().discovery().scope()); + Assertions.assertEquals(DiscoveryRuleRecommendedSignalsBehavior.DISABLED, + model.properties().discovery().addRecommendedSignals()); + Assertions.assertEquals("bj", model.properties().discovery().identity()); + Assertions.assertEquals(ManagedServiceIdentityType.SYSTEM_ASSIGNED, model.identity().type()); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelListResultTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelListResultTests.java new file mode 100644 index 000000000000..553991680310 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelListResultTests.java @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.cloudhealth.implementation.models.HealthModelListResult; +import com.azure.resourcemanager.cloudhealth.models.DiscoveryRuleRecommendedSignalsBehavior; +import com.azure.resourcemanager.cloudhealth.models.ManagedServiceIdentityType; +import org.junit.jupiter.api.Assertions; + +public final class HealthModelListResultTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + HealthModelListResult model = BinaryData.fromString( + "{\"value\":[{\"properties\":{\"dataplaneEndpoint\":\"gcbacphejkot\",\"provisioningState\":\"Failed\",\"discovery\":{\"scope\":\"oulzndlikwyq\",\"addRecommendedSignals\":\"Enabled\",\"identity\":\"gibma\"}},\"identity\":{\"principalId\":\"keqsrxybzqqedq\",\"tenantId\":\"bciqfouflm\",\"type\":\"UserAssigned\",\"userAssignedIdentities\":{\"uqktap\":{\"principalId\":\"modmglougpb\",\"clientId\":\"tmut\"}}},\"location\":\"wgcu\",\"tags\":{\"bbjfddgmbmbexp\":\"umkdosvqwhbmd\",\"gbquxigj\":\"bhtqqrolfpfpsa\",\"lnerkujysvleju\":\"jgzjaoyfhrtx\",\"kcprbnw\":\"fqawrlyxw\"},\"id\":\"xgjvtbv\",\"name\":\"ysszdnrujqguh\",\"type\":\"uouq\"},{\"properties\":{\"dataplaneEndpoint\":\"wzwbnguitn\",\"provisioningState\":\"Succeeded\",\"discovery\":{\"scope\":\"gazxuf\",\"addRecommendedSignals\":\"Enabled\",\"identity\":\"ckyfih\"}},\"identity\":{\"principalId\":\"dfvzwdzuhty\",\"tenantId\":\"isdkfthwxmnteiw\",\"type\":\"UserAssigned\",\"userAssignedIdentities\":{\"ezcxtbzsgfyccsne\":{\"principalId\":\"mijcmmxdcufufs\",\"clientId\":\"ymzidn\"},\"osfqpteehzzv\":{\"principalId\":\"dwzjeiach\",\"clientId\":\"osfln\"},\"dqxhcrmnohjtckwh\":{\"principalId\":\"yqrimzin\",\"clientId\":\"swjdkirso\"},\"vsnb\":{\"principalId\":\"oifiyipjxsqwpgr\",\"clientId\":\"znorcj\"}}},\"location\":\"qabnmoc\",\"tags\":{\"c\":\"shurzafbljjgpbto\"},\"id\":\"mkljavb\",\"name\":\"idtqajzyu\",\"type\":\"pku\"}],\"nextLink\":\"krlkhbzhfepg\"}") + .toObject(HealthModelListResult.class); + Assertions.assertEquals("wgcu", model.value().get(0).location()); + Assertions.assertEquals("umkdosvqwhbmd", model.value().get(0).tags().get("bbjfddgmbmbexp")); + Assertions.assertEquals("oulzndlikwyq", model.value().get(0).properties().discovery().scope()); + Assertions.assertEquals(DiscoveryRuleRecommendedSignalsBehavior.ENABLED, + model.value().get(0).properties().discovery().addRecommendedSignals()); + Assertions.assertEquals("gibma", model.value().get(0).properties().discovery().identity()); + Assertions.assertEquals(ManagedServiceIdentityType.USER_ASSIGNED, model.value().get(0).identity().type()); + Assertions.assertEquals("krlkhbzhfepg", model.nextLink()); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelPropertiesTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelPropertiesTests.java new file mode 100644 index 000000000000..2710d9419059 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelPropertiesTests.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.cloudhealth.models.DiscoveryRuleRecommendedSignalsBehavior; +import com.azure.resourcemanager.cloudhealth.models.HealthModelProperties; +import com.azure.resourcemanager.cloudhealth.models.ModelDiscoverySettings; +import org.junit.jupiter.api.Assertions; + +public final class HealthModelPropertiesTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + HealthModelProperties model = BinaryData.fromString( + "{\"dataplaneEndpoint\":\"jbp\",\"provisioningState\":\"Canceled\",\"discovery\":{\"scope\":\"inzgvfcj\",\"addRecommendedSignals\":\"Enabled\",\"identity\":\"oxxjtfelluwf\"}}") + .toObject(HealthModelProperties.class); + Assertions.assertEquals("inzgvfcj", model.discovery().scope()); + Assertions.assertEquals(DiscoveryRuleRecommendedSignalsBehavior.ENABLED, + model.discovery().addRecommendedSignals()); + Assertions.assertEquals("oxxjtfelluwf", model.discovery().identity()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + HealthModelProperties model + = new HealthModelProperties().withDiscovery(new ModelDiscoverySettings().withScope("inzgvfcj") + .withAddRecommendedSignals(DiscoveryRuleRecommendedSignalsBehavior.ENABLED) + .withIdentity("oxxjtfelluwf")); + model = BinaryData.fromObject(model).toObject(HealthModelProperties.class); + Assertions.assertEquals("inzgvfcj", model.discovery().scope()); + Assertions.assertEquals(DiscoveryRuleRecommendedSignalsBehavior.ENABLED, + model.discovery().addRecommendedSignals()); + Assertions.assertEquals("oxxjtfelluwf", model.discovery().identity()); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelUpdatePropertiesTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelUpdatePropertiesTests.java new file mode 100644 index 000000000000..90f2c73b45fe --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelUpdatePropertiesTests.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.cloudhealth.models.DiscoveryRuleRecommendedSignalsBehavior; +import com.azure.resourcemanager.cloudhealth.models.HealthModelUpdateProperties; +import com.azure.resourcemanager.cloudhealth.models.ModelDiscoverySettings; +import org.junit.jupiter.api.Assertions; + +public final class HealthModelUpdatePropertiesTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + HealthModelUpdateProperties model = BinaryData.fromString( + "{\"discovery\":{\"scope\":\"w\",\"addRecommendedSignals\":\"Disabled\",\"identity\":\"ryplwckbasyypn\"}}") + .toObject(HealthModelUpdateProperties.class); + Assertions.assertEquals("w", model.discovery().scope()); + Assertions.assertEquals(DiscoveryRuleRecommendedSignalsBehavior.DISABLED, + model.discovery().addRecommendedSignals()); + Assertions.assertEquals("ryplwckbasyypn", model.discovery().identity()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + HealthModelUpdateProperties model + = new HealthModelUpdateProperties().withDiscovery(new ModelDiscoverySettings().withScope("w") + .withAddRecommendedSignals(DiscoveryRuleRecommendedSignalsBehavior.DISABLED) + .withIdentity("ryplwckbasyypn")); + model = BinaryData.fromObject(model).toObject(HealthModelUpdateProperties.class); + Assertions.assertEquals("w", model.discovery().scope()); + Assertions.assertEquals(DiscoveryRuleRecommendedSignalsBehavior.DISABLED, + model.discovery().addRecommendedSignals()); + Assertions.assertEquals("ryplwckbasyypn", model.discovery().identity()); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelUpdateTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelUpdateTests.java new file mode 100644 index 000000000000..035ab3203fcf --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelUpdateTests.java @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.cloudhealth.models.DiscoveryRuleRecommendedSignalsBehavior; +import com.azure.resourcemanager.cloudhealth.models.HealthModelUpdate; +import com.azure.resourcemanager.cloudhealth.models.HealthModelUpdateProperties; +import com.azure.resourcemanager.cloudhealth.models.ManagedServiceIdentity; +import com.azure.resourcemanager.cloudhealth.models.ManagedServiceIdentityType; +import com.azure.resourcemanager.cloudhealth.models.ModelDiscoverySettings; +import com.azure.resourcemanager.cloudhealth.models.UserAssignedIdentity; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; + +public final class HealthModelUpdateTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + HealthModelUpdate model = BinaryData.fromString( + "{\"identity\":{\"principalId\":\"sainqpjwnzl\",\"tenantId\":\"fmppe\",\"type\":\"SystemAssigned,UserAssigned\",\"userAssignedIdentities\":{\"vndhkrwpdapp\":{\"principalId\":\"xsabkyqdu\",\"clientId\":\"itcjczdz\"},\"je\":{\"principalId\":\"bdkvwrwjf\",\"clientId\":\"snhu\"}}},\"tags\":{\"hugjzzdatqxhoc\":\"rl\",\"ozwyiftyhxhuro\":\"geablgphuticndvk\"},\"properties\":{\"discovery\":{\"scope\":\"yxolniwp\",\"addRecommendedSignals\":\"Enabled\",\"identity\":\"kjfkg\"}}}") + .toObject(HealthModelUpdate.class); + Assertions.assertEquals(ManagedServiceIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED, model.identity().type()); + Assertions.assertEquals("rl", model.tags().get("hugjzzdatqxhoc")); + Assertions.assertEquals("yxolniwp", model.properties().discovery().scope()); + Assertions.assertEquals(DiscoveryRuleRecommendedSignalsBehavior.ENABLED, + model.properties().discovery().addRecommendedSignals()); + Assertions.assertEquals("kjfkg", model.properties().discovery().identity()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + HealthModelUpdate model = new HealthModelUpdate() + .withIdentity( + new ManagedServiceIdentity().withType(ManagedServiceIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED) + .withUserAssignedIdentities( + mapOf("vndhkrwpdapp", new UserAssignedIdentity(), "je", new UserAssignedIdentity()))) + .withTags(mapOf("hugjzzdatqxhoc", "rl", "ozwyiftyhxhuro", "geablgphuticndvk")) + .withProperties( + new HealthModelUpdateProperties().withDiscovery(new ModelDiscoverySettings().withScope("yxolniwp") + .withAddRecommendedSignals(DiscoveryRuleRecommendedSignalsBehavior.ENABLED) + .withIdentity("kjfkg"))); + model = BinaryData.fromObject(model).toObject(HealthModelUpdate.class); + Assertions.assertEquals(ManagedServiceIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED, model.identity().type()); + Assertions.assertEquals("rl", model.tags().get("hugjzzdatqxhoc")); + Assertions.assertEquals("yxolniwp", model.properties().discovery().scope()); + Assertions.assertEquals(DiscoveryRuleRecommendedSignalsBehavior.ENABLED, + model.properties().discovery().addRecommendedSignals()); + Assertions.assertEquals("kjfkg", model.properties().discovery().identity()); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelsCreateMockTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelsCreateMockTests.java new file mode 100644 index 000000000000..d464878fba46 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelsCreateMockTests.java @@ -0,0 +1,74 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.cloudhealth.CloudHealthManager; +import com.azure.resourcemanager.cloudhealth.models.DiscoveryRuleRecommendedSignalsBehavior; +import com.azure.resourcemanager.cloudhealth.models.HealthModel; +import com.azure.resourcemanager.cloudhealth.models.HealthModelProperties; +import com.azure.resourcemanager.cloudhealth.models.ManagedServiceIdentity; +import com.azure.resourcemanager.cloudhealth.models.ManagedServiceIdentityType; +import com.azure.resourcemanager.cloudhealth.models.ModelDiscoverySettings; +import com.azure.resourcemanager.cloudhealth.models.UserAssignedIdentity; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class HealthModelsCreateMockTests { + @Test + public void testCreate() throws Exception { + String responseStr + = "{\"properties\":{\"dataplaneEndpoint\":\"t\",\"provisioningState\":\"Succeeded\",\"discovery\":{\"scope\":\"ra\",\"addRecommendedSignals\":\"Disabled\",\"identity\":\"koowtl\"}},\"identity\":{\"principalId\":\"ux\",\"tenantId\":\"q\",\"type\":\"SystemAssigned,UserAssigned\",\"userAssignedIdentities\":{\"znkbykutwpfhpagm\":{\"principalId\":\"uuximerq\",\"clientId\":\"bw\"},\"evdlh\":{\"principalId\":\"skdsnfdsdoakg\",\"clientId\":\"lmkk\"},\"m\":{\"principalId\":\"pusdstt\",\"clientId\":\"ogvbbejdcngq\"}}},\"location\":\"kufgmj\",\"tags\":{\"enuuzkopbm\":\"rdgrtw\"},\"id\":\"nrfdw\",\"name\":\"yuhhziu\",\"type\":\"efozbhdms\"}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + CloudHealthManager manager = CloudHealthManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + HealthModel response = manager.healthModels() + .define("gdknnqv") + .withRegion("ouicybxarzgszu") + .withExistingResourceGroup("u") + .withTags(mapOf("ciodhkhaz", "ciqopidoa")) + .withProperties( + new HealthModelProperties().withDiscovery(new ModelDiscoverySettings().withScope("rauwjuetaebu") + .withAddRecommendedSignals(DiscoveryRuleRecommendedSignalsBehavior.ENABLED) + .withIdentity("dmovsm"))) + .withIdentity(new ManagedServiceIdentity().withType(ManagedServiceIdentityType.SYSTEM_ASSIGNED) + .withUserAssignedIdentities(mapOf("twwaezkojvdcpzf", new UserAssignedIdentity()))) + .create(); + + Assertions.assertEquals("kufgmj", response.location()); + Assertions.assertEquals("rdgrtw", response.tags().get("enuuzkopbm")); + Assertions.assertEquals("ra", response.properties().discovery().scope()); + Assertions.assertEquals(DiscoveryRuleRecommendedSignalsBehavior.DISABLED, + response.properties().discovery().addRecommendedSignals()); + Assertions.assertEquals("koowtl", response.properties().discovery().identity()); + Assertions.assertEquals(ManagedServiceIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED, response.identity().type()); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelsGetByResourceGroupWithResponseMockTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelsGetByResourceGroupWithResponseMockTests.java new file mode 100644 index 000000000000..9b4a1e89d7a8 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelsGetByResourceGroupWithResponseMockTests.java @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.cloudhealth.CloudHealthManager; +import com.azure.resourcemanager.cloudhealth.models.DiscoveryRuleRecommendedSignalsBehavior; +import com.azure.resourcemanager.cloudhealth.models.HealthModel; +import com.azure.resourcemanager.cloudhealth.models.ManagedServiceIdentityType; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class HealthModelsGetByResourceGroupWithResponseMockTests { + @Test + public void testGetByResourceGroupWithResponse() throws Exception { + String responseStr + = "{\"properties\":{\"dataplaneEndpoint\":\"x\",\"provisioningState\":\"Creating\",\"discovery\":{\"scope\":\"zikywgg\",\"addRecommendedSignals\":\"Disabled\",\"identity\":\"lla\"}},\"identity\":{\"principalId\":\"lwuip\",\"tenantId\":\"cjzkzivgvvcna\",\"type\":\"UserAssigned\",\"userAssignedIdentities\":{\"tdaaygdvwvg\":{\"principalId\":\"nxxmueedndrdv\",\"clientId\":\"kwqqtchealmf\"},\"himdbl\":{\"principalId\":\"ohgwxrtfudxepxg\",\"clientId\":\"agvrvmnpkuk\"},\"xw\":{\"principalId\":\"wi\",\"clientId\":\"njhf\"}}},\"location\":\"zk\",\"tags\":{\"fjawneaivxwczel\":\"qreyfkzi\",\"r\":\"c\",\"xbjhwuaanozjosph\":\"lsfeaenwabfatkld\",\"ag\":\"oulpjrv\"},\"id\":\"rvimjwosytxitcsk\",\"name\":\"cktqumiekkezzi\",\"type\":\"hlyfjhdgqgg\"}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + CloudHealthManager manager = CloudHealthManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + HealthModel response = manager.healthModels() + .getByResourceGroupWithResponse("ocrkvcikh", "vpa", com.azure.core.util.Context.NONE) + .getValue(); + + Assertions.assertEquals("zk", response.location()); + Assertions.assertEquals("qreyfkzi", response.tags().get("fjawneaivxwczel")); + Assertions.assertEquals("zikywgg", response.properties().discovery().scope()); + Assertions.assertEquals(DiscoveryRuleRecommendedSignalsBehavior.DISABLED, + response.properties().discovery().addRecommendedSignals()); + Assertions.assertEquals("lla", response.properties().discovery().identity()); + Assertions.assertEquals(ManagedServiceIdentityType.USER_ASSIGNED, response.identity().type()); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelsListByResourceGroupMockTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelsListByResourceGroupMockTests.java new file mode 100644 index 000000000000..d7be16e5b322 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelsListByResourceGroupMockTests.java @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.cloudhealth.CloudHealthManager; +import com.azure.resourcemanager.cloudhealth.models.DiscoveryRuleRecommendedSignalsBehavior; +import com.azure.resourcemanager.cloudhealth.models.HealthModel; +import com.azure.resourcemanager.cloudhealth.models.ManagedServiceIdentityType; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class HealthModelsListByResourceGroupMockTests { + @Test + public void testListByResourceGroup() throws Exception { + String responseStr + = "{\"value\":[{\"properties\":{\"dataplaneEndpoint\":\"atpxl\",\"provisioningState\":\"Creating\",\"discovery\":{\"scope\":\"yjmoadsu\",\"addRecommendedSignals\":\"Enabled\",\"identity\":\"m\"}},\"identity\":{\"principalId\":\"mjsjqb\",\"tenantId\":\"hyxxrwlycoduhpk\",\"type\":\"SystemAssigned,UserAssigned\",\"userAssignedIdentities\":{\"dgssofwqmzqal\":{\"principalId\":\"areqna\",\"clientId\":\"qugjhkycube\"},\"imrzrtuzqog\":{\"principalId\":\"mnjijpxacqqudf\",\"clientId\":\"yxbaaabjyvayf\"},\"ud\":{\"principalId\":\"xnevfdnwn\",\"clientId\":\"ewzsyyceuzsoib\"},\"paxh\":{\"principalId\":\"rx\",\"clientId\":\"thzvaytdwkqbrqu\"}}},\"location\":\"iilivpdtiirqtd\",\"tags\":{\"l\":\"xoruzfgsquyfxrx\",\"zwl\":\"ptramxj\",\"tdooaoj\":\"nwxuqlcvydyp\"},\"id\":\"niodkooeb\",\"name\":\"nuj\",\"type\":\"emmsbvdkc\"}]}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + CloudHealthManager manager = CloudHealthManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + PagedIterable response + = manager.healthModels().listByResourceGroup("bdunygaeqid", com.azure.core.util.Context.NONE); + + Assertions.assertEquals("iilivpdtiirqtd", response.iterator().next().location()); + Assertions.assertEquals("xoruzfgsquyfxrx", response.iterator().next().tags().get("l")); + Assertions.assertEquals("yjmoadsu", response.iterator().next().properties().discovery().scope()); + Assertions.assertEquals(DiscoveryRuleRecommendedSignalsBehavior.ENABLED, + response.iterator().next().properties().discovery().addRecommendedSignals()); + Assertions.assertEquals("m", response.iterator().next().properties().discovery().identity()); + Assertions.assertEquals(ManagedServiceIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED, + response.iterator().next().identity().type()); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelsListMockTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelsListMockTests.java new file mode 100644 index 000000000000..99cdfff0b201 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/HealthModelsListMockTests.java @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.cloudhealth.CloudHealthManager; +import com.azure.resourcemanager.cloudhealth.models.DiscoveryRuleRecommendedSignalsBehavior; +import com.azure.resourcemanager.cloudhealth.models.HealthModel; +import com.azure.resourcemanager.cloudhealth.models.ManagedServiceIdentityType; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class HealthModelsListMockTests { + @Test + public void testList() throws Exception { + String responseStr + = "{\"value\":[{\"properties\":{\"dataplaneEndpoint\":\"tjinf\",\"provisioningState\":\"Deleting\",\"discovery\":{\"scope\":\"lt\",\"addRecommendedSignals\":\"Enabled\",\"identity\":\"jvefkdlfoakggkfp\"}},\"identity\":{\"principalId\":\"owpulpq\",\"tenantId\":\"ylsyxkqjnsje\",\"type\":\"None\",\"userAssignedIdentities\":{\"psbzkfzbeyvpn\":{\"principalId\":\"gxsds\",\"clientId\":\"e\"},\"zpof\":{\"principalId\":\"cvinvkjjxdxrbuuk\",\"clientId\":\"lewyhmlwpaz\"},\"tpp\":{\"principalId\":\"ckw\",\"clientId\":\"zqwhxxbuyqaxzfeq\"},\"altol\":{\"principalId\":\"o\",\"clientId\":\"or\"}}},\"location\":\"cwsobqwcs\",\"tags\":{\"lsbjjcanvxbv\":\"wdcfhucqdpfuv\",\"r\":\"vudutncor\"},\"id\":\"xqtvcofu\",\"name\":\"f\",\"type\":\"vkg\"}]}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + CloudHealthManager manager = CloudHealthManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + PagedIterable response = manager.healthModels().list(com.azure.core.util.Context.NONE); + + Assertions.assertEquals("cwsobqwcs", response.iterator().next().location()); + Assertions.assertEquals("wdcfhucqdpfuv", response.iterator().next().tags().get("lsbjjcanvxbv")); + Assertions.assertEquals("lt", response.iterator().next().properties().discovery().scope()); + Assertions.assertEquals(DiscoveryRuleRecommendedSignalsBehavior.ENABLED, + response.iterator().next().properties().discovery().addRecommendedSignals()); + Assertions.assertEquals("jvefkdlfoakggkfp", response.iterator().next().properties().discovery().identity()); + Assertions.assertEquals(ManagedServiceIdentityType.NONE, response.iterator().next().identity().type()); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/IconDefinitionTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/IconDefinitionTests.java new file mode 100644 index 000000000000..19c5efbe6e6c --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/IconDefinitionTests.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.cloudhealth.models.IconDefinition; +import org.junit.jupiter.api.Assertions; + +public final class IconDefinitionTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + IconDefinition model + = BinaryData.fromString("{\"iconName\":\"ag\",\"customData\":\"t\"}").toObject(IconDefinition.class); + Assertions.assertEquals("ag", model.iconName()); + Assertions.assertEquals("t", model.customData()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + IconDefinition model = new IconDefinition().withIconName("ag").withCustomData("t"); + model = BinaryData.fromObject(model).toObject(IconDefinition.class); + Assertions.assertEquals("ag", model.iconName()); + Assertions.assertEquals("t", model.customData()); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/LogAnalyticsQuerySignalDefinitionPropertiesTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/LogAnalyticsQuerySignalDefinitionPropertiesTests.java new file mode 100644 index 000000000000..84a50a8f78ca --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/LogAnalyticsQuerySignalDefinitionPropertiesTests.java @@ -0,0 +1,98 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.cloudhealth.models.DynamicDetectionRule; +import com.azure.resourcemanager.cloudhealth.models.DynamicThresholdDirection; +import com.azure.resourcemanager.cloudhealth.models.DynamicThresholdModel; +import com.azure.resourcemanager.cloudhealth.models.EvaluationRule; +import com.azure.resourcemanager.cloudhealth.models.LogAnalyticsQuerySignalDefinitionProperties; +import com.azure.resourcemanager.cloudhealth.models.RefreshInterval; +import com.azure.resourcemanager.cloudhealth.models.SignalOperator; +import com.azure.resourcemanager.cloudhealth.models.ThresholdRule; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; + +public final class LogAnalyticsQuerySignalDefinitionPropertiesTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + LogAnalyticsQuerySignalDefinitionProperties model = BinaryData.fromString( + "{\"signalKind\":\"LogAnalyticsQuery\",\"queryText\":\"cfionl\",\"timeGrain\":\"x\",\"valueColumnName\":\"qgtz\",\"provisioningState\":\"Deleting\",\"displayName\":\"qbqqwxr\",\"refreshInterval\":\"PT30M\",\"labels\":{\"ampmngnz\":\"lnwsubisn\",\"aqw\":\"c\"},\"dataUnit\":\"chcbonqvpkvlrxnj\",\"evaluationRules\":{\"dynamicDetectionRule\":{\"dynamicThresholdModel\":\"AnomalyDetection\",\"modelSensitivity\":80.0054787376229,\"dynamicThresholdDirection\":\"LowerThan\",\"trainingStartTime\":\"2021-01-11T00:37:29Z\"},\"degradedRule\":{\"operator\":\"LowerThan\",\"threshold\":\"lokeyy\"},\"unhealthyRule\":{\"operator\":\"LowerOrEquals\",\"threshold\":\"jbdlwtgrhpdjpju\"}},\"deletionDate\":\"2021-01-02T16:01:04Z\"}") + .toObject(LogAnalyticsQuerySignalDefinitionProperties.class); + Assertions.assertEquals("qbqqwxr", model.displayName()); + Assertions.assertEquals(RefreshInterval.PT30M, model.refreshInterval()); + Assertions.assertEquals("lnwsubisn", model.labels().get("ampmngnz")); + Assertions.assertEquals("chcbonqvpkvlrxnj", model.dataUnit()); + Assertions.assertEquals(DynamicThresholdModel.ANOMALY_DETECTION, + model.evaluationRules().dynamicDetectionRule().dynamicThresholdModel()); + Assertions.assertEquals(80.0054787376229, model.evaluationRules().dynamicDetectionRule().modelSensitivity()); + Assertions.assertEquals(DynamicThresholdDirection.LOWER_THAN, + model.evaluationRules().dynamicDetectionRule().dynamicThresholdDirection()); + Assertions.assertEquals(OffsetDateTime.parse("2021-01-11T00:37:29Z"), + model.evaluationRules().dynamicDetectionRule().trainingStartTime()); + Assertions.assertEquals(SignalOperator.LOWER_THAN, model.evaluationRules().degradedRule().operator()); + Assertions.assertEquals("lokeyy", model.evaluationRules().degradedRule().threshold()); + Assertions.assertEquals(SignalOperator.LOWER_OR_EQUALS, model.evaluationRules().unhealthyRule().operator()); + Assertions.assertEquals("jbdlwtgrhpdjpju", model.evaluationRules().unhealthyRule().threshold()); + Assertions.assertEquals("cfionl", model.queryText()); + Assertions.assertEquals("x", model.timeGrain()); + Assertions.assertEquals("qgtz", model.valueColumnName()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + LogAnalyticsQuerySignalDefinitionProperties model = new LogAnalyticsQuerySignalDefinitionProperties() + .withDisplayName("qbqqwxr") + .withRefreshInterval(RefreshInterval.PT30M) + .withLabels(mapOf("ampmngnz", "lnwsubisn", "aqw", "c")) + .withDataUnit("chcbonqvpkvlrxnj") + .withEvaluationRules(new EvaluationRule() + .withDynamicDetectionRule( + new DynamicDetectionRule().withDynamicThresholdModel(DynamicThresholdModel.ANOMALY_DETECTION) + .withModelSensitivity(80.0054787376229) + .withDynamicThresholdDirection(DynamicThresholdDirection.LOWER_THAN) + .withTrainingStartTime(OffsetDateTime.parse("2021-01-11T00:37:29Z"))) + .withDegradedRule(new ThresholdRule().withOperator(SignalOperator.LOWER_THAN).withThreshold("lokeyy")) + .withUnhealthyRule( + new ThresholdRule().withOperator(SignalOperator.LOWER_OR_EQUALS).withThreshold("jbdlwtgrhpdjpju"))) + .withQueryText("cfionl") + .withTimeGrain("x") + .withValueColumnName("qgtz"); + model = BinaryData.fromObject(model).toObject(LogAnalyticsQuerySignalDefinitionProperties.class); + Assertions.assertEquals("qbqqwxr", model.displayName()); + Assertions.assertEquals(RefreshInterval.PT30M, model.refreshInterval()); + Assertions.assertEquals("lnwsubisn", model.labels().get("ampmngnz")); + Assertions.assertEquals("chcbonqvpkvlrxnj", model.dataUnit()); + Assertions.assertEquals(DynamicThresholdModel.ANOMALY_DETECTION, + model.evaluationRules().dynamicDetectionRule().dynamicThresholdModel()); + Assertions.assertEquals(80.0054787376229, model.evaluationRules().dynamicDetectionRule().modelSensitivity()); + Assertions.assertEquals(DynamicThresholdDirection.LOWER_THAN, + model.evaluationRules().dynamicDetectionRule().dynamicThresholdDirection()); + Assertions.assertEquals(OffsetDateTime.parse("2021-01-11T00:37:29Z"), + model.evaluationRules().dynamicDetectionRule().trainingStartTime()); + Assertions.assertEquals(SignalOperator.LOWER_THAN, model.evaluationRules().degradedRule().operator()); + Assertions.assertEquals("lokeyy", model.evaluationRules().degradedRule().threshold()); + Assertions.assertEquals(SignalOperator.LOWER_OR_EQUALS, model.evaluationRules().unhealthyRule().operator()); + Assertions.assertEquals("jbdlwtgrhpdjpju", model.evaluationRules().unhealthyRule().threshold()); + Assertions.assertEquals("cfionl", model.queryText()); + Assertions.assertEquals("x", model.timeGrain()); + Assertions.assertEquals("qgtz", model.valueColumnName()); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/LogAnalyticsSignalGroupTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/LogAnalyticsSignalGroupTests.java new file mode 100644 index 000000000000..8363ba804403 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/LogAnalyticsSignalGroupTests.java @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.cloudhealth.models.LogAnalyticsSignalGroup; +import com.azure.resourcemanager.cloudhealth.models.SignalAssignment; +import java.util.Arrays; +import org.junit.jupiter.api.Assertions; + +public final class LogAnalyticsSignalGroupTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + LogAnalyticsSignalGroup model = BinaryData.fromString( + "{\"signalAssignments\":[{\"signalDefinitions\":[\"thnnpr\",\"xipeilpjzuaejx\",\"ultskzbbtdz\",\"mv\"]},{\"signalDefinitions\":[\"kgpwoz\"]}],\"authenticationSetting\":\"hkfpbs\",\"logAnalyticsWorkspaceResourceId\":\"yofd\"}") + .toObject(LogAnalyticsSignalGroup.class); + Assertions.assertEquals("thnnpr", model.signalAssignments().get(0).signalDefinitions().get(0)); + Assertions.assertEquals("hkfpbs", model.authenticationSetting()); + Assertions.assertEquals("yofd", model.logAnalyticsWorkspaceResourceId()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + LogAnalyticsSignalGroup model = new LogAnalyticsSignalGroup() + .withSignalAssignments(Arrays.asList( + new SignalAssignment() + .withSignalDefinitions(Arrays.asList("thnnpr", "xipeilpjzuaejx", "ultskzbbtdz", "mv")), + new SignalAssignment().withSignalDefinitions(Arrays.asList("kgpwoz")))) + .withAuthenticationSetting("hkfpbs") + .withLogAnalyticsWorkspaceResourceId("yofd"); + model = BinaryData.fromObject(model).toObject(LogAnalyticsSignalGroup.class); + Assertions.assertEquals("thnnpr", model.signalAssignments().get(0).signalDefinitions().get(0)); + Assertions.assertEquals("hkfpbs", model.authenticationSetting()); + Assertions.assertEquals("yofd", model.logAnalyticsWorkspaceResourceId()); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/ManagedIdentityAuthenticationSettingPropertiesTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/ManagedIdentityAuthenticationSettingPropertiesTests.java new file mode 100644 index 000000000000..15f758beb564 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/ManagedIdentityAuthenticationSettingPropertiesTests.java @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.cloudhealth.models.ManagedIdentityAuthenticationSettingProperties; +import org.junit.jupiter.api.Assertions; + +public final class ManagedIdentityAuthenticationSettingPropertiesTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + ManagedIdentityAuthenticationSettingProperties model = BinaryData.fromString( + "{\"authenticationKind\":\"ManagedIdentity\",\"managedIdentityName\":\"hslkevleggzf\",\"provisioningState\":\"Succeeded\",\"displayName\":\"mvfaxkffeiith\"}") + .toObject(ManagedIdentityAuthenticationSettingProperties.class); + Assertions.assertEquals("mvfaxkffeiith", model.displayName()); + Assertions.assertEquals("hslkevleggzf", model.managedIdentityName()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + ManagedIdentityAuthenticationSettingProperties model + = new ManagedIdentityAuthenticationSettingProperties().withDisplayName("mvfaxkffeiith") + .withManagedIdentityName("hslkevleggzf"); + model = BinaryData.fromObject(model).toObject(ManagedIdentityAuthenticationSettingProperties.class); + Assertions.assertEquals("mvfaxkffeiith", model.displayName()); + Assertions.assertEquals("hslkevleggzf", model.managedIdentityName()); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/ManagedServiceIdentityTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/ManagedServiceIdentityTests.java new file mode 100644 index 000000000000..ff3c78f655e6 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/ManagedServiceIdentityTests.java @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.cloudhealth.models.ManagedServiceIdentity; +import com.azure.resourcemanager.cloudhealth.models.ManagedServiceIdentityType; +import com.azure.resourcemanager.cloudhealth.models.UserAssignedIdentity; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; + +public final class ManagedServiceIdentityTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + ManagedServiceIdentity model = BinaryData.fromString( + "{\"principalId\":\"lxofpdvhpfxxypin\",\"tenantId\":\"mayhuybbkpodepoo\",\"type\":\"UserAssigned\",\"userAssignedIdentities\":{\"evcciqihnhun\":{\"principalId\":\"amiheognarxz\",\"clientId\":\"heotusiv\"},\"kufubljo\":{\"principalId\":\"wjzrnfygxgisp\",\"clientId\":\"vtz\"},\"jhqjbasvmsmjqul\":{\"principalId\":\"qeof\",\"clientId\":\"e\"},\"skcqvkocrcjd\":{\"principalId\":\"sntnbybkzgcw\",\"clientId\":\"clxxwrljdo\"}}}") + .toObject(ManagedServiceIdentity.class); + Assertions.assertEquals(ManagedServiceIdentityType.USER_ASSIGNED, model.type()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + ManagedServiceIdentity model = new ManagedServiceIdentity().withType(ManagedServiceIdentityType.USER_ASSIGNED) + .withUserAssignedIdentities( + mapOf("evcciqihnhun", new UserAssignedIdentity(), "kufubljo", new UserAssignedIdentity(), + "jhqjbasvmsmjqul", new UserAssignedIdentity(), "skcqvkocrcjd", new UserAssignedIdentity())); + model = BinaryData.fromObject(model).toObject(ManagedServiceIdentity.class); + Assertions.assertEquals(ManagedServiceIdentityType.USER_ASSIGNED, model.type()); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/ModelDiscoverySettingsTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/ModelDiscoverySettingsTests.java new file mode 100644 index 000000000000..2677fe3c7230 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/ModelDiscoverySettingsTests.java @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.cloudhealth.models.DiscoveryRuleRecommendedSignalsBehavior; +import com.azure.resourcemanager.cloudhealth.models.ModelDiscoverySettings; +import org.junit.jupiter.api.Assertions; + +public final class ModelDiscoverySettingsTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + ModelDiscoverySettings model + = BinaryData.fromString("{\"scope\":\"it\",\"addRecommendedSignals\":\"Enabled\",\"identity\":\"eqfpj\"}") + .toObject(ModelDiscoverySettings.class); + Assertions.assertEquals("it", model.scope()); + Assertions.assertEquals(DiscoveryRuleRecommendedSignalsBehavior.ENABLED, model.addRecommendedSignals()); + Assertions.assertEquals("eqfpj", model.identity()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + ModelDiscoverySettings model = new ModelDiscoverySettings().withScope("it") + .withAddRecommendedSignals(DiscoveryRuleRecommendedSignalsBehavior.ENABLED) + .withIdentity("eqfpj"); + model = BinaryData.fromObject(model).toObject(ModelDiscoverySettings.class); + Assertions.assertEquals("it", model.scope()); + Assertions.assertEquals(DiscoveryRuleRecommendedSignalsBehavior.ENABLED, model.addRecommendedSignals()); + Assertions.assertEquals("eqfpj", model.identity()); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/OperationDisplayTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/OperationDisplayTests.java new file mode 100644 index 000000000000..2c66eba349ff --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/OperationDisplayTests.java @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.cloudhealth.models.OperationDisplay; + +public final class OperationDisplayTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + OperationDisplay model = BinaryData.fromString( + "{\"provider\":\"cdm\",\"resource\":\"rcryuanzwuxzdxta\",\"operation\":\"lhmwhfpmrqobm\",\"description\":\"kknryrtihf\"}") + .toObject(OperationDisplay.class); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/OperationInnerTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/OperationInnerTests.java new file mode 100644 index 000000000000..30017b3d0f05 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/OperationInnerTests.java @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.cloudhealth.fluent.models.OperationInner; + +public final class OperationInnerTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + OperationInner model = BinaryData.fromString( + "{\"name\":\"nygj\",\"isDataAction\":true,\"display\":{\"provider\":\"eqsrdeupewnwreit\",\"resource\":\"yflusarhmofc\",\"operation\":\"smy\",\"description\":\"kdtmlxhekuk\"},\"origin\":\"user,system\",\"actionType\":\"Internal\"}") + .toObject(OperationInner.class); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/OperationListResultTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/OperationListResultTests.java new file mode 100644 index 000000000000..e5d3f867b477 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/OperationListResultTests.java @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.cloudhealth.implementation.models.OperationListResult; +import org.junit.jupiter.api.Assertions; + +public final class OperationListResultTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + OperationListResult model = BinaryData.fromString( + "{\"value\":[{\"name\":\"hq\",\"isDataAction\":true,\"display\":{\"provider\":\"pybczmehmtzopb\",\"resource\":\"h\",\"operation\":\"pidgsybbejhphoyc\",\"description\":\"xaobhdxbmtqioqjz\"},\"origin\":\"system\",\"actionType\":\"Internal\"},{\"name\":\"fpownoizhwlr\",\"isDataAction\":false,\"display\":{\"provider\":\"oqijgkdmbpaz\",\"resource\":\"bc\",\"operation\":\"pdznrbtcqqjnqgl\",\"description\":\"gnufoooj\"},\"origin\":\"system\",\"actionType\":\"Internal\"},{\"name\":\"esaagdfm\",\"isDataAction\":true,\"display\":{\"provider\":\"j\",\"resource\":\"ifkwmrvktsizntoc\",\"operation\":\"a\",\"description\":\"ajpsquc\"},\"origin\":\"system\",\"actionType\":\"Internal\"}],\"nextLink\":\"kfo\"}") + .toObject(OperationListResult.class); + Assertions.assertEquals("kfo", model.nextLink()); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/OperationsListMockTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/OperationsListMockTests.java new file mode 100644 index 000000000000..cfa3b61eb0e1 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/OperationsListMockTests.java @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.cloudhealth.CloudHealthManager; +import com.azure.resourcemanager.cloudhealth.models.Operation; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class OperationsListMockTests { + @Test + public void testList() throws Exception { + String responseStr + = "{\"value\":[{\"name\":\"abikns\",\"isDataAction\":false,\"display\":{\"provider\":\"xbldtlwwrlkdmtn\",\"resource\":\"ok\",\"operation\":\"llxdyhgs\",\"description\":\"cogjltdtbn\"},\"origin\":\"user,system\",\"actionType\":\"Internal\"}]}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + CloudHealthManager manager = CloudHealthManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + PagedIterable response = manager.operations().list(com.azure.core.util.Context.NONE); + + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/PrometheusMetricsSignalDefinitionPropertiesTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/PrometheusMetricsSignalDefinitionPropertiesTests.java new file mode 100644 index 000000000000..92a610077662 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/PrometheusMetricsSignalDefinitionPropertiesTests.java @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.cloudhealth.models.DynamicDetectionRule; +import com.azure.resourcemanager.cloudhealth.models.DynamicThresholdDirection; +import com.azure.resourcemanager.cloudhealth.models.DynamicThresholdModel; +import com.azure.resourcemanager.cloudhealth.models.EvaluationRule; +import com.azure.resourcemanager.cloudhealth.models.PrometheusMetricsSignalDefinitionProperties; +import com.azure.resourcemanager.cloudhealth.models.RefreshInterval; +import com.azure.resourcemanager.cloudhealth.models.SignalOperator; +import com.azure.resourcemanager.cloudhealth.models.ThresholdRule; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; + +public final class PrometheusMetricsSignalDefinitionPropertiesTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + PrometheusMetricsSignalDefinitionProperties model = BinaryData.fromString( + "{\"signalKind\":\"PrometheusMetricsQuery\",\"queryText\":\"xazjpqyegual\",\"timeGrain\":\"xxhejjzzvd\",\"provisioningState\":\"Succeeded\",\"displayName\":\"dslfhotwmcy\",\"refreshInterval\":\"PT30M\",\"labels\":{\"cftadeh\":\"jnpg\",\"dejbavo\":\"nltyfsoppusuesnz\"},\"dataUnit\":\"zdmohctbqvu\",\"evaluationRules\":{\"dynamicDetectionRule\":{\"dynamicThresholdModel\":\"AnomalyDetection\",\"modelSensitivity\":40.951472945028,\"dynamicThresholdDirection\":\"GreaterThan\",\"trainingStartTime\":\"2021-02-14T16:40:57Z\"},\"degradedRule\":{\"operator\":\"GreaterOrEquals\",\"threshold\":\"gujjugwdkcglh\"},\"unhealthyRule\":{\"operator\":\"LowerThan\",\"threshold\":\"zj\"}},\"deletionDate\":\"2021-10-23T04:38:56Z\"}") + .toObject(PrometheusMetricsSignalDefinitionProperties.class); + Assertions.assertEquals("dslfhotwmcy", model.displayName()); + Assertions.assertEquals(RefreshInterval.PT30M, model.refreshInterval()); + Assertions.assertEquals("jnpg", model.labels().get("cftadeh")); + Assertions.assertEquals("zdmohctbqvu", model.dataUnit()); + Assertions.assertEquals(DynamicThresholdModel.ANOMALY_DETECTION, + model.evaluationRules().dynamicDetectionRule().dynamicThresholdModel()); + Assertions.assertEquals(40.951472945028, model.evaluationRules().dynamicDetectionRule().modelSensitivity()); + Assertions.assertEquals(DynamicThresholdDirection.GREATER_THAN, + model.evaluationRules().dynamicDetectionRule().dynamicThresholdDirection()); + Assertions.assertEquals(OffsetDateTime.parse("2021-02-14T16:40:57Z"), + model.evaluationRules().dynamicDetectionRule().trainingStartTime()); + Assertions.assertEquals(SignalOperator.GREATER_OR_EQUALS, model.evaluationRules().degradedRule().operator()); + Assertions.assertEquals("gujjugwdkcglh", model.evaluationRules().degradedRule().threshold()); + Assertions.assertEquals(SignalOperator.LOWER_THAN, model.evaluationRules().unhealthyRule().operator()); + Assertions.assertEquals("zj", model.evaluationRules().unhealthyRule().threshold()); + Assertions.assertEquals("xazjpqyegual", model.queryText()); + Assertions.assertEquals("xxhejjzzvd", model.timeGrain()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + PrometheusMetricsSignalDefinitionProperties model = new PrometheusMetricsSignalDefinitionProperties() + .withDisplayName("dslfhotwmcy") + .withRefreshInterval(RefreshInterval.PT30M) + .withLabels(mapOf("cftadeh", "jnpg", "dejbavo", "nltyfsoppusuesnz")) + .withDataUnit("zdmohctbqvu") + .withEvaluationRules(new EvaluationRule() + .withDynamicDetectionRule( + new DynamicDetectionRule().withDynamicThresholdModel(DynamicThresholdModel.ANOMALY_DETECTION) + .withModelSensitivity(40.951472945028) + .withDynamicThresholdDirection(DynamicThresholdDirection.GREATER_THAN) + .withTrainingStartTime(OffsetDateTime.parse("2021-02-14T16:40:57Z"))) + .withDegradedRule( + new ThresholdRule().withOperator(SignalOperator.GREATER_OR_EQUALS).withThreshold("gujjugwdkcglh")) + .withUnhealthyRule(new ThresholdRule().withOperator(SignalOperator.LOWER_THAN).withThreshold("zj"))) + .withQueryText("xazjpqyegual") + .withTimeGrain("xxhejjzzvd"); + model = BinaryData.fromObject(model).toObject(PrometheusMetricsSignalDefinitionProperties.class); + Assertions.assertEquals("dslfhotwmcy", model.displayName()); + Assertions.assertEquals(RefreshInterval.PT30M, model.refreshInterval()); + Assertions.assertEquals("jnpg", model.labels().get("cftadeh")); + Assertions.assertEquals("zdmohctbqvu", model.dataUnit()); + Assertions.assertEquals(DynamicThresholdModel.ANOMALY_DETECTION, + model.evaluationRules().dynamicDetectionRule().dynamicThresholdModel()); + Assertions.assertEquals(40.951472945028, model.evaluationRules().dynamicDetectionRule().modelSensitivity()); + Assertions.assertEquals(DynamicThresholdDirection.GREATER_THAN, + model.evaluationRules().dynamicDetectionRule().dynamicThresholdDirection()); + Assertions.assertEquals(OffsetDateTime.parse("2021-02-14T16:40:57Z"), + model.evaluationRules().dynamicDetectionRule().trainingStartTime()); + Assertions.assertEquals(SignalOperator.GREATER_OR_EQUALS, model.evaluationRules().degradedRule().operator()); + Assertions.assertEquals("gujjugwdkcglh", model.evaluationRules().degradedRule().threshold()); + Assertions.assertEquals(SignalOperator.LOWER_THAN, model.evaluationRules().unhealthyRule().operator()); + Assertions.assertEquals("zj", model.evaluationRules().unhealthyRule().threshold()); + Assertions.assertEquals("xazjpqyegual", model.queryText()); + Assertions.assertEquals("xxhejjzzvd", model.timeGrain()); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/RelationshipInnerTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/RelationshipInnerTests.java new file mode 100644 index 000000000000..bb271c74d47e --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/RelationshipInnerTests.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.cloudhealth.fluent.models.RelationshipInner; +import com.azure.resourcemanager.cloudhealth.models.RelationshipProperties; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; + +public final class RelationshipInnerTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + RelationshipInner model = BinaryData.fromString( + "{\"properties\":{\"provisioningState\":\"Succeeded\",\"displayName\":\"nosggbhcoh\",\"parentEntityName\":\"wdsjnkalju\",\"childEntityName\":\"iiswacffgdkzze\",\"labels\":{\"pnppfuf\":\"vhqcrail\",\"afcnih\":\"rwdmhdlxyjrxsa\"},\"discoveredBy\":\"qapnedgfbcv\",\"deletionDate\":\"2021-08-11T14:17:34Z\"},\"id\":\"vpk\",\"name\":\"qdcvdrhvoo\",\"type\":\"sotbob\"}") + .toObject(RelationshipInner.class); + Assertions.assertEquals("nosggbhcoh", model.properties().displayName()); + Assertions.assertEquals("wdsjnkalju", model.properties().parentEntityName()); + Assertions.assertEquals("iiswacffgdkzze", model.properties().childEntityName()); + Assertions.assertEquals("vhqcrail", model.properties().labels().get("pnppfuf")); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + RelationshipInner model + = new RelationshipInner().withProperties(new RelationshipProperties().withDisplayName("nosggbhcoh") + .withParentEntityName("wdsjnkalju") + .withChildEntityName("iiswacffgdkzze") + .withLabels(mapOf("pnppfuf", "vhqcrail", "afcnih", "rwdmhdlxyjrxsa"))); + model = BinaryData.fromObject(model).toObject(RelationshipInner.class); + Assertions.assertEquals("nosggbhcoh", model.properties().displayName()); + Assertions.assertEquals("wdsjnkalju", model.properties().parentEntityName()); + Assertions.assertEquals("iiswacffgdkzze", model.properties().childEntityName()); + Assertions.assertEquals("vhqcrail", model.properties().labels().get("pnppfuf")); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/RelationshipListResultTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/RelationshipListResultTests.java new file mode 100644 index 000000000000..3a223f7c0142 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/RelationshipListResultTests.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.cloudhealth.implementation.models.RelationshipListResult; +import org.junit.jupiter.api.Assertions; + +public final class RelationshipListResultTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + RelationshipListResult model = BinaryData.fromString( + "{\"value\":[{\"properties\":{\"provisioningState\":\"Failed\",\"displayName\":\"mquxvypo\",\"parentEntityName\":\"gkopkwhojvpajqgx\",\"childEntityName\":\"smocmbq\",\"labels\":{\"lxprglyatddckcbc\":\"mkcxozapvh\",\"xsdqrhzoymibmrqy\":\"ejrjxgciqibrho\"},\"discoveredBy\":\"ahwfluszdtmhrk\",\"deletionDate\":\"2021-06-28T13:04:58Z\"},\"id\":\"yvoqa\",\"name\":\"piexpbtgiw\",\"type\":\"wo\"}],\"nextLink\":\"washr\"}") + .toObject(RelationshipListResult.class); + Assertions.assertEquals("mquxvypo", model.value().get(0).properties().displayName()); + Assertions.assertEquals("gkopkwhojvpajqgx", model.value().get(0).properties().parentEntityName()); + Assertions.assertEquals("smocmbq", model.value().get(0).properties().childEntityName()); + Assertions.assertEquals("mkcxozapvh", model.value().get(0).properties().labels().get("lxprglyatddckcbc")); + Assertions.assertEquals("washr", model.nextLink()); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/RelationshipPropertiesTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/RelationshipPropertiesTests.java new file mode 100644 index 000000000000..584bb46625a3 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/RelationshipPropertiesTests.java @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.cloudhealth.models.RelationshipProperties; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; + +public final class RelationshipPropertiesTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + RelationshipProperties model = BinaryData.fromString( + "{\"provisioningState\":\"Failed\",\"displayName\":\"cjwvn\",\"parentEntityName\":\"dldwmgxc\",\"childEntityName\":\"rslpmutwuoeg\",\"labels\":{\"dggkzzlvmbmpa\":\"hjwniyqsluic\",\"yhrfouyftaakcpw\":\"modfvuefywsbpfvm\"},\"discoveredBy\":\"zvqtmnubexkp\",\"deletionDate\":\"2021-05-08T13:31:38Z\"}") + .toObject(RelationshipProperties.class); + Assertions.assertEquals("cjwvn", model.displayName()); + Assertions.assertEquals("dldwmgxc", model.parentEntityName()); + Assertions.assertEquals("rslpmutwuoeg", model.childEntityName()); + Assertions.assertEquals("hjwniyqsluic", model.labels().get("dggkzzlvmbmpa")); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + RelationshipProperties model = new RelationshipProperties().withDisplayName("cjwvn") + .withParentEntityName("dldwmgxc") + .withChildEntityName("rslpmutwuoeg") + .withLabels(mapOf("dggkzzlvmbmpa", "hjwniyqsluic", "yhrfouyftaakcpw", "modfvuefywsbpfvm")); + model = BinaryData.fromObject(model).toObject(RelationshipProperties.class); + Assertions.assertEquals("cjwvn", model.displayName()); + Assertions.assertEquals("dldwmgxc", model.parentEntityName()); + Assertions.assertEquals("rslpmutwuoeg", model.childEntityName()); + Assertions.assertEquals("hjwniyqsluic", model.labels().get("dggkzzlvmbmpa")); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/RelationshipsCreateOrUpdateWithResponseMockTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/RelationshipsCreateOrUpdateWithResponseMockTests.java new file mode 100644 index 000000000000..3d3a1d47d853 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/RelationshipsCreateOrUpdateWithResponseMockTests.java @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.cloudhealth.CloudHealthManager; +import com.azure.resourcemanager.cloudhealth.models.Relationship; +import com.azure.resourcemanager.cloudhealth.models.RelationshipProperties; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class RelationshipsCreateOrUpdateWithResponseMockTests { + @Test + public void testCreateOrUpdateWithResponse() throws Exception { + String responseStr + = "{\"properties\":{\"provisioningState\":\"Succeeded\",\"displayName\":\"gqqqxh\",\"parentEntityName\":\"n\",\"childEntityName\":\"rxcpjuisavo\",\"labels\":{\"jlfrq\":\"zfvazi\"},\"discoveredBy\":\"bajlka\",\"deletionDate\":\"2021-04-16T08:57:57Z\"},\"id\":\"yiopi\",\"name\":\"kqqfk\",\"type\":\"vscx\"}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + CloudHealthManager manager = CloudHealthManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + Relationship response = manager.relationships() + .define("bywdxsmicc") + .withExistingHealthmodel("ev", "gmblrri") + .withProperties(new RelationshipProperties().withDisplayName("cj") + .withParentEntityName("n") + .withChildEntityName("nszqujiz") + .withLabels(mapOf("pthjoxo", "qytibyowbblgyavu", "pi", "smsks", "xkcgxxlxsffgcvi", "lqol", "gfbkjubdyh", + "qzdwlvwlyoup"))) + .create(); + + Assertions.assertEquals("gqqqxh", response.properties().displayName()); + Assertions.assertEquals("n", response.properties().parentEntityName()); + Assertions.assertEquals("rxcpjuisavo", response.properties().childEntityName()); + Assertions.assertEquals("zfvazi", response.properties().labels().get("jlfrq")); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/RelationshipsDeleteWithResponseMockTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/RelationshipsDeleteWithResponseMockTests.java new file mode 100644 index 000000000000..12a6e83d7aa2 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/RelationshipsDeleteWithResponseMockTests.java @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.cloudhealth.CloudHealthManager; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class RelationshipsDeleteWithResponseMockTests { + @Test + public void testDeleteWithResponse() throws Exception { + String responseStr = "{}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + CloudHealthManager manager = CloudHealthManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + manager.relationships() + .deleteWithResponse("pjuohminyfl", "orwmduvwpklv", "w", com.azure.core.util.Context.NONE); + + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/RelationshipsGetWithResponseMockTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/RelationshipsGetWithResponseMockTests.java new file mode 100644 index 000000000000..93647e32ed4a --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/RelationshipsGetWithResponseMockTests.java @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.cloudhealth.CloudHealthManager; +import com.azure.resourcemanager.cloudhealth.models.Relationship; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class RelationshipsGetWithResponseMockTests { + @Test + public void testGetWithResponse() throws Exception { + String responseStr + = "{\"properties\":{\"provisioningState\":\"Succeeded\",\"displayName\":\"iqtqzfavyvnq\",\"parentEntityName\":\"ybar\",\"childEntityName\":\"euayjkqabqgzsles\",\"labels\":{\"bquwrbehw\":\"hernntiewdjc\",\"mvvhmxtdrjfuta\":\"gohbuffkmrq\",\"jvewzcjznmwcp\":\"oe\"},\"discoveredBy\":\"uaadraufactkahzo\",\"deletionDate\":\"2021-05-31T02:13:42Z\"},\"id\":\"ziuxxpshnee\",\"name\":\"ulfgslqu\",\"type\":\"kwdlenrdsutujba\"}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + CloudHealthManager manager = CloudHealthManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + Relationship response = manager.relationships() + .getWithResponse("dyg", "ookk", "fqjbvleo", com.azure.core.util.Context.NONE) + .getValue(); + + Assertions.assertEquals("iqtqzfavyvnq", response.properties().displayName()); + Assertions.assertEquals("ybar", response.properties().parentEntityName()); + Assertions.assertEquals("euayjkqabqgzsles", response.properties().childEntityName()); + Assertions.assertEquals("hernntiewdjc", response.properties().labels().get("bquwrbehw")); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/RelationshipsListByHealthModelMockTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/RelationshipsListByHealthModelMockTests.java new file mode 100644 index 000000000000..aabd4893dc8d --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/RelationshipsListByHealthModelMockTests.java @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.cloudhealth.CloudHealthManager; +import com.azure.resourcemanager.cloudhealth.models.Relationship; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class RelationshipsListByHealthModelMockTests { + @Test + public void testListByHealthModel() throws Exception { + String responseStr + = "{\"value\":[{\"properties\":{\"provisioningState\":\"Canceled\",\"displayName\":\"gibbdaxc\",\"parentEntityName\":\"nfo\",\"childEntityName\":\"auorsukokw\",\"labels\":{\"uuepzlrphwzsoldw\":\"lhlv\",\"vmnnrw\":\"yuqdu\",\"wjhhgdnhxmsivf\":\"biorktal\",\"zaofjchvcyy\":\"miloxggdufiqndie\"},\"discoveredBy\":\"fgdo\",\"deletionDate\":\"2021-02-19T09:04:20Z\"},\"id\":\"iipuipwoqonm\",\"name\":\"cje\",\"type\":\"nizshqvcim\"}]}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + CloudHealthManager manager = CloudHealthManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + PagedIterable response = manager.relationships() + .listByHealthModel("ygdxpgpqchis", "epn", OffsetDateTime.parse("2021-02-11T21:08:57Z"), + com.azure.core.util.Context.NONE); + + Assertions.assertEquals("gibbdaxc", response.iterator().next().properties().displayName()); + Assertions.assertEquals("nfo", response.iterator().next().properties().parentEntityName()); + Assertions.assertEquals("auorsukokw", response.iterator().next().properties().childEntityName()); + Assertions.assertEquals("lhlv", response.iterator().next().properties().labels().get("uuepzlrphwzsoldw")); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/ResourceMetricSignalDefinitionPropertiesTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/ResourceMetricSignalDefinitionPropertiesTests.java new file mode 100644 index 000000000000..6b40197c927c --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/ResourceMetricSignalDefinitionPropertiesTests.java @@ -0,0 +1,110 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.cloudhealth.models.DynamicDetectionRule; +import com.azure.resourcemanager.cloudhealth.models.DynamicThresholdDirection; +import com.azure.resourcemanager.cloudhealth.models.DynamicThresholdModel; +import com.azure.resourcemanager.cloudhealth.models.EvaluationRule; +import com.azure.resourcemanager.cloudhealth.models.MetricAggregationType; +import com.azure.resourcemanager.cloudhealth.models.RefreshInterval; +import com.azure.resourcemanager.cloudhealth.models.ResourceMetricSignalDefinitionProperties; +import com.azure.resourcemanager.cloudhealth.models.SignalOperator; +import com.azure.resourcemanager.cloudhealth.models.ThresholdRule; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; + +public final class ResourceMetricSignalDefinitionPropertiesTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + ResourceMetricSignalDefinitionProperties model = BinaryData.fromString( + "{\"signalKind\":\"AzureResourceMetric\",\"metricNamespace\":\"igdtopbob\",\"metricName\":\"og\",\"timeGrain\":\"m\",\"aggregationType\":\"None\",\"dimension\":\"a\",\"dimensionFilter\":\"uhrzayvvt\",\"provisioningState\":\"Creating\",\"displayName\":\"f\",\"refreshInterval\":\"PT1H\",\"labels\":{\"nxkrx\":\"ftutqxlngxlefgu\",\"tthzrvqd\":\"qmi\",\"ehoqfbowskan\":\"abhjybi\",\"ywgndrv\":\"ktzlcuiywg\"},\"dataUnit\":\"hzgpphrcgyncocpe\",\"evaluationRules\":{\"dynamicDetectionRule\":{\"dynamicThresholdModel\":\"AnomalyDetection\",\"modelSensitivity\":1.8683451643171978,\"dynamicThresholdDirection\":\"GreaterOrLowerThan\",\"trainingStartTime\":\"2021-05-04T16:53:18Z\"},\"degradedRule\":{\"operator\":\"GreaterOrEquals\",\"threshold\":\"xlzevgbmqjqabcy\"},\"unhealthyRule\":{\"operator\":\"LowerThan\",\"threshold\":\"vkwlzuvccfwnf\"}},\"deletionDate\":\"2021-06-18T14:17:09Z\"}") + .toObject(ResourceMetricSignalDefinitionProperties.class); + Assertions.assertEquals("f", model.displayName()); + Assertions.assertEquals(RefreshInterval.PT1H, model.refreshInterval()); + Assertions.assertEquals("ftutqxlngxlefgu", model.labels().get("nxkrx")); + Assertions.assertEquals("hzgpphrcgyncocpe", model.dataUnit()); + Assertions.assertEquals(DynamicThresholdModel.ANOMALY_DETECTION, + model.evaluationRules().dynamicDetectionRule().dynamicThresholdModel()); + Assertions.assertEquals(1.8683451643171978, model.evaluationRules().dynamicDetectionRule().modelSensitivity()); + Assertions.assertEquals(DynamicThresholdDirection.GREATER_OR_LOWER_THAN, + model.evaluationRules().dynamicDetectionRule().dynamicThresholdDirection()); + Assertions.assertEquals(OffsetDateTime.parse("2021-05-04T16:53:18Z"), + model.evaluationRules().dynamicDetectionRule().trainingStartTime()); + Assertions.assertEquals(SignalOperator.GREATER_OR_EQUALS, model.evaluationRules().degradedRule().operator()); + Assertions.assertEquals("xlzevgbmqjqabcy", model.evaluationRules().degradedRule().threshold()); + Assertions.assertEquals(SignalOperator.LOWER_THAN, model.evaluationRules().unhealthyRule().operator()); + Assertions.assertEquals("vkwlzuvccfwnf", model.evaluationRules().unhealthyRule().threshold()); + Assertions.assertEquals("igdtopbob", model.metricNamespace()); + Assertions.assertEquals("og", model.metricName()); + Assertions.assertEquals("m", model.timeGrain()); + Assertions.assertEquals(MetricAggregationType.NONE, model.aggregationType()); + Assertions.assertEquals("a", model.dimension()); + Assertions.assertEquals("uhrzayvvt", model.dimensionFilter()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + ResourceMetricSignalDefinitionProperties model = new ResourceMetricSignalDefinitionProperties() + .withDisplayName("f") + .withRefreshInterval(RefreshInterval.PT1H) + .withLabels(mapOf("nxkrx", "ftutqxlngxlefgu", "tthzrvqd", "qmi", "ehoqfbowskan", "abhjybi", "ywgndrv", + "ktzlcuiywg")) + .withDataUnit("hzgpphrcgyncocpe") + .withEvaluationRules(new EvaluationRule() + .withDynamicDetectionRule( + new DynamicDetectionRule().withDynamicThresholdModel(DynamicThresholdModel.ANOMALY_DETECTION) + .withModelSensitivity(1.8683451643171978) + .withDynamicThresholdDirection(DynamicThresholdDirection.GREATER_OR_LOWER_THAN) + .withTrainingStartTime(OffsetDateTime.parse("2021-05-04T16:53:18Z"))) + .withDegradedRule( + new ThresholdRule().withOperator(SignalOperator.GREATER_OR_EQUALS).withThreshold("xlzevgbmqjqabcy")) + .withUnhealthyRule( + new ThresholdRule().withOperator(SignalOperator.LOWER_THAN).withThreshold("vkwlzuvccfwnf"))) + .withMetricNamespace("igdtopbob") + .withMetricName("og") + .withTimeGrain("m") + .withAggregationType(MetricAggregationType.NONE) + .withDimension("a") + .withDimensionFilter("uhrzayvvt"); + model = BinaryData.fromObject(model).toObject(ResourceMetricSignalDefinitionProperties.class); + Assertions.assertEquals("f", model.displayName()); + Assertions.assertEquals(RefreshInterval.PT1H, model.refreshInterval()); + Assertions.assertEquals("ftutqxlngxlefgu", model.labels().get("nxkrx")); + Assertions.assertEquals("hzgpphrcgyncocpe", model.dataUnit()); + Assertions.assertEquals(DynamicThresholdModel.ANOMALY_DETECTION, + model.evaluationRules().dynamicDetectionRule().dynamicThresholdModel()); + Assertions.assertEquals(1.8683451643171978, model.evaluationRules().dynamicDetectionRule().modelSensitivity()); + Assertions.assertEquals(DynamicThresholdDirection.GREATER_OR_LOWER_THAN, + model.evaluationRules().dynamicDetectionRule().dynamicThresholdDirection()); + Assertions.assertEquals(OffsetDateTime.parse("2021-05-04T16:53:18Z"), + model.evaluationRules().dynamicDetectionRule().trainingStartTime()); + Assertions.assertEquals(SignalOperator.GREATER_OR_EQUALS, model.evaluationRules().degradedRule().operator()); + Assertions.assertEquals("xlzevgbmqjqabcy", model.evaluationRules().degradedRule().threshold()); + Assertions.assertEquals(SignalOperator.LOWER_THAN, model.evaluationRules().unhealthyRule().operator()); + Assertions.assertEquals("vkwlzuvccfwnf", model.evaluationRules().unhealthyRule().threshold()); + Assertions.assertEquals("igdtopbob", model.metricNamespace()); + Assertions.assertEquals("og", model.metricName()); + Assertions.assertEquals("m", model.timeGrain()); + Assertions.assertEquals(MetricAggregationType.NONE, model.aggregationType()); + Assertions.assertEquals("a", model.dimension()); + Assertions.assertEquals("uhrzayvvt", model.dimensionFilter()); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/SignalAssignmentTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/SignalAssignmentTests.java new file mode 100644 index 000000000000..a47e45ffd4c0 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/SignalAssignmentTests.java @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.cloudhealth.models.SignalAssignment; +import java.util.Arrays; +import org.junit.jupiter.api.Assertions; + +public final class SignalAssignmentTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + SignalAssignment model + = BinaryData.fromString("{\"signalDefinitions\":[\"hpvgqz\",\"j\",\"vxdjzlmwlxkvugf\",\"zovawjvz\"]}") + .toObject(SignalAssignment.class); + Assertions.assertEquals("hpvgqz", model.signalDefinitions().get(0)); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + SignalAssignment model + = new SignalAssignment().withSignalDefinitions(Arrays.asList("hpvgqz", "j", "vxdjzlmwlxkvugf", "zovawjvz")); + model = BinaryData.fromObject(model).toObject(SignalAssignment.class); + Assertions.assertEquals("hpvgqz", model.signalDefinitions().get(0)); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/SignalDefinitionInnerTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/SignalDefinitionInnerTests.java new file mode 100644 index 000000000000..477cc26a43e6 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/SignalDefinitionInnerTests.java @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.cloudhealth.fluent.models.SignalDefinitionInner; +import com.azure.resourcemanager.cloudhealth.models.DynamicDetectionRule; +import com.azure.resourcemanager.cloudhealth.models.DynamicThresholdDirection; +import com.azure.resourcemanager.cloudhealth.models.DynamicThresholdModel; +import com.azure.resourcemanager.cloudhealth.models.EvaluationRule; +import com.azure.resourcemanager.cloudhealth.models.RefreshInterval; +import com.azure.resourcemanager.cloudhealth.models.SignalDefinitionProperties; +import com.azure.resourcemanager.cloudhealth.models.SignalOperator; +import com.azure.resourcemanager.cloudhealth.models.ThresholdRule; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; + +public final class SignalDefinitionInnerTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + SignalDefinitionInner model = BinaryData.fromString( + "{\"properties\":{\"signalKind\":\"SignalDefinitionProperties\",\"provisioningState\":\"Creating\",\"displayName\":\"zloc\",\"refreshInterval\":\"PT10M\",\"labels\":{\"j\":\"ierhhbcsglummaj\",\"jionpimexgstxgc\":\"odxobnbdxkqpxok\"},\"dataUnit\":\"dg\",\"evaluationRules\":{\"dynamicDetectionRule\":{\"dynamicThresholdModel\":\"AnomalyDetection\",\"modelSensitivity\":63.97488565542637,\"dynamicThresholdDirection\":\"GreaterThan\",\"trainingStartTime\":\"2021-07-18T09:47:03Z\"},\"degradedRule\":{\"operator\":\"LowerThan\",\"threshold\":\"zrlovmclwhijcoej\"},\"unhealthyRule\":{\"operator\":\"GreaterThan\",\"threshold\":\"zaqsqsycbkbfk\"}},\"deletionDate\":\"2021-04-13T09:52:22Z\"},\"id\":\"kexxppof\",\"name\":\"xaxcfjpgddtocjjx\",\"type\":\"vpmouexhdzxib\"}") + .toObject(SignalDefinitionInner.class); + Assertions.assertEquals("zloc", model.properties().displayName()); + Assertions.assertEquals(RefreshInterval.PT10M, model.properties().refreshInterval()); + Assertions.assertEquals("ierhhbcsglummaj", model.properties().labels().get("j")); + Assertions.assertEquals("dg", model.properties().dataUnit()); + Assertions.assertEquals(DynamicThresholdModel.ANOMALY_DETECTION, + model.properties().evaluationRules().dynamicDetectionRule().dynamicThresholdModel()); + Assertions.assertEquals(63.97488565542637, + model.properties().evaluationRules().dynamicDetectionRule().modelSensitivity()); + Assertions.assertEquals(DynamicThresholdDirection.GREATER_THAN, + model.properties().evaluationRules().dynamicDetectionRule().dynamicThresholdDirection()); + Assertions.assertEquals(OffsetDateTime.parse("2021-07-18T09:47:03Z"), + model.properties().evaluationRules().dynamicDetectionRule().trainingStartTime()); + Assertions.assertEquals(SignalOperator.LOWER_THAN, + model.properties().evaluationRules().degradedRule().operator()); + Assertions.assertEquals("zrlovmclwhijcoej", model.properties().evaluationRules().degradedRule().threshold()); + Assertions.assertEquals(SignalOperator.GREATER_THAN, + model.properties().evaluationRules().unhealthyRule().operator()); + Assertions.assertEquals("zaqsqsycbkbfk", model.properties().evaluationRules().unhealthyRule().threshold()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + SignalDefinitionInner model + = new SignalDefinitionInner().withProperties(new SignalDefinitionProperties().withDisplayName("zloc") + .withRefreshInterval(RefreshInterval.PT10M) + .withLabels(mapOf("j", "ierhhbcsglummaj", "jionpimexgstxgc", "odxobnbdxkqpxok")) + .withDataUnit("dg") + .withEvaluationRules(new EvaluationRule() + .withDynamicDetectionRule( + new DynamicDetectionRule().withDynamicThresholdModel(DynamicThresholdModel.ANOMALY_DETECTION) + .withModelSensitivity(63.97488565542637) + .withDynamicThresholdDirection(DynamicThresholdDirection.GREATER_THAN) + .withTrainingStartTime(OffsetDateTime.parse("2021-07-18T09:47:03Z"))) + .withDegradedRule( + new ThresholdRule().withOperator(SignalOperator.LOWER_THAN).withThreshold("zrlovmclwhijcoej")) + .withUnhealthyRule( + new ThresholdRule().withOperator(SignalOperator.GREATER_THAN).withThreshold("zaqsqsycbkbfk")))); + model = BinaryData.fromObject(model).toObject(SignalDefinitionInner.class); + Assertions.assertEquals("zloc", model.properties().displayName()); + Assertions.assertEquals(RefreshInterval.PT10M, model.properties().refreshInterval()); + Assertions.assertEquals("ierhhbcsglummaj", model.properties().labels().get("j")); + Assertions.assertEquals("dg", model.properties().dataUnit()); + Assertions.assertEquals(DynamicThresholdModel.ANOMALY_DETECTION, + model.properties().evaluationRules().dynamicDetectionRule().dynamicThresholdModel()); + Assertions.assertEquals(63.97488565542637, + model.properties().evaluationRules().dynamicDetectionRule().modelSensitivity()); + Assertions.assertEquals(DynamicThresholdDirection.GREATER_THAN, + model.properties().evaluationRules().dynamicDetectionRule().dynamicThresholdDirection()); + Assertions.assertEquals(OffsetDateTime.parse("2021-07-18T09:47:03Z"), + model.properties().evaluationRules().dynamicDetectionRule().trainingStartTime()); + Assertions.assertEquals(SignalOperator.LOWER_THAN, + model.properties().evaluationRules().degradedRule().operator()); + Assertions.assertEquals("zrlovmclwhijcoej", model.properties().evaluationRules().degradedRule().threshold()); + Assertions.assertEquals(SignalOperator.GREATER_THAN, + model.properties().evaluationRules().unhealthyRule().operator()); + Assertions.assertEquals("zaqsqsycbkbfk", model.properties().evaluationRules().unhealthyRule().threshold()); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/SignalDefinitionListResultTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/SignalDefinitionListResultTests.java new file mode 100644 index 000000000000..c1d3080f15ba --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/SignalDefinitionListResultTests.java @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.cloudhealth.implementation.models.SignalDefinitionListResult; +import com.azure.resourcemanager.cloudhealth.models.DynamicThresholdDirection; +import com.azure.resourcemanager.cloudhealth.models.DynamicThresholdModel; +import com.azure.resourcemanager.cloudhealth.models.RefreshInterval; +import com.azure.resourcemanager.cloudhealth.models.SignalOperator; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Assertions; + +public final class SignalDefinitionListResultTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + SignalDefinitionListResult model = BinaryData.fromString( + "{\"value\":[{\"properties\":{\"signalKind\":\"SignalDefinitionProperties\",\"provisioningState\":\"Canceled\",\"displayName\":\"mdectehfiqscjey\",\"refreshInterval\":\"PT30M\",\"labels\":{\"gm\":\"rkgqhcjrefo\",\"yyvxyqjpkcattpn\":\"qsl\",\"v\":\"jcrcczsqpjhvmda\",\"q\":\"ysou\"},\"dataUnit\":\"a\",\"evaluationRules\":{\"dynamicDetectionRule\":{\"dynamicThresholdModel\":\"AnomalyDetection\",\"modelSensitivity\":74.55696647155128,\"dynamicThresholdDirection\":\"GreaterOrLowerThan\",\"trainingStartTime\":\"2021-05-02T19:00:13Z\"},\"degradedRule\":{\"operator\":\"LowerOrEquals\",\"threshold\":\"ltrpmopj\"},\"unhealthyRule\":{\"operator\":\"Equals\",\"threshold\":\"atuokthfuiu\"}},\"deletionDate\":\"2021-05-15T07:44:06Z\"},\"id\":\"fcp\",\"name\":\"vxodpu\",\"type\":\"zmyzydagf\"},{\"properties\":{\"signalKind\":\"SignalDefinitionProperties\",\"provisioningState\":\"Succeeded\",\"displayName\":\"zyiuokk\",\"refreshInterval\":\"PT1M\",\"labels\":{\"ywqsmbsurexim\":\"xw\",\"stkiiuxhqyud\":\"ryocfsfksymdd\",\"rq\":\"o\",\"oczvy\":\"b\"},\"dataUnit\":\"qrvkdv\",\"evaluationRules\":{\"dynamicDetectionRule\":{\"dynamicThresholdModel\":\"AnomalyDetection\",\"modelSensitivity\":19.527100203245883,\"dynamicThresholdDirection\":\"GreaterOrLowerThan\",\"trainingStartTime\":\"2021-05-18T15:53:17Z\"},\"degradedRule\":{\"operator\":\"GreaterThan\",\"threshold\":\"watkpnpulexxb\"},\"unhealthyRule\":{\"operator\":\"GreaterThan\",\"threshold\":\"truwiqzb\"}},\"deletionDate\":\"2021-02-10T16:58:51Z\"},\"id\":\"ovm\",\"name\":\"okacspk\",\"type\":\"lhzdobp\"}],\"nextLink\":\"mflbv\"}") + .toObject(SignalDefinitionListResult.class); + Assertions.assertEquals("mdectehfiqscjey", model.value().get(0).properties().displayName()); + Assertions.assertEquals(RefreshInterval.PT30M, model.value().get(0).properties().refreshInterval()); + Assertions.assertEquals("rkgqhcjrefo", model.value().get(0).properties().labels().get("gm")); + Assertions.assertEquals("a", model.value().get(0).properties().dataUnit()); + Assertions.assertEquals(DynamicThresholdModel.ANOMALY_DETECTION, + model.value().get(0).properties().evaluationRules().dynamicDetectionRule().dynamicThresholdModel()); + Assertions.assertEquals(74.55696647155128, + model.value().get(0).properties().evaluationRules().dynamicDetectionRule().modelSensitivity()); + Assertions.assertEquals(DynamicThresholdDirection.GREATER_OR_LOWER_THAN, + model.value().get(0).properties().evaluationRules().dynamicDetectionRule().dynamicThresholdDirection()); + Assertions.assertEquals(OffsetDateTime.parse("2021-05-02T19:00:13Z"), + model.value().get(0).properties().evaluationRules().dynamicDetectionRule().trainingStartTime()); + Assertions.assertEquals(SignalOperator.LOWER_OR_EQUALS, + model.value().get(0).properties().evaluationRules().degradedRule().operator()); + Assertions.assertEquals("ltrpmopj", + model.value().get(0).properties().evaluationRules().degradedRule().threshold()); + Assertions.assertEquals(SignalOperator.EQUALS, + model.value().get(0).properties().evaluationRules().unhealthyRule().operator()); + Assertions.assertEquals("atuokthfuiu", + model.value().get(0).properties().evaluationRules().unhealthyRule().threshold()); + Assertions.assertEquals("mflbv", model.nextLink()); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/SignalDefinitionPropertiesTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/SignalDefinitionPropertiesTests.java new file mode 100644 index 000000000000..6b64b449fdcd --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/SignalDefinitionPropertiesTests.java @@ -0,0 +1,88 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.cloudhealth.models.DynamicDetectionRule; +import com.azure.resourcemanager.cloudhealth.models.DynamicThresholdDirection; +import com.azure.resourcemanager.cloudhealth.models.DynamicThresholdModel; +import com.azure.resourcemanager.cloudhealth.models.EvaluationRule; +import com.azure.resourcemanager.cloudhealth.models.RefreshInterval; +import com.azure.resourcemanager.cloudhealth.models.SignalDefinitionProperties; +import com.azure.resourcemanager.cloudhealth.models.SignalOperator; +import com.azure.resourcemanager.cloudhealth.models.ThresholdRule; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; + +public final class SignalDefinitionPropertiesTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + SignalDefinitionProperties model = BinaryData.fromString( + "{\"signalKind\":\"SignalDefinitionProperties\",\"provisioningState\":\"Canceled\",\"displayName\":\"nxqbzvddn\",\"refreshInterval\":\"PT1M\",\"labels\":{\"vuhrhcffcyddgl\":\"icbtwnpzao\"},\"dataUnit\":\"t\",\"evaluationRules\":{\"dynamicDetectionRule\":{\"dynamicThresholdModel\":\"AnomalyDetection\",\"modelSensitivity\":11.132933027510406,\"dynamicThresholdDirection\":\"GreaterOrLowerThan\",\"trainingStartTime\":\"2021-11-24T17:43:24Z\"},\"degradedRule\":{\"operator\":\"Equals\",\"threshold\":\"xmqci\"},\"unhealthyRule\":{\"operator\":\"LowerOrEquals\",\"threshold\":\"hkh\"}},\"deletionDate\":\"2021-04-08T23:48:15Z\"}") + .toObject(SignalDefinitionProperties.class); + Assertions.assertEquals("nxqbzvddn", model.displayName()); + Assertions.assertEquals(RefreshInterval.PT1M, model.refreshInterval()); + Assertions.assertEquals("icbtwnpzao", model.labels().get("vuhrhcffcyddgl")); + Assertions.assertEquals("t", model.dataUnit()); + Assertions.assertEquals(DynamicThresholdModel.ANOMALY_DETECTION, + model.evaluationRules().dynamicDetectionRule().dynamicThresholdModel()); + Assertions.assertEquals(11.132933027510406, model.evaluationRules().dynamicDetectionRule().modelSensitivity()); + Assertions.assertEquals(DynamicThresholdDirection.GREATER_OR_LOWER_THAN, + model.evaluationRules().dynamicDetectionRule().dynamicThresholdDirection()); + Assertions.assertEquals(OffsetDateTime.parse("2021-11-24T17:43:24Z"), + model.evaluationRules().dynamicDetectionRule().trainingStartTime()); + Assertions.assertEquals(SignalOperator.EQUALS, model.evaluationRules().degradedRule().operator()); + Assertions.assertEquals("xmqci", model.evaluationRules().degradedRule().threshold()); + Assertions.assertEquals(SignalOperator.LOWER_OR_EQUALS, model.evaluationRules().unhealthyRule().operator()); + Assertions.assertEquals("hkh", model.evaluationRules().unhealthyRule().threshold()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + SignalDefinitionProperties model = new SignalDefinitionProperties().withDisplayName("nxqbzvddn") + .withRefreshInterval(RefreshInterval.PT1M) + .withLabels(mapOf("vuhrhcffcyddgl", "icbtwnpzao")) + .withDataUnit("t") + .withEvaluationRules(new EvaluationRule() + .withDynamicDetectionRule( + new DynamicDetectionRule().withDynamicThresholdModel(DynamicThresholdModel.ANOMALY_DETECTION) + .withModelSensitivity(11.132933027510406) + .withDynamicThresholdDirection(DynamicThresholdDirection.GREATER_OR_LOWER_THAN) + .withTrainingStartTime(OffsetDateTime.parse("2021-11-24T17:43:24Z"))) + .withDegradedRule(new ThresholdRule().withOperator(SignalOperator.EQUALS).withThreshold("xmqci")) + .withUnhealthyRule( + new ThresholdRule().withOperator(SignalOperator.LOWER_OR_EQUALS).withThreshold("hkh"))); + model = BinaryData.fromObject(model).toObject(SignalDefinitionProperties.class); + Assertions.assertEquals("nxqbzvddn", model.displayName()); + Assertions.assertEquals(RefreshInterval.PT1M, model.refreshInterval()); + Assertions.assertEquals("icbtwnpzao", model.labels().get("vuhrhcffcyddgl")); + Assertions.assertEquals("t", model.dataUnit()); + Assertions.assertEquals(DynamicThresholdModel.ANOMALY_DETECTION, + model.evaluationRules().dynamicDetectionRule().dynamicThresholdModel()); + Assertions.assertEquals(11.132933027510406, model.evaluationRules().dynamicDetectionRule().modelSensitivity()); + Assertions.assertEquals(DynamicThresholdDirection.GREATER_OR_LOWER_THAN, + model.evaluationRules().dynamicDetectionRule().dynamicThresholdDirection()); + Assertions.assertEquals(OffsetDateTime.parse("2021-11-24T17:43:24Z"), + model.evaluationRules().dynamicDetectionRule().trainingStartTime()); + Assertions.assertEquals(SignalOperator.EQUALS, model.evaluationRules().degradedRule().operator()); + Assertions.assertEquals("xmqci", model.evaluationRules().degradedRule().threshold()); + Assertions.assertEquals(SignalOperator.LOWER_OR_EQUALS, model.evaluationRules().unhealthyRule().operator()); + Assertions.assertEquals("hkh", model.evaluationRules().unhealthyRule().threshold()); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/SignalDefinitionsCreateOrUpdateWithResponseMockTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/SignalDefinitionsCreateOrUpdateWithResponseMockTests.java new file mode 100644 index 000000000000..6f9ec9626131 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/SignalDefinitionsCreateOrUpdateWithResponseMockTests.java @@ -0,0 +1,93 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.cloudhealth.CloudHealthManager; +import com.azure.resourcemanager.cloudhealth.models.DynamicDetectionRule; +import com.azure.resourcemanager.cloudhealth.models.DynamicThresholdDirection; +import com.azure.resourcemanager.cloudhealth.models.DynamicThresholdModel; +import com.azure.resourcemanager.cloudhealth.models.EvaluationRule; +import com.azure.resourcemanager.cloudhealth.models.RefreshInterval; +import com.azure.resourcemanager.cloudhealth.models.SignalDefinition; +import com.azure.resourcemanager.cloudhealth.models.SignalDefinitionProperties; +import com.azure.resourcemanager.cloudhealth.models.SignalOperator; +import com.azure.resourcemanager.cloudhealth.models.ThresholdRule; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class SignalDefinitionsCreateOrUpdateWithResponseMockTests { + @Test + public void testCreateOrUpdateWithResponse() throws Exception { + String responseStr + = "{\"properties\":{\"signalKind\":\"SignalDefinitionProperties\",\"provisioningState\":\"Creating\",\"displayName\":\"ib\",\"refreshInterval\":\"PT5M\",\"labels\":{\"lfzxiavrmbzonoki\":\"ikpzimejza\",\"rgz\":\"rjqc\"},\"dataUnit\":\"rlazszrnw\",\"evaluationRules\":{\"dynamicDetectionRule\":{\"dynamicThresholdModel\":\"AnomalyDetection\",\"modelSensitivity\":40.13963187173724,\"dynamicThresholdDirection\":\"GreaterThan\",\"trainingStartTime\":\"2020-12-22T05:34:35Z\"},\"degradedRule\":{\"operator\":\"GreaterThan\",\"threshold\":\"ylwbtlhflsjcdhsz\"},\"unhealthyRule\":{\"operator\":\"LowerOrEquals\",\"threshold\":\"fbgofeljagrqmqh\"}},\"deletionDate\":\"2021-03-07T21:36:25Z\"},\"id\":\"iiiojnalghf\",\"name\":\"vtvsexsowueluq\",\"type\":\"hahhxvrhmzkwpj\"}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + CloudHealthManager manager = CloudHealthManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + SignalDefinition response = manager.signalDefinitions() + .define("rwkq") + .withExistingHealthmodel("bdeibqipqk", "hvxndzwmkrefajpj") + .withProperties(new SignalDefinitionProperties().withDisplayName("ij") + .withRefreshInterval(RefreshInterval.PT30M) + .withLabels(mapOf("ystawfsdjpvkvp", "xzsjabib", "jabudurgkakmo", "jxbkzbzkdvn", "gzrf", + "zhjjklffhmouwq", "ikayuhqlbjbsybb", "eeyebi")) + .withDataUnit("r") + .withEvaluationRules(new EvaluationRule() + .withDynamicDetectionRule( + new DynamicDetectionRule().withDynamicThresholdModel(DynamicThresholdModel.ANOMALY_DETECTION) + .withModelSensitivity(86.86379856850752) + .withDynamicThresholdDirection(DynamicThresholdDirection.LOWER_THAN) + .withTrainingStartTime(OffsetDateTime.parse("2021-06-20T07:23:19Z"))) + .withDegradedRule( + new ThresholdRule().withOperator(SignalOperator.GREATER_THAN).withThreshold("mpipaslthaqfxs")) + .withUnhealthyRule(new ThresholdRule().withOperator(SignalOperator.LOWER_THAN).withThreshold("u")))) + .create(); + + Assertions.assertEquals("ib", response.properties().displayName()); + Assertions.assertEquals(RefreshInterval.PT5M, response.properties().refreshInterval()); + Assertions.assertEquals("ikpzimejza", response.properties().labels().get("lfzxiavrmbzonoki")); + Assertions.assertEquals("rlazszrnw", response.properties().dataUnit()); + Assertions.assertEquals(DynamicThresholdModel.ANOMALY_DETECTION, + response.properties().evaluationRules().dynamicDetectionRule().dynamicThresholdModel()); + Assertions.assertEquals(40.13963187173724, + response.properties().evaluationRules().dynamicDetectionRule().modelSensitivity()); + Assertions.assertEquals(DynamicThresholdDirection.GREATER_THAN, + response.properties().evaluationRules().dynamicDetectionRule().dynamicThresholdDirection()); + Assertions.assertEquals(OffsetDateTime.parse("2020-12-22T05:34:35Z"), + response.properties().evaluationRules().dynamicDetectionRule().trainingStartTime()); + Assertions.assertEquals(SignalOperator.GREATER_THAN, + response.properties().evaluationRules().degradedRule().operator()); + Assertions.assertEquals("ylwbtlhflsjcdhsz", response.properties().evaluationRules().degradedRule().threshold()); + Assertions.assertEquals(SignalOperator.LOWER_OR_EQUALS, + response.properties().evaluationRules().unhealthyRule().operator()); + Assertions.assertEquals("fbgofeljagrqmqh", response.properties().evaluationRules().unhealthyRule().threshold()); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/SignalDefinitionsDeleteWithResponseMockTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/SignalDefinitionsDeleteWithResponseMockTests.java new file mode 100644 index 000000000000..d6ed45ba3720 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/SignalDefinitionsDeleteWithResponseMockTests.java @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.cloudhealth.CloudHealthManager; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class SignalDefinitionsDeleteWithResponseMockTests { + @Test + public void testDeleteWithResponse() throws Exception { + String responseStr = "{}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + CloudHealthManager manager = CloudHealthManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + manager.signalDefinitions() + .deleteWithResponse("bsfgytguslfea", "cy", "qukyhejhzi", com.azure.core.util.Context.NONE); + + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/SignalDefinitionsGetWithResponseMockTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/SignalDefinitionsGetWithResponseMockTests.java new file mode 100644 index 000000000000..b98c10e35e3f --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/SignalDefinitionsGetWithResponseMockTests.java @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.cloudhealth.CloudHealthManager; +import com.azure.resourcemanager.cloudhealth.models.DynamicThresholdDirection; +import com.azure.resourcemanager.cloudhealth.models.DynamicThresholdModel; +import com.azure.resourcemanager.cloudhealth.models.RefreshInterval; +import com.azure.resourcemanager.cloudhealth.models.SignalDefinition; +import com.azure.resourcemanager.cloudhealth.models.SignalOperator; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class SignalDefinitionsGetWithResponseMockTests { + @Test + public void testGetWithResponse() throws Exception { + String responseStr + = "{\"properties\":{\"signalKind\":\"SignalDefinitionProperties\",\"provisioningState\":\"Failed\",\"displayName\":\"cslfaoqzpiyylha\",\"refreshInterval\":\"PT5M\",\"labels\":{\"qscywu\":\"ccsphkaivwi\"},\"dataUnit\":\"woluhczbwemhair\",\"evaluationRules\":{\"dynamicDetectionRule\":{\"dynamicThresholdModel\":\"AnomalyDetection\",\"modelSensitivity\":12.991988684461575,\"dynamicThresholdDirection\":\"GreaterThan\",\"trainingStartTime\":\"2021-06-14T04:59:44Z\"},\"degradedRule\":{\"operator\":\"GreaterThan\",\"threshold\":\"eypqwdxggicccn\"},\"unhealthyRule\":{\"operator\":\"Equals\",\"threshold\":\"uexmkttlst\"}},\"deletionDate\":\"2021-09-29T19:52:13Z\"},\"id\":\"wem\",\"name\":\"zrncsdt\",\"type\":\"lusiy\"}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + CloudHealthManager manager = CloudHealthManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + SignalDefinition response = manager.signalDefinitions() + .getWithResponse("l", "zqhof", "rmaequ", com.azure.core.util.Context.NONE) + .getValue(); + + Assertions.assertEquals("cslfaoqzpiyylha", response.properties().displayName()); + Assertions.assertEquals(RefreshInterval.PT5M, response.properties().refreshInterval()); + Assertions.assertEquals("ccsphkaivwi", response.properties().labels().get("qscywu")); + Assertions.assertEquals("woluhczbwemhair", response.properties().dataUnit()); + Assertions.assertEquals(DynamicThresholdModel.ANOMALY_DETECTION, + response.properties().evaluationRules().dynamicDetectionRule().dynamicThresholdModel()); + Assertions.assertEquals(12.991988684461575, + response.properties().evaluationRules().dynamicDetectionRule().modelSensitivity()); + Assertions.assertEquals(DynamicThresholdDirection.GREATER_THAN, + response.properties().evaluationRules().dynamicDetectionRule().dynamicThresholdDirection()); + Assertions.assertEquals(OffsetDateTime.parse("2021-06-14T04:59:44Z"), + response.properties().evaluationRules().dynamicDetectionRule().trainingStartTime()); + Assertions.assertEquals(SignalOperator.GREATER_THAN, + response.properties().evaluationRules().degradedRule().operator()); + Assertions.assertEquals("eypqwdxggicccn", response.properties().evaluationRules().degradedRule().threshold()); + Assertions.assertEquals(SignalOperator.EQUALS, + response.properties().evaluationRules().unhealthyRule().operator()); + Assertions.assertEquals("uexmkttlst", response.properties().evaluationRules().unhealthyRule().threshold()); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/SignalDefinitionsListByHealthModelMockTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/SignalDefinitionsListByHealthModelMockTests.java new file mode 100644 index 000000000000..985dd1727391 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/SignalDefinitionsListByHealthModelMockTests.java @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.cloudhealth.CloudHealthManager; +import com.azure.resourcemanager.cloudhealth.models.DynamicThresholdDirection; +import com.azure.resourcemanager.cloudhealth.models.DynamicThresholdModel; +import com.azure.resourcemanager.cloudhealth.models.RefreshInterval; +import com.azure.resourcemanager.cloudhealth.models.SignalDefinition; +import com.azure.resourcemanager.cloudhealth.models.SignalOperator; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class SignalDefinitionsListByHealthModelMockTests { + @Test + public void testListByHealthModel() throws Exception { + String responseStr + = "{\"value\":[{\"properties\":{\"signalKind\":\"SignalDefinitionProperties\",\"provisioningState\":\"Failed\",\"displayName\":\"aehtwd\",\"refreshInterval\":\"PT5M\",\"labels\":{\"rcdlbhshfwpr\":\"wib\",\"hevxcced\":\"cstwity\"},\"dataUnit\":\"nmdyodnwzxl\",\"evaluationRules\":{\"dynamicDetectionRule\":{\"dynamicThresholdModel\":\"AnomalyDetection\",\"modelSensitivity\":61.44686132510554,\"dynamicThresholdDirection\":\"GreaterOrLowerThan\",\"trainingStartTime\":\"2021-02-20T03:38:09Z\"},\"degradedRule\":{\"operator\":\"GreaterThan\",\"threshold\":\"gcxn\"},\"unhealthyRule\":{\"operator\":\"GreaterOrEquals\",\"threshold\":\"wxqibyq\"}},\"deletionDate\":\"2021-05-22T21:00:43Z\"},\"id\":\"wxwlmdjrkvfgb\",\"name\":\"fvpdbo\",\"type\":\"acizsjqlhkrr\"}]}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + CloudHealthManager manager = CloudHealthManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + PagedIterable response = manager.signalDefinitions() + .listByHealthModel("xgfpelolppv", "srp", OffsetDateTime.parse("2021-02-05T20:48:24Z"), + com.azure.core.util.Context.NONE); + + Assertions.assertEquals("aehtwd", response.iterator().next().properties().displayName()); + Assertions.assertEquals(RefreshInterval.PT5M, response.iterator().next().properties().refreshInterval()); + Assertions.assertEquals("wib", response.iterator().next().properties().labels().get("rcdlbhshfwpr")); + Assertions.assertEquals("nmdyodnwzxl", response.iterator().next().properties().dataUnit()); + Assertions.assertEquals(DynamicThresholdModel.ANOMALY_DETECTION, + response.iterator().next().properties().evaluationRules().dynamicDetectionRule().dynamicThresholdModel()); + Assertions.assertEquals(61.44686132510554, + response.iterator().next().properties().evaluationRules().dynamicDetectionRule().modelSensitivity()); + Assertions.assertEquals(DynamicThresholdDirection.GREATER_OR_LOWER_THAN, + response.iterator() + .next() + .properties() + .evaluationRules() + .dynamicDetectionRule() + .dynamicThresholdDirection()); + Assertions.assertEquals(OffsetDateTime.parse("2021-02-20T03:38:09Z"), + response.iterator().next().properties().evaluationRules().dynamicDetectionRule().trainingStartTime()); + Assertions.assertEquals(SignalOperator.GREATER_THAN, + response.iterator().next().properties().evaluationRules().degradedRule().operator()); + Assertions.assertEquals("gcxn", + response.iterator().next().properties().evaluationRules().degradedRule().threshold()); + Assertions.assertEquals(SignalOperator.GREATER_OR_EQUALS, + response.iterator().next().properties().evaluationRules().unhealthyRule().operator()); + Assertions.assertEquals("wxqibyq", + response.iterator().next().properties().evaluationRules().unhealthyRule().threshold()); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/SignalGroupTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/SignalGroupTests.java new file mode 100644 index 000000000000..d8a6e2e7028f --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/SignalGroupTests.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.cloudhealth.models.AzureMonitorWorkspaceSignalGroup; +import com.azure.resourcemanager.cloudhealth.models.AzureResourceSignalGroup; +import com.azure.resourcemanager.cloudhealth.models.DependenciesAggregationType; +import com.azure.resourcemanager.cloudhealth.models.DependenciesSignalGroup; +import com.azure.resourcemanager.cloudhealth.models.LogAnalyticsSignalGroup; +import com.azure.resourcemanager.cloudhealth.models.SignalAssignment; +import com.azure.resourcemanager.cloudhealth.models.SignalGroup; +import java.util.Arrays; +import org.junit.jupiter.api.Assertions; + +public final class SignalGroupTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + SignalGroup model = BinaryData.fromString( + "{\"azureResource\":{\"signalAssignments\":[{\"signalDefinitions\":[\"krh\",\"hvljuahaquh\",\"dhmdua\"]},{\"signalDefinitions\":[\"exq\"]},{\"signalDefinitions\":[\"fadmws\",\"crgvxpvgom\"]},{\"signalDefinitions\":[\"fmisg\"]}],\"authenticationSetting\":\"bnbbeldawkz\",\"azureResourceId\":\"ali\"},\"azureLogAnalytics\":{\"signalAssignments\":[{\"signalDefinitions\":[\"akauha\",\"hsfwxosowzxcug\",\"cjooxdjebwpucwwf\"]},{\"signalDefinitions\":[\"vbvmeu\",\"civyhzceuo\",\"gjrwjueiotwmcdyt\"]},{\"signalDefinitions\":[\"wit\"]}],\"authenticationSetting\":\"nrjawgqwg\",\"logAnalyticsWorkspaceResourceId\":\"hniskxfbkpyc\"},\"azureMonitorWorkspace\":{\"signalAssignments\":[{\"signalDefinitions\":[\"dnhjdauwhvylw\",\"btdhxujznbm\"]},{\"signalDefinitions\":[\"wuwprzqlv\"]}],\"authenticationSetting\":\"ualupjmkh\",\"azureMonitorWorkspaceResourceId\":\"xobbcswsrt\"},\"dependencies\":{\"aggregationType\":\"Thresholds\",\"degradedThreshold\":\"lrbpbewtghfgbl\",\"unhealthyThreshold\":\"wxzvlvqhjkb\"}}") + .toObject(SignalGroup.class); + Assertions.assertEquals("krh", model.azureResource().signalAssignments().get(0).signalDefinitions().get(0)); + Assertions.assertEquals("bnbbeldawkz", model.azureResource().authenticationSetting()); + Assertions.assertEquals("ali", model.azureResource().azureResourceId()); + Assertions.assertEquals("akauha", + model.azureLogAnalytics().signalAssignments().get(0).signalDefinitions().get(0)); + Assertions.assertEquals("nrjawgqwg", model.azureLogAnalytics().authenticationSetting()); + Assertions.assertEquals("hniskxfbkpyc", model.azureLogAnalytics().logAnalyticsWorkspaceResourceId()); + Assertions.assertEquals("dnhjdauwhvylw", + model.azureMonitorWorkspace().signalAssignments().get(0).signalDefinitions().get(0)); + Assertions.assertEquals("ualupjmkh", model.azureMonitorWorkspace().authenticationSetting()); + Assertions.assertEquals("xobbcswsrt", model.azureMonitorWorkspace().azureMonitorWorkspaceResourceId()); + Assertions.assertEquals(DependenciesAggregationType.THRESHOLDS, model.dependencies().aggregationType()); + Assertions.assertEquals("lrbpbewtghfgbl", model.dependencies().degradedThreshold()); + Assertions.assertEquals("wxzvlvqhjkb", model.dependencies().unhealthyThreshold()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + SignalGroup model = new SignalGroup() + .withAzureResource(new AzureResourceSignalGroup() + .withSignalAssignments(Arrays.asList( + new SignalAssignment().withSignalDefinitions(Arrays.asList("krh", "hvljuahaquh", "dhmdua")), + new SignalAssignment().withSignalDefinitions(Arrays.asList("exq")), + new SignalAssignment().withSignalDefinitions(Arrays.asList("fadmws", "crgvxpvgom")), + new SignalAssignment().withSignalDefinitions(Arrays.asList("fmisg")))) + .withAuthenticationSetting("bnbbeldawkz") + .withAzureResourceId("ali")) + .withAzureLogAnalytics(new LogAnalyticsSignalGroup().withSignalAssignments(Arrays.asList( + new SignalAssignment() + .withSignalDefinitions(Arrays.asList("akauha", "hsfwxosowzxcug", "cjooxdjebwpucwwf")), + new SignalAssignment().withSignalDefinitions(Arrays.asList("vbvmeu", "civyhzceuo", "gjrwjueiotwmcdyt")), + new SignalAssignment().withSignalDefinitions(Arrays.asList("wit")))) + .withAuthenticationSetting("nrjawgqwg") + .withLogAnalyticsWorkspaceResourceId("hniskxfbkpyc")) + .withAzureMonitorWorkspace(new AzureMonitorWorkspaceSignalGroup() + .withSignalAssignments(Arrays.asList( + new SignalAssignment().withSignalDefinitions(Arrays.asList("dnhjdauwhvylw", "btdhxujznbm")), + new SignalAssignment().withSignalDefinitions(Arrays.asList("wuwprzqlv")))) + .withAuthenticationSetting("ualupjmkh") + .withAzureMonitorWorkspaceResourceId("xobbcswsrt")) + .withDependencies(new DependenciesSignalGroup().withAggregationType(DependenciesAggregationType.THRESHOLDS) + .withDegradedThreshold("lrbpbewtghfgbl") + .withUnhealthyThreshold("wxzvlvqhjkb")); + model = BinaryData.fromObject(model).toObject(SignalGroup.class); + Assertions.assertEquals("krh", model.azureResource().signalAssignments().get(0).signalDefinitions().get(0)); + Assertions.assertEquals("bnbbeldawkz", model.azureResource().authenticationSetting()); + Assertions.assertEquals("ali", model.azureResource().azureResourceId()); + Assertions.assertEquals("akauha", + model.azureLogAnalytics().signalAssignments().get(0).signalDefinitions().get(0)); + Assertions.assertEquals("nrjawgqwg", model.azureLogAnalytics().authenticationSetting()); + Assertions.assertEquals("hniskxfbkpyc", model.azureLogAnalytics().logAnalyticsWorkspaceResourceId()); + Assertions.assertEquals("dnhjdauwhvylw", + model.azureMonitorWorkspace().signalAssignments().get(0).signalDefinitions().get(0)); + Assertions.assertEquals("ualupjmkh", model.azureMonitorWorkspace().authenticationSetting()); + Assertions.assertEquals("xobbcswsrt", model.azureMonitorWorkspace().azureMonitorWorkspaceResourceId()); + Assertions.assertEquals(DependenciesAggregationType.THRESHOLDS, model.dependencies().aggregationType()); + Assertions.assertEquals("lrbpbewtghfgbl", model.dependencies().degradedThreshold()); + Assertions.assertEquals("wxzvlvqhjkb", model.dependencies().unhealthyThreshold()); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/ThresholdRuleTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/ThresholdRuleTests.java new file mode 100644 index 000000000000..db0c87503bf7 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/ThresholdRuleTests.java @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.cloudhealth.models.SignalOperator; +import com.azure.resourcemanager.cloudhealth.models.ThresholdRule; +import org.junit.jupiter.api.Assertions; + +public final class ThresholdRuleTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + ThresholdRule model = BinaryData.fromString("{\"operator\":\"LowerOrEquals\",\"threshold\":\"dcsi\"}") + .toObject(ThresholdRule.class); + Assertions.assertEquals(SignalOperator.LOWER_OR_EQUALS, model.operator()); + Assertions.assertEquals("dcsi", model.threshold()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + ThresholdRule model = new ThresholdRule().withOperator(SignalOperator.LOWER_OR_EQUALS).withThreshold("dcsi"); + model = BinaryData.fromObject(model).toObject(ThresholdRule.class); + Assertions.assertEquals(SignalOperator.LOWER_OR_EQUALS, model.operator()); + Assertions.assertEquals("dcsi", model.threshold()); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/UserAssignedIdentityTests.java b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/UserAssignedIdentityTests.java new file mode 100644 index 000000000000..c9422dedd8c0 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/src/test/java/com/azure/resourcemanager/cloudhealth/generated/UserAssignedIdentityTests.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.cloudhealth.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.cloudhealth.models.UserAssignedIdentity; + +public final class UserAssignedIdentityTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + UserAssignedIdentity model = BinaryData.fromString("{\"principalId\":\"tnhxbn\",\"clientId\":\"iksqr\"}") + .toObject(UserAssignedIdentity.class); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + UserAssignedIdentity model = new UserAssignedIdentity(); + model = BinaryData.fromObject(model).toObject(UserAssignedIdentity.class); + } +} diff --git a/sdk/cloudhealth/azure-resourcemanager-cloudhealth/tsp-location.yaml b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/tsp-location.yaml new file mode 100644 index 000000000000..1c6afe6988b2 --- /dev/null +++ b/sdk/cloudhealth/azure-resourcemanager-cloudhealth/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/cloudhealth/CloudHealth.Management +commit: a7cd3fbd39eb9ec8a620e00ec1b1e2624bb97503 +repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/cloudhealth/ci.yml b/sdk/cloudhealth/ci.yml new file mode 100644 index 000000000000..01b2c3569ab4 --- /dev/null +++ b/sdk/cloudhealth/ci.yml @@ -0,0 +1,46 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: + branches: + include: + - main + - hotfix/* + - release/* + paths: + include: + - sdk/cloudhealth/ci.yml + - sdk/cloudhealth/azure-resourcemanager-cloudhealth/ + exclude: + - sdk/cloudhealth/pom.xml + - sdk/cloudhealth/azure-resourcemanager-cloudhealth/pom.xml + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/cloudhealth/ci.yml + - sdk/cloudhealth/azure-resourcemanager-cloudhealth/ + exclude: + - sdk/cloudhealth/pom.xml + - sdk/cloudhealth/azure-resourcemanager-cloudhealth/pom.xml + +parameters: + - name: release_azureresourcemanagercloudhealth + displayName: azure-resourcemanager-cloudhealth + type: boolean + default: false + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: cloudhealth + Artifacts: + - name: azure-resourcemanager-cloudhealth + groupId: com.azure.resourcemanager + safeName: azureresourcemanagercloudhealth + releaseInBatch: ${{ parameters.release_azureresourcemanagercloudhealth }} diff --git a/sdk/cloudhealth/pom.xml b/sdk/cloudhealth/pom.xml new file mode 100644 index 000000000000..f55a6702d51f --- /dev/null +++ b/sdk/cloudhealth/pom.xml @@ -0,0 +1,15 @@ + + + 4.0.0 + com.azure + azure-cloudhealth-service + pom + 1.0.0 + + + azure-resourcemanager-cloudhealth + +