From 2ab71c81fbd4e094d5cc019ef4cb3be2abcbb4f8 Mon Sep 17 00:00:00 2001 From: wyunchi-ms Date: Wed, 2 Dec 2020 23:50:59 +0800 Subject: [PATCH 1/4] Init for CostManagement --- documentation/azure-powershell-modules.md | 3 + src/CostManagement/Az.CostManagement.csproj | 7 + .../Az.CostManagement.format.ps1xml | 1817 +++++++ src/CostManagement/Az.CostManagement.psd1 | 138 + src/CostManagement/Az.CostManagement.psm1 | 109 + src/CostManagement/Changelog.md | 24 + src/CostManagement/CostManagement.sln | 48 + src/CostManagement/Properties/AssemblyInfo.cs | 28 + src/CostManagement/build-module.ps1 | 153 + src/CostManagement/check-dependencies.ps1 | 64 + .../custom/Az.CostManagement.custom.psm1 | 17 + .../custom/Invoke-AzCostManagementQuery.ps1 | 276 ++ .../custom/New-AzCostManagementExport.ps1 | 231 + ...agementQueryComparisonExpressionObject.ps1 | 52 + .../New-AzCostManagementQueryFilterObject.ps1 | 60 + .../custom/Update-AzCostManagementExport.ps1 | 294 ++ src/CostManagement/custom/readme.md | 41 + .../examples/Get-AzCostManagementExport.md | 24 + ...-AzCostManagementExportExecutionHistory.md | 25 + .../Invoke-AzCostManagementExecuteExport.md | 17 + .../examples/Invoke-AzCostManagementQuery.md | 24 + .../examples/New-AzCostManagementExport.md | 11 + ...nagementQueryComparisonExpressionObject.md | 11 + .../New-AzCostManagementQueryFilterObject.md | 15 + .../examples/Remove-AzCostManagementExport.md | 19 + .../examples/Update-AzCostManagementExport.md | 23 + src/CostManagement/export-surface.ps1 | 40 + .../exports/Get-AzCostManagementExport.ps1 | 172 + ...AzCostManagementExportExecutionHistory.ps1 | 163 + .../Invoke-AzCostManagementExecuteExport.ps1 | 161 + .../exports/Invoke-AzCostManagementQuery.ps1 | 226 + .../exports/New-AzCostManagementExport.ps1 | 241 + ...agementQueryComparisonExpressionObject.ps1 | 90 + .../New-AzCostManagementQueryFilterObject.ps1 | 157 + .../exports/ProxyCmdletDefinitions.ps1 | 1646 ++++++ .../exports/Remove-AzCostManagementExport.ps1 | 164 + .../exports/Update-AzCostManagementExport.ps1 | 272 + src/CostManagement/exports/readme.md | 20 + src/CostManagement/generate-help.ps1 | 73 + src/CostManagement/generate-info.json | 8 + src/CostManagement/generated/Module.cs | 158 + .../generated/api/CostManagement.cs | 4410 +++++++++++++++++ .../Models/Api20200601/Alert.PowerShell.cs | 199 + .../Models/Api20200601/Alert.TypeConverter.cs | 142 + .../generated/api/Models/Api20200601/Alert.cs | 489 ++ .../api/Models/Api20200601/Alert.json.cs | 103 + .../Api20200601/AlertProperties.PowerShell.cs | 187 + .../AlertProperties.TypeConverter.cs | 142 + .../api/Models/Api20200601/AlertProperties.cs | 468 ++ .../Api20200601/AlertProperties.json.cs | 120 + .../AlertPropertiesDefinition.PowerShell.cs | 137 + ...AlertPropertiesDefinition.TypeConverter.cs | 142 + .../Api20200601/AlertPropertiesDefinition.cs | 80 + .../AlertPropertiesDefinition.json.cs | 105 + .../AlertPropertiesDetails.PowerShell.cs | 163 + .../AlertPropertiesDetails.TypeConverter.cs | 142 + .../Api20200601/AlertPropertiesDetails.cs | 301 ++ .../AlertPropertiesDetails.json.cs | 179 + ...rtPropertiesDetailsTagFilter.PowerShell.cs | 131 + ...ropertiesDetailsTagFilter.TypeConverter.cs | 142 + .../AlertPropertiesDetailsTagFilter.cs | 29 + .../AlertPropertiesDetailsTagFilter.json.cs | 99 + .../Api20200601/AlertsResult.PowerShell.cs | 133 + .../Api20200601/AlertsResult.TypeConverter.cs | 142 + .../api/Models/Api20200601/AlertsResult.cs | 69 + .../Models/Api20200601/AlertsResult.json.cs | 117 + .../CommonExportProperties.PowerShell.cs | 169 + .../CommonExportProperties.TypeConverter.cs | 142 + .../Api20200601/CommonExportProperties.cs | 295 ++ .../CommonExportProperties.json.cs | 112 + .../Api20200601/Dimension.PowerShell.cs | 155 + .../Api20200601/Dimension.TypeConverter.cs | 142 + .../api/Models/Api20200601/Dimension.cs | 234 + .../api/Models/Api20200601/Dimension.json.cs | 102 + .../DimensionProperties.PowerShell.cs | 145 + .../DimensionProperties.TypeConverter.cs | 142 + .../Models/Api20200601/DimensionProperties.cs | 202 + .../Api20200601/DimensionProperties.json.cs | 148 + .../DimensionsListResult.PowerShell.cs | 133 + .../DimensionsListResult.TypeConverter.cs | 142 + .../Api20200601/DimensionsListResult.cs | 49 + .../Api20200601/DimensionsListResult.json.cs | 112 + .../DismissAlertPayload.PowerShell.cs | 191 + .../DismissAlertPayload.TypeConverter.cs | 142 + .../Models/Api20200601/DismissAlertPayload.cs | 442 ++ .../Api20200601/DismissAlertPayload.json.cs | 101 + .../Api20200601/ErrorDetails.PowerShell.cs | 133 + .../Api20200601/ErrorDetails.TypeConverter.cs | 142 + .../api/Models/Api20200601/ErrorDetails.cs | 69 + .../Models/Api20200601/ErrorDetails.json.cs | 109 + .../Api20200601/ErrorResponse.PowerShell.cs | 149 + .../ErrorResponse.TypeConverter.cs | 142 + .../api/Models/Api20200601/ErrorResponse.cs | 95 + .../Models/Api20200601/ErrorResponse.json.cs | 109 + .../Models/Api20200601/Export.PowerShell.cs | 189 + .../Api20200601/Export.TypeConverter.cs | 142 + .../api/Models/Api20200601/Export.cs | 402 ++ .../api/Models/Api20200601/Export.json.cs | 103 + .../Api20200601/ExportDataset.PowerShell.cs | 135 + .../ExportDataset.TypeConverter.cs | 142 + .../api/Models/Api20200601/ExportDataset.cs | 81 + .../Models/Api20200601/ExportDataset.json.cs | 103 + .../ExportDatasetConfiguration.PowerShell.cs | 137 + ...xportDatasetConfiguration.TypeConverter.cs | 142 + .../Api20200601/ExportDatasetConfiguration.cs | 60 + .../ExportDatasetConfiguration.json.cs | 112 + .../ExportDefinition.PowerShell.cs | 147 + .../ExportDefinition.TypeConverter.cs | 142 + .../Models/Api20200601/ExportDefinition.cs | 172 + .../Api20200601/ExportDefinition.json.cs | 107 + .../ExportDeliveryDestination.PowerShell.cs | 147 + ...ExportDeliveryDestination.TypeConverter.cs | 142 + .../Api20200601/ExportDeliveryDestination.cs | 94 + .../ExportDeliveryDestination.json.cs | 111 + .../ExportDeliveryInfo.PowerShell.cs | 137 + .../ExportDeliveryInfo.TypeConverter.cs | 142 + .../Models/Api20200601/ExportDeliveryInfo.cs | 83 + .../Api20200601/ExportDeliveryInfo.json.cs | 101 + .../Api20200601/ExportExecution.PowerShell.cs | 199 + .../ExportExecution.TypeConverter.cs | 142 + .../api/Models/Api20200601/ExportExecution.cs | 504 ++ .../Api20200601/ExportExecution.json.cs | 103 + .../ExportExecutionListResult.PowerShell.cs | 133 + ...ExportExecutionListResult.TypeConverter.cs | 142 + .../Api20200601/ExportExecutionListResult.cs | 49 + .../ExportExecutionListResult.json.cs | 112 + .../ExportExecutionProperties.PowerShell.cs | 191 + ...ExportExecutionProperties.TypeConverter.cs | 142 + .../Api20200601/ExportExecutionProperties.cs | 454 ++ .../ExportExecutionProperties.json.cs | 117 + .../ExportListResult.PowerShell.cs | 133 + .../ExportListResult.TypeConverter.cs | 142 + .../Models/Api20200601/ExportListResult.cs | 51 + .../Api20200601/ExportListResult.json.cs | 114 + .../ExportProperties.PowerShell.cs | 179 + .../ExportProperties.TypeConverter.cs | 142 + .../Models/Api20200601/ExportProperties.cs | 222 + .../Api20200601/ExportProperties.json.cs | 103 + .../ExportRecurrencePeriod.PowerShell.cs | 135 + .../ExportRecurrencePeriod.TypeConverter.cs | 142 + .../Api20200601/ExportRecurrencePeriod.cs | 63 + .../ExportRecurrencePeriod.json.cs | 103 + .../Api20200601/ExportSchedule.PowerShell.cs | 139 + .../ExportSchedule.TypeConverter.cs | 142 + .../api/Models/Api20200601/ExportSchedule.cs | 115 + .../Models/Api20200601/ExportSchedule.json.cs | 105 + .../ExportTimePeriod.PowerShell.cs | 137 + .../ExportTimePeriod.TypeConverter.cs | 142 + .../Models/Api20200601/ExportTimePeriod.cs | 68 + .../Api20200601/ExportTimePeriod.json.cs | 106 + .../Api20200601/ForecastDataset.PowerShell.cs | 139 + .../ForecastDataset.TypeConverter.cs | 142 + .../api/Models/Api20200601/ForecastDataset.cs | 130 + .../Api20200601/ForecastDataset.json.cs | 107 + .../ForecastDatasetAggregation.PowerShell.cs | 139 + ...orecastDatasetAggregation.TypeConverter.cs | 142 + .../Api20200601/ForecastDatasetAggregation.cs | 35 + .../ForecastDatasetAggregation.dictionary.cs | 70 + .../ForecastDatasetAggregation.json.cs | 105 + .../ForecastDefinition.PowerShell.cs | 155 + .../ForecastDefinition.TypeConverter.cs | 142 + .../Models/Api20200601/ForecastDefinition.cs | 237 + .../Api20200601/ForecastDefinition.json.cs | 111 + .../Api20200601/KpiProperties.PowerShell.cs | 135 + .../KpiProperties.TypeConverter.cs | 142 + .../api/Models/Api20200601/KpiProperties.cs | 80 + .../Models/Api20200601/KpiProperties.json.cs | 105 + .../Api20200601/Operation.PowerShell.cs | 139 + .../Api20200601/Operation.TypeConverter.cs | 142 + .../api/Models/Api20200601/Operation.cs | 112 + .../api/Models/Api20200601/Operation.json.cs | 106 + .../OperationDisplay.PowerShell.cs | 135 + .../OperationDisplay.TypeConverter.cs | 142 + .../Models/Api20200601/OperationDisplay.cs | 89 + .../Api20200601/OperationDisplay.json.cs | 114 + .../OperationListResult.PowerShell.cs | 135 + .../OperationListResult.TypeConverter.cs | 142 + .../Models/Api20200601/OperationListResult.cs | 77 + .../Api20200601/OperationListResult.json.cs | 119 + .../Api20200601/PivotProperties.PowerShell.cs | 133 + .../PivotProperties.TypeConverter.cs | 142 + .../api/Models/Api20200601/PivotProperties.cs | 63 + .../Api20200601/PivotProperties.json.cs | 103 + .../Api20200601/ProxyResource.PowerShell.cs | 137 + .../ProxyResource.TypeConverter.cs | 142 + .../api/Models/Api20200601/ProxyResource.cs | 115 + .../Models/Api20200601/ProxyResource.json.cs | 116 + .../QueryAggregation.PowerShell.cs | 133 + .../QueryAggregation.TypeConverter.cs | 142 + .../Models/Api20200601/QueryAggregation.cs | 66 + .../Api20200601/QueryAggregation.json.cs | 103 + .../Api20200601/QueryColumn.PowerShell.cs | 131 + .../Api20200601/QueryColumn.TypeConverter.cs | 142 + .../api/Models/Api20200601/QueryColumn.cs | 60 + .../Models/Api20200601/QueryColumn.json.cs | 102 + .../QueryComparisonExpression.PowerShell.cs | 137 + ...QueryComparisonExpression.TypeConverter.cs | 142 + .../Api20200601/QueryComparisonExpression.cs | 80 + .../QueryComparisonExpression.json.cs | 113 + .../Api20200601/QueryDataset.PowerShell.cs | 141 + .../Api20200601/QueryDataset.TypeConverter.cs | 142 + .../api/Models/Api20200601/QueryDataset.cs | 153 + .../Models/Api20200601/QueryDataset.json.cs | 117 + .../QueryDatasetAggregation.PowerShell.cs | 139 + .../QueryDatasetAggregation.TypeConverter.cs | 142 + .../Api20200601/QueryDatasetAggregation.cs | 35 + .../QueryDatasetAggregation.dictionary.cs | 70 + .../QueryDatasetAggregation.json.cs | 105 + .../QueryDatasetConfiguration.PowerShell.cs | 133 + ...QueryDatasetConfiguration.TypeConverter.cs | 142 + .../Api20200601/QueryDatasetConfiguration.cs | 55 + .../QueryDatasetConfiguration.json.cs | 109 + .../Api20200601/QueryDefinition.PowerShell.cs | 153 + .../QueryDefinition.TypeConverter.cs | 142 + .../api/Models/Api20200601/QueryDefinition.cs | 223 + .../Api20200601/QueryDefinition.json.cs | 107 + .../Api20200601/QueryFilter.PowerShell.cs | 139 + .../Api20200601/QueryFilter.TypeConverter.cs | 142 + .../api/Models/Api20200601/QueryFilter.cs | 114 + .../Models/Api20200601/QueryFilter.json.cs | 125 + .../Api20200601/QueryGrouping.PowerShell.cs | 133 + .../QueryGrouping.TypeConverter.cs | 142 + .../api/Models/Api20200601/QueryGrouping.cs | 63 + .../Models/Api20200601/QueryGrouping.json.cs | 103 + .../Api20200601/QueryProperties.PowerShell.cs | 133 + .../QueryProperties.TypeConverter.cs | 142 + .../api/Models/Api20200601/QueryProperties.cs | 77 + .../Api20200601/QueryProperties.json.cs | 120 + .../Api20200601/QueryResult.PowerShell.cs | 147 + .../Api20200601/QueryResult.TypeConverter.cs | 142 + .../api/Models/Api20200601/QueryResult.cs | 140 + .../Models/Api20200601/QueryResult.json.cs | 105 + .../Api20200601/QueryTimePeriod.PowerShell.cs | 133 + .../QueryTimePeriod.TypeConverter.cs | 142 + .../api/Models/Api20200601/QueryTimePeriod.cs | 63 + .../Api20200601/QueryTimePeriod.json.cs | 103 + .../ReportConfigAggregation.PowerShell.cs | 135 + .../ReportConfigAggregation.TypeConverter.cs | 142 + .../Api20200601/ReportConfigAggregation.cs | 66 + .../ReportConfigAggregation.json.cs | 103 + ...rtConfigComparisonExpression.PowerShell.cs | 137 + ...onfigComparisonExpression.TypeConverter.cs | 142 + .../ReportConfigComparisonExpression.cs | 80 + .../ReportConfigComparisonExpression.json.cs | 113 + .../ReportConfigDataset.PowerShell.cs | 143 + .../ReportConfigDataset.TypeConverter.cs | 142 + .../Models/Api20200601/ReportConfigDataset.cs | 170 + .../Api20200601/ReportConfigDataset.json.cs | 127 + .../ReportConfigDataset1.PowerShell.cs | 145 + .../ReportConfigDataset1.TypeConverter.cs | 142 + .../Api20200601/ReportConfigDataset1.cs | 170 + .../Api20200601/ReportConfigDataset1.json.cs | 127 + ...portConfigDatasetAggregation.PowerShell.cs | 139 + ...tConfigDatasetAggregation.TypeConverter.cs | 142 + .../ReportConfigDatasetAggregation.cs | 35 + ...portConfigDatasetAggregation.dictionary.cs | 70 + .../ReportConfigDatasetAggregation.json.cs | 105 + ...rtConfigDatasetConfiguration.PowerShell.cs | 133 + ...onfigDatasetConfiguration.TypeConverter.cs | 142 + .../ReportConfigDatasetConfiguration.cs | 55 + .../ReportConfigDatasetConfiguration.json.cs | 109 + .../ReportConfigDefinition.PowerShell.cs | 157 + .../ReportConfigDefinition.TypeConverter.cs | 142 + .../Api20200601/ReportConfigDefinition.cs | 249 + .../ReportConfigDefinition.json.cs | 107 + .../ReportConfigDefinition1.PowerShell.cs | 157 + .../ReportConfigDefinition1.TypeConverter.cs | 142 + .../Api20200601/ReportConfigDefinition1.cs | 249 + .../ReportConfigDefinition1.json.cs | 107 + .../ReportConfigFilter.PowerShell.cs | 139 + .../ReportConfigFilter.TypeConverter.cs | 142 + .../Models/Api20200601/ReportConfigFilter.cs | 114 + .../Api20200601/ReportConfigFilter.json.cs | 125 + .../ReportConfigFilter1.PowerShell.cs | 139 + .../ReportConfigFilter1.TypeConverter.cs | 142 + .../Models/Api20200601/ReportConfigFilter1.cs | 114 + .../Api20200601/ReportConfigFilter1.json.cs | 125 + .../ReportConfigGrouping.PowerShell.cs | 135 + .../ReportConfigGrouping.TypeConverter.cs | 142 + .../Api20200601/ReportConfigGrouping.cs | 69 + .../Api20200601/ReportConfigGrouping.json.cs | 103 + .../ReportConfigSorting.PowerShell.cs | 133 + .../ReportConfigSorting.TypeConverter.cs | 142 + .../Models/Api20200601/ReportConfigSorting.cs | 63 + .../Api20200601/ReportConfigSorting.json.cs | 103 + .../ReportConfigTimePeriod.PowerShell.cs | 135 + .../ReportConfigTimePeriod.TypeConverter.cs | 142 + .../Api20200601/ReportConfigTimePeriod.cs | 63 + .../ReportConfigTimePeriod.json.cs | 103 + .../Models/Api20200601/Resource.PowerShell.cs | 137 + .../Api20200601/Resource.TypeConverter.cs | 142 + .../api/Models/Api20200601/Resource.cs | 109 + .../api/Models/Api20200601/Resource.json.cs | 119 + .../Api20200601/ResourceTags.PowerShell.cs | 133 + .../Api20200601/ResourceTags.TypeConverter.cs | 142 + .../api/Models/Api20200601/ResourceTags.cs | 30 + .../Api20200601/ResourceTags.dictionary.cs | 70 + .../Models/Api20200601/ResourceTags.json.cs | 102 + .../api/Models/Api20200601/View.PowerShell.cs | 185 + .../Models/Api20200601/View.TypeConverter.cs | 142 + .../generated/api/Models/Api20200601/View.cs | 455 ++ .../api/Models/Api20200601/View.json.cs | 103 + .../Api20200601/ViewListResult.PowerShell.cs | 133 + .../ViewListResult.TypeConverter.cs | 142 + .../api/Models/Api20200601/ViewListResult.cs | 69 + .../Models/Api20200601/ViewListResult.json.cs | 117 + .../Api20200601/ViewProperties.PowerShell.cs | 175 + .../ViewProperties.TypeConverter.cs | 142 + .../api/Models/Api20200601/ViewProperties.cs | 430 ++ .../Models/Api20200601/ViewProperties.json.cs | 141 + .../CostManagementIdentity.PowerShell.cs | 146 + .../CostManagementIdentity.TypeConverter.cs | 157 + .../api/Models/CostManagementIdentity.cs | 198 + .../api/Models/CostManagementIdentity.json.cs | 117 + .../api/Support/AccumulatedType.Completer.cs | 39 + .../Support/AccumulatedType.TypeConverter.cs | 59 + .../generated/api/Support/AccumulatedType.cs | 97 + .../api/Support/AlertCategory.Completer.cs | 47 + .../Support/AlertCategory.TypeConverter.cs | 59 + .../generated/api/Support/AlertCategory.cs | 101 + .../api/Support/AlertCriteria.Completer.cs | 87 + .../Support/AlertCriteria.TypeConverter.cs | 59 + .../generated/api/Support/AlertCriteria.cs | 121 + .../api/Support/AlertOperator.Completer.cs | 55 + .../Support/AlertOperator.TypeConverter.cs | 59 + .../generated/api/Support/AlertOperator.cs | 105 + .../api/Support/AlertSource.Completer.cs | 39 + .../api/Support/AlertSource.TypeConverter.cs | 59 + .../generated/api/Support/AlertSource.cs | 97 + .../api/Support/AlertStatus.Completer.cs | 51 + .../api/Support/AlertStatus.TypeConverter.cs | 59 + .../generated/api/Support/AlertStatus.cs | 103 + .../Support/AlertTimeGrainType.Completer.cs | 59 + .../AlertTimeGrainType.TypeConverter.cs | 59 + .../api/Support/AlertTimeGrainType.cs | 107 + .../api/Support/AlertType.Completer.cs | 59 + .../api/Support/AlertType.TypeConverter.cs | 59 + .../generated/api/Support/AlertType.cs | 107 + .../api/Support/ChartType.Completer.cs | 51 + .../api/Support/ChartType.TypeConverter.cs | 59 + .../generated/api/Support/ChartType.cs | 103 + .../api/Support/ExecutionStatus.Completer.cs | 59 + .../Support/ExecutionStatus.TypeConverter.cs | 59 + .../generated/api/Support/ExecutionStatus.cs | 107 + .../api/Support/ExecutionType.Completer.cs | 39 + .../Support/ExecutionType.TypeConverter.cs | 59 + .../generated/api/Support/ExecutionType.cs | 97 + .../api/Support/ExportType.Completer.cs | 43 + .../api/Support/ExportType.TypeConverter.cs | 59 + .../generated/api/Support/ExportType.cs | 99 + .../ExternalCloudProviderType.Completer.cs | 39 + ...ExternalCloudProviderType.TypeConverter.cs | 59 + .../api/Support/ExternalCloudProviderType.cs | 97 + .../ForecastTimeframeType.Completer.cs | 55 + .../ForecastTimeframeType.TypeConverter.cs | 59 + .../api/Support/ForecastTimeframeType.cs | 105 + .../api/Support/ForecastType.Completer.cs | 43 + .../api/Support/ForecastType.TypeConverter.cs | 59 + .../generated/api/Support/ForecastType.cs | 99 + .../api/Support/FormatType.Completer.cs | 35 + .../api/Support/FormatType.TypeConverter.cs | 59 + .../generated/api/Support/FormatType.cs | 95 + .../api/Support/GranularityType.Completer.cs | 35 + .../Support/GranularityType.TypeConverter.cs | 59 + .../generated/api/Support/GranularityType.cs | 95 + .../api/Support/KpiType.Completer.cs | 39 + .../api/Support/KpiType.TypeConverter.cs | 59 + .../generated/api/Support/KpiType.cs | 97 + .../api/Support/MetricType.Completer.cs | 43 + .../api/Support/MetricType.TypeConverter.cs | 59 + .../generated/api/Support/MetricType.cs | 99 + .../api/Support/OperatorType.Completer.cs | 39 + .../api/Support/OperatorType.TypeConverter.cs | 59 + .../generated/api/Support/OperatorType.cs | 97 + .../api/Support/PivotType.Completer.cs | 39 + .../api/Support/PivotType.TypeConverter.cs | 59 + .../generated/api/Support/PivotType.cs | 97 + .../api/Support/QueryColumnType.Completer.cs | 39 + .../Support/QueryColumnType.TypeConverter.cs | 59 + .../generated/api/Support/QueryColumnType.cs | 97 + .../api/Support/RecurrenceType.Completer.cs | 47 + .../Support/RecurrenceType.TypeConverter.cs | 59 + .../generated/api/Support/RecurrenceType.cs | 101 + .../ReportConfigColumnType.Completer.cs | 39 + .../ReportConfigColumnType.TypeConverter.cs | 59 + .../api/Support/ReportConfigColumnType.cs | 97 + .../ReportGranularityType.Completer.cs | 39 + .../ReportGranularityType.TypeConverter.cs | 59 + .../api/Support/ReportGranularityType.cs | 97 + .../Support/ReportTimeframeType.Completer.cs | 47 + .../ReportTimeframeType.TypeConverter.cs | 59 + .../api/Support/ReportTimeframeType.cs | 101 + .../api/Support/StatusType.Completer.cs | 39 + .../api/Support/StatusType.TypeConverter.cs | 59 + .../generated/api/Support/StatusType.cs | 97 + .../api/Support/TimeframeType.Completer.cs | 55 + .../Support/TimeframeType.TypeConverter.cs | 59 + .../generated/api/Support/TimeframeType.cs | 105 + ...ostManagementExportExecutionHistory_Get.cs | 383 ++ ...ntExportExecutionHistory_GetViaIdentity.cs | 376 ++ .../cmdlets/GetAzCostManagementExport_Get.cs | 398 ++ ...etAzCostManagementExport_GetViaIdentity.cs | 390 ++ .../cmdlets/GetAzCostManagementExport_List.cs | 384 ++ .../GetAzCostManagementOperation_List.cs | 361 ++ ...keAzCostManagementExecuteExport_Execute.cs | 388 ++ ...agementExecuteExport_ExecuteViaIdentity.cs | 381 ++ ...ewAzCostManagementExport_CreateExpanded.cs | 615 +++ .../RemoveAzCostManagementExport_Delete.cs | 389 ++ ...zCostManagementExport_DeleteViaIdentity.cs | 381 ++ ...teAzCostManagementExport_UpdateExpanded.cs | 615 +++ ...agementExport_UpdateViaIdentityExpanded.cs | 607 +++ .../generated/runtime/AsyncCommandRuntime.cs | 828 ++++ .../generated/runtime/AsyncJob.cs | 270 + .../runtime/AsyncOperationResponse.cs | 177 + .../BuildTime/Cmdlets/ExportCmdletSurface.cs | 113 + .../BuildTime/Cmdlets/ExportExampleStub.cs | 74 + .../BuildTime/Cmdlets/ExportFormatPs1xml.cs | 99 + .../BuildTime/Cmdlets/ExportHelpMarkdown.cs | 53 + .../BuildTime/Cmdlets/ExportModelSurface.cs | 117 + .../BuildTime/Cmdlets/ExportProxyCmdlet.cs | 159 + .../runtime/BuildTime/Cmdlets/ExportPsd1.cs | 125 + .../BuildTime/Cmdlets/ExportTestStub.cs | 137 + .../BuildTime/Cmdlets/GetCommonParameter.cs | 52 + .../BuildTime/Cmdlets/GetModuleGuid.cs | 31 + .../BuildTime/Cmdlets/GetScriptCmdlet.cs | 53 + .../runtime/BuildTime/CollectionExtensions.cs | 20 + .../runtime/BuildTime/MarkdownRenderer.cs | 121 + .../runtime/BuildTime/Models/PsFormatTypes.cs | 138 + .../BuildTime/Models/PsHelpMarkdownOutputs.cs | 177 + .../runtime/BuildTime/Models/PsHelpTypes.cs | 199 + .../BuildTime/Models/PsMarkdownTypes.cs | 291 ++ .../BuildTime/Models/PsProxyOutputs.cs | 513 ++ .../runtime/BuildTime/Models/PsProxyTypes.cs | 499 ++ .../runtime/BuildTime/PsAttributes.cs | 114 + .../runtime/BuildTime/PsExtensions.cs | 160 + .../generated/runtime/BuildTime/PsHelpers.cs | 104 + .../runtime/BuildTime/StringExtensions.cs | 24 + .../runtime/BuildTime/XmlExtensions.cs | 28 + .../generated/runtime/CmdInfoHandler.cs | 40 + .../Conversions/ConversionException.cs | 17 + .../runtime/Conversions/IJsonConverter.cs | 13 + .../Conversions/Instances/BinaryConverter.cs | 24 + .../Conversions/Instances/BooleanConverter.cs | 13 + .../Instances/DateTimeConverter.cs | 18 + .../Instances/DateTimeOffsetConverter.cs | 15 + .../Conversions/Instances/DecimalConverter.cs | 16 + .../Conversions/Instances/DoubleConverter.cs | 13 + .../Conversions/Instances/EnumConverter.cs | 30 + .../Conversions/Instances/GuidConverter.cs | 15 + .../Instances/HashSet'1Converter.cs | 27 + .../Conversions/Instances/Int16Converter.cs | 13 + .../Conversions/Instances/Int32Converter.cs | 13 + .../Conversions/Instances/Int64Converter.cs | 13 + .../Instances/JsonArrayConverter.cs | 13 + .../Instances/JsonObjectConverter.cs | 13 + .../Conversions/Instances/SingleConverter.cs | 13 + .../Conversions/Instances/StringConverter.cs | 13 + .../Instances/TimeSpanConverter.cs | 15 + .../Conversions/Instances/UInt16Converter.cs | 13 + .../Conversions/Instances/UInt32Converter.cs | 13 + .../Conversions/Instances/UInt64Converter.cs | 13 + .../Conversions/Instances/UriConverter.cs | 15 + .../runtime/Conversions/JsonConverter.cs | 21 + .../Conversions/JsonConverterAttribute.cs | 18 + .../Conversions/JsonConverterFactory.cs | 91 + .../Conversions/StringLikeConverter.cs | 45 + .../Customizations/IJsonSerializable.cs | 249 + .../runtime/Customizations/JsonArray.cs | 13 + .../runtime/Customizations/JsonBoolean.cs | 16 + .../runtime/Customizations/JsonNode.cs | 21 + .../runtime/Customizations/JsonNumber.cs | 78 + .../runtime/Customizations/JsonObject.cs | 183 + .../runtime/Customizations/JsonString.cs | 34 + .../runtime/Customizations/XNodeArray.cs | 44 + .../generated/runtime/Debugging.cs | 28 + .../generated/runtime/DictionaryExtensions.cs | 36 + .../generated/runtime/EventData.cs | 78 + .../generated/runtime/EventDataExtensions.cs | 94 + .../generated/runtime/EventListener.cs | 247 + .../generated/runtime/Events.cs | 27 + .../generated/runtime/EventsExtensions.cs | 27 + .../generated/runtime/Extensions.cs | 111 + .../Extensions/StringBuilderExtensions.cs | 23 + .../Helpers/Extensions/TypeExtensions.cs | 61 + .../generated/runtime/Helpers/Seperator.cs | 11 + .../generated/runtime/Helpers/TypeDetails.cs | 116 + .../generated/runtime/Helpers/XHelper.cs | 75 + .../generated/runtime/HttpPipeline.cs | 88 + .../generated/runtime/HttpPipelineMocking.ps1 | 110 + .../generated/runtime/IAssociativeArray.cs | 21 + .../generated/runtime/IHeaderSerializable.cs | 14 + .../generated/runtime/ISendAsync.cs | 296 ++ .../generated/runtime/InfoAttribute.cs | 34 + .../generated/runtime/Iso/IsoDate.cs | 214 + .../generated/runtime/JsonType.cs | 18 + .../generated/runtime/Method.cs | 19 + .../generated/runtime/Models/JsonMember.cs | 83 + .../generated/runtime/Models/JsonModel.cs | 89 + .../runtime/Models/JsonModelCache.cs | 19 + .../runtime/Nodes/Collections/JsonArray.cs | 65 + .../Nodes/Collections/XImmutableArray.cs | 62 + .../runtime/Nodes/Collections/XList.cs | 64 + .../runtime/Nodes/Collections/XNodeArray.cs | 68 + .../runtime/Nodes/Collections/XSet.cs | 60 + .../generated/runtime/Nodes/JsonBoolean.cs | 42 + .../generated/runtime/Nodes/JsonDate.cs | 173 + .../generated/runtime/Nodes/JsonNode.cs | 250 + .../generated/runtime/Nodes/JsonNumber.cs | 109 + .../generated/runtime/Nodes/JsonObject.cs | 172 + .../generated/runtime/Nodes/JsonString.cs | 42 + .../generated/runtime/Nodes/XBinary.cs | 40 + .../generated/runtime/Nodes/XNull.cs | 15 + .../Parser/Exceptions/ParseException.cs | 24 + .../generated/runtime/Parser/JsonParser.cs | 180 + .../generated/runtime/Parser/JsonToken.cs | 66 + .../generated/runtime/Parser/JsonTokenizer.cs | 177 + .../generated/runtime/Parser/Location.cs | 43 + .../runtime/Parser/Readers/SourceReader.cs | 130 + .../generated/runtime/Parser/TokenReader.cs | 39 + .../generated/runtime/PipelineMocking.cs | 254 + .../generated/runtime/Response.cs | 27 + .../runtime/Serialization/JsonSerializer.cs | 350 ++ .../Serialization/PropertyTransformation.cs | 21 + .../Serialization/SerializationOptions.cs | 65 + .../generated/runtime/SerializationMode.cs | 16 + .../runtime/TypeConverterExtensions.cs | 190 + .../runtime/UndeclaredResponseException.cs | 104 + .../generated/runtime/Writers/JsonWriter.cs | 223 + .../generated/runtime/delegates.cs | 23 + src/CostManagement/help/Az.CostManagement.md | 46 + .../help/Get-AzCostManagementExport.md | 171 + ...-AzCostManagementExportExecutionHistory.md | 150 + .../Invoke-AzCostManagementExecuteExport.md | 188 + .../help/Invoke-AzCostManagementQuery.md | 325 ++ .../help/New-AzCostManagementExport.md | 361 ++ ...nagementQueryComparisonExpressionObject.md | 97 + .../New-AzCostManagementQueryFilterObject.md | 183 + .../help/Remove-AzCostManagementExport.md | 190 + .../help/Update-AzCostManagementExport.md | 426 ++ src/CostManagement/how-to.md | 58 + .../internal/Az.CostManagement.internal.psm1 | 38 + .../Get-AzCostManagementOperation.ps1 | 121 + .../internal/New-AzCostManagementExport.ps1 | 242 + .../internal/ProxyCmdletDefinitions.ps1 | 635 +++ .../Update-AzCostManagementExport.ps1 | 272 + src/CostManagement/internal/readme.md | 14 + src/CostManagement/pack-module.ps1 | 16 + src/CostManagement/readme.md | 197 + src/CostManagement/run-module.ps1 | 59 + src/CostManagement/test-module.ps1 | 68 + .../test/Az.Cost-TestResults.xml | 110 + .../Get-AzCostManagementExport.Recording.json | 170 + .../test/Get-AzCostManagementExport.Tests.ps1 | 30 + ...ementExportExecutionHistory.Recording.json | 128 + ...ManagementExportExecutionHistory.Tests.ps1 | 25 + ...CostManagementExecuteExport.Recording.json | 208 + ...ke-AzCostManagementExecuteExport.Tests.ps1 | 27 + .../Invoke-AzCostManagementQuery.Tests.ps1 | 25 + .../New-AzCostManagementExport.Recording.json | 113 + .../test/New-AzCostManagementExport.Tests.ps1 | 48 + ...zCostManagementQueryColumnObject.Tests.ps1 | 18 + ...tQueryComparisonExpressionObject.Tests.ps1 | 20 + ...zCostManagementQueryFilterObject.Tests.ps1 | 26 + ...move-AzCostManagementExport.Recording.json | 208 + .../Remove-AzCostManagementExport.Tests.ps1 | 27 + ...date-AzCostManagementExport.Recording.json | 118 + .../Update-AzCostManagementExport.Tests.ps1 | 25 + .../storage-account/parameters.json | 7 + .../storage-account/template.json | 96 + src/CostManagement/test/env.json | 13 + src/CostManagement/test/loadEnv.ps1 | 28 + src/CostManagement/test/readme.md | 17 + src/CostManagement/test/test-script.ps1 | 91 + src/CostManagement/test/utils.ps1 | 86 + tools/CreateMappings_rules.json | 6 +- tools/GeneratedModuleList.txt | 1 + 576 files changed, 76594 insertions(+), 1 deletion(-) create mode 100644 src/CostManagement/Az.CostManagement.csproj create mode 100644 src/CostManagement/Az.CostManagement.format.ps1xml create mode 100644 src/CostManagement/Az.CostManagement.psd1 create mode 100644 src/CostManagement/Az.CostManagement.psm1 create mode 100644 src/CostManagement/Changelog.md create mode 100644 src/CostManagement/CostManagement.sln create mode 100644 src/CostManagement/Properties/AssemblyInfo.cs create mode 100644 src/CostManagement/build-module.ps1 create mode 100644 src/CostManagement/check-dependencies.ps1 create mode 100644 src/CostManagement/custom/Az.CostManagement.custom.psm1 create mode 100644 src/CostManagement/custom/Invoke-AzCostManagementQuery.ps1 create mode 100644 src/CostManagement/custom/New-AzCostManagementExport.ps1 create mode 100644 src/CostManagement/custom/New-AzCostManagementQueryComparisonExpressionObject.ps1 create mode 100644 src/CostManagement/custom/New-AzCostManagementQueryFilterObject.ps1 create mode 100644 src/CostManagement/custom/Update-AzCostManagementExport.ps1 create mode 100644 src/CostManagement/custom/readme.md create mode 100644 src/CostManagement/examples/Get-AzCostManagementExport.md create mode 100644 src/CostManagement/examples/Get-AzCostManagementExportExecutionHistory.md create mode 100644 src/CostManagement/examples/Invoke-AzCostManagementExecuteExport.md create mode 100644 src/CostManagement/examples/Invoke-AzCostManagementQuery.md create mode 100644 src/CostManagement/examples/New-AzCostManagementExport.md create mode 100644 src/CostManagement/examples/New-AzCostManagementQueryComparisonExpressionObject.md create mode 100644 src/CostManagement/examples/New-AzCostManagementQueryFilterObject.md create mode 100644 src/CostManagement/examples/Remove-AzCostManagementExport.md create mode 100644 src/CostManagement/examples/Update-AzCostManagementExport.md create mode 100644 src/CostManagement/export-surface.ps1 create mode 100644 src/CostManagement/exports/Get-AzCostManagementExport.ps1 create mode 100644 src/CostManagement/exports/Get-AzCostManagementExportExecutionHistory.ps1 create mode 100644 src/CostManagement/exports/Invoke-AzCostManagementExecuteExport.ps1 create mode 100644 src/CostManagement/exports/Invoke-AzCostManagementQuery.ps1 create mode 100644 src/CostManagement/exports/New-AzCostManagementExport.ps1 create mode 100644 src/CostManagement/exports/New-AzCostManagementQueryComparisonExpressionObject.ps1 create mode 100644 src/CostManagement/exports/New-AzCostManagementQueryFilterObject.ps1 create mode 100644 src/CostManagement/exports/ProxyCmdletDefinitions.ps1 create mode 100644 src/CostManagement/exports/Remove-AzCostManagementExport.ps1 create mode 100644 src/CostManagement/exports/Update-AzCostManagementExport.ps1 create mode 100644 src/CostManagement/exports/readme.md create mode 100644 src/CostManagement/generate-help.ps1 create mode 100644 src/CostManagement/generate-info.json create mode 100644 src/CostManagement/generated/Module.cs create mode 100644 src/CostManagement/generated/api/CostManagement.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/Alert.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/Alert.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/Alert.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/Alert.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/AlertProperties.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/AlertProperties.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/AlertProperties.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/AlertProperties.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/AlertPropertiesDefinition.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/AlertPropertiesDefinition.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/AlertPropertiesDefinition.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/AlertPropertiesDefinition.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/AlertPropertiesDetails.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/AlertPropertiesDetails.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/AlertPropertiesDetails.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/AlertPropertiesDetails.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/AlertPropertiesDetailsTagFilter.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/AlertPropertiesDetailsTagFilter.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/AlertPropertiesDetailsTagFilter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/AlertPropertiesDetailsTagFilter.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/AlertsResult.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/AlertsResult.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/AlertsResult.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/AlertsResult.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/CommonExportProperties.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/CommonExportProperties.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/CommonExportProperties.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/CommonExportProperties.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/Dimension.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/Dimension.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/Dimension.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/Dimension.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/DimensionProperties.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/DimensionProperties.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/DimensionProperties.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/DimensionProperties.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/DimensionsListResult.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/DimensionsListResult.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/DimensionsListResult.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/DimensionsListResult.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/DismissAlertPayload.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/DismissAlertPayload.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/DismissAlertPayload.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/DismissAlertPayload.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ErrorDetails.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ErrorDetails.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ErrorDetails.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ErrorDetails.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ErrorResponse.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ErrorResponse.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ErrorResponse.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ErrorResponse.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/Export.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/Export.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/Export.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/Export.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportDataset.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportDataset.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportDataset.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportDataset.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportDatasetConfiguration.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportDatasetConfiguration.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportDatasetConfiguration.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportDatasetConfiguration.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportDefinition.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportDefinition.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportDefinition.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportDefinition.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportDeliveryDestination.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportDeliveryDestination.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportDeliveryDestination.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportDeliveryDestination.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportDeliveryInfo.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportDeliveryInfo.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportDeliveryInfo.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportDeliveryInfo.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportExecution.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportExecution.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportExecution.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportExecution.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportExecutionListResult.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportExecutionListResult.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportExecutionListResult.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportExecutionListResult.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportExecutionProperties.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportExecutionProperties.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportExecutionProperties.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportExecutionProperties.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportListResult.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportListResult.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportListResult.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportListResult.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportProperties.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportProperties.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportProperties.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportProperties.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportRecurrencePeriod.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportRecurrencePeriod.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportRecurrencePeriod.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportRecurrencePeriod.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportSchedule.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportSchedule.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportSchedule.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportSchedule.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportTimePeriod.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportTimePeriod.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportTimePeriod.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ExportTimePeriod.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ForecastDataset.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ForecastDataset.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ForecastDataset.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ForecastDataset.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ForecastDatasetAggregation.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ForecastDatasetAggregation.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ForecastDatasetAggregation.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ForecastDatasetAggregation.dictionary.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ForecastDatasetAggregation.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ForecastDefinition.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ForecastDefinition.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ForecastDefinition.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ForecastDefinition.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/KpiProperties.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/KpiProperties.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/KpiProperties.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/KpiProperties.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/Operation.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/Operation.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/Operation.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/Operation.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/OperationDisplay.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/OperationDisplay.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/OperationDisplay.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/OperationDisplay.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/OperationListResult.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/OperationListResult.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/OperationListResult.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/OperationListResult.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/PivotProperties.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/PivotProperties.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/PivotProperties.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/PivotProperties.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ProxyResource.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ProxyResource.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ProxyResource.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ProxyResource.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/QueryAggregation.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/QueryAggregation.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/QueryAggregation.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/QueryAggregation.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/QueryColumn.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/QueryColumn.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/QueryColumn.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/QueryColumn.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/QueryComparisonExpression.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/QueryComparisonExpression.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/QueryComparisonExpression.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/QueryComparisonExpression.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/QueryDataset.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/QueryDataset.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/QueryDataset.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/QueryDataset.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/QueryDatasetAggregation.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/QueryDatasetAggregation.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/QueryDatasetAggregation.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/QueryDatasetAggregation.dictionary.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/QueryDatasetAggregation.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/QueryDatasetConfiguration.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/QueryDatasetConfiguration.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/QueryDatasetConfiguration.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/QueryDatasetConfiguration.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/QueryDefinition.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/QueryDefinition.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/QueryDefinition.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/QueryDefinition.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/QueryFilter.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/QueryFilter.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/QueryFilter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/QueryFilter.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/QueryGrouping.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/QueryGrouping.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/QueryGrouping.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/QueryGrouping.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/QueryProperties.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/QueryProperties.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/QueryProperties.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/QueryProperties.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/QueryResult.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/QueryResult.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/QueryResult.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/QueryResult.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/QueryTimePeriod.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/QueryTimePeriod.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/QueryTimePeriod.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/QueryTimePeriod.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigAggregation.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigAggregation.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigAggregation.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigAggregation.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigComparisonExpression.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigComparisonExpression.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigComparisonExpression.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigComparisonExpression.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigDataset.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigDataset.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigDataset.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigDataset.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigDataset1.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigDataset1.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigDataset1.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigDataset1.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigDatasetAggregation.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigDatasetAggregation.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigDatasetAggregation.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigDatasetAggregation.dictionary.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigDatasetAggregation.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigDatasetConfiguration.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigDatasetConfiguration.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigDatasetConfiguration.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigDatasetConfiguration.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigDefinition.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigDefinition.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigDefinition.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigDefinition.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigDefinition1.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigDefinition1.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigDefinition1.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigDefinition1.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigFilter.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigFilter.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigFilter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigFilter.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigFilter1.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigFilter1.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigFilter1.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigFilter1.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigGrouping.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigGrouping.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigGrouping.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigGrouping.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigSorting.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigSorting.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigSorting.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigSorting.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigTimePeriod.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigTimePeriod.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigTimePeriod.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ReportConfigTimePeriod.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/Resource.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/Resource.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/Resource.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/Resource.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ResourceTags.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ResourceTags.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ResourceTags.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ResourceTags.dictionary.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ResourceTags.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/View.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/View.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/View.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/View.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ViewListResult.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ViewListResult.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ViewListResult.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ViewListResult.json.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ViewProperties.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ViewProperties.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ViewProperties.cs create mode 100644 src/CostManagement/generated/api/Models/Api20200601/ViewProperties.json.cs create mode 100644 src/CostManagement/generated/api/Models/CostManagementIdentity.PowerShell.cs create mode 100644 src/CostManagement/generated/api/Models/CostManagementIdentity.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Models/CostManagementIdentity.cs create mode 100644 src/CostManagement/generated/api/Models/CostManagementIdentity.json.cs create mode 100644 src/CostManagement/generated/api/Support/AccumulatedType.Completer.cs create mode 100644 src/CostManagement/generated/api/Support/AccumulatedType.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Support/AccumulatedType.cs create mode 100644 src/CostManagement/generated/api/Support/AlertCategory.Completer.cs create mode 100644 src/CostManagement/generated/api/Support/AlertCategory.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Support/AlertCategory.cs create mode 100644 src/CostManagement/generated/api/Support/AlertCriteria.Completer.cs create mode 100644 src/CostManagement/generated/api/Support/AlertCriteria.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Support/AlertCriteria.cs create mode 100644 src/CostManagement/generated/api/Support/AlertOperator.Completer.cs create mode 100644 src/CostManagement/generated/api/Support/AlertOperator.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Support/AlertOperator.cs create mode 100644 src/CostManagement/generated/api/Support/AlertSource.Completer.cs create mode 100644 src/CostManagement/generated/api/Support/AlertSource.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Support/AlertSource.cs create mode 100644 src/CostManagement/generated/api/Support/AlertStatus.Completer.cs create mode 100644 src/CostManagement/generated/api/Support/AlertStatus.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Support/AlertStatus.cs create mode 100644 src/CostManagement/generated/api/Support/AlertTimeGrainType.Completer.cs create mode 100644 src/CostManagement/generated/api/Support/AlertTimeGrainType.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Support/AlertTimeGrainType.cs create mode 100644 src/CostManagement/generated/api/Support/AlertType.Completer.cs create mode 100644 src/CostManagement/generated/api/Support/AlertType.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Support/AlertType.cs create mode 100644 src/CostManagement/generated/api/Support/ChartType.Completer.cs create mode 100644 src/CostManagement/generated/api/Support/ChartType.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Support/ChartType.cs create mode 100644 src/CostManagement/generated/api/Support/ExecutionStatus.Completer.cs create mode 100644 src/CostManagement/generated/api/Support/ExecutionStatus.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Support/ExecutionStatus.cs create mode 100644 src/CostManagement/generated/api/Support/ExecutionType.Completer.cs create mode 100644 src/CostManagement/generated/api/Support/ExecutionType.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Support/ExecutionType.cs create mode 100644 src/CostManagement/generated/api/Support/ExportType.Completer.cs create mode 100644 src/CostManagement/generated/api/Support/ExportType.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Support/ExportType.cs create mode 100644 src/CostManagement/generated/api/Support/ExternalCloudProviderType.Completer.cs create mode 100644 src/CostManagement/generated/api/Support/ExternalCloudProviderType.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Support/ExternalCloudProviderType.cs create mode 100644 src/CostManagement/generated/api/Support/ForecastTimeframeType.Completer.cs create mode 100644 src/CostManagement/generated/api/Support/ForecastTimeframeType.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Support/ForecastTimeframeType.cs create mode 100644 src/CostManagement/generated/api/Support/ForecastType.Completer.cs create mode 100644 src/CostManagement/generated/api/Support/ForecastType.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Support/ForecastType.cs create mode 100644 src/CostManagement/generated/api/Support/FormatType.Completer.cs create mode 100644 src/CostManagement/generated/api/Support/FormatType.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Support/FormatType.cs create mode 100644 src/CostManagement/generated/api/Support/GranularityType.Completer.cs create mode 100644 src/CostManagement/generated/api/Support/GranularityType.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Support/GranularityType.cs create mode 100644 src/CostManagement/generated/api/Support/KpiType.Completer.cs create mode 100644 src/CostManagement/generated/api/Support/KpiType.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Support/KpiType.cs create mode 100644 src/CostManagement/generated/api/Support/MetricType.Completer.cs create mode 100644 src/CostManagement/generated/api/Support/MetricType.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Support/MetricType.cs create mode 100644 src/CostManagement/generated/api/Support/OperatorType.Completer.cs create mode 100644 src/CostManagement/generated/api/Support/OperatorType.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Support/OperatorType.cs create mode 100644 src/CostManagement/generated/api/Support/PivotType.Completer.cs create mode 100644 src/CostManagement/generated/api/Support/PivotType.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Support/PivotType.cs create mode 100644 src/CostManagement/generated/api/Support/QueryColumnType.Completer.cs create mode 100644 src/CostManagement/generated/api/Support/QueryColumnType.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Support/QueryColumnType.cs create mode 100644 src/CostManagement/generated/api/Support/RecurrenceType.Completer.cs create mode 100644 src/CostManagement/generated/api/Support/RecurrenceType.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Support/RecurrenceType.cs create mode 100644 src/CostManagement/generated/api/Support/ReportConfigColumnType.Completer.cs create mode 100644 src/CostManagement/generated/api/Support/ReportConfigColumnType.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Support/ReportConfigColumnType.cs create mode 100644 src/CostManagement/generated/api/Support/ReportGranularityType.Completer.cs create mode 100644 src/CostManagement/generated/api/Support/ReportGranularityType.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Support/ReportGranularityType.cs create mode 100644 src/CostManagement/generated/api/Support/ReportTimeframeType.Completer.cs create mode 100644 src/CostManagement/generated/api/Support/ReportTimeframeType.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Support/ReportTimeframeType.cs create mode 100644 src/CostManagement/generated/api/Support/StatusType.Completer.cs create mode 100644 src/CostManagement/generated/api/Support/StatusType.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Support/StatusType.cs create mode 100644 src/CostManagement/generated/api/Support/TimeframeType.Completer.cs create mode 100644 src/CostManagement/generated/api/Support/TimeframeType.TypeConverter.cs create mode 100644 src/CostManagement/generated/api/Support/TimeframeType.cs create mode 100644 src/CostManagement/generated/cmdlets/GetAzCostManagementExportExecutionHistory_Get.cs create mode 100644 src/CostManagement/generated/cmdlets/GetAzCostManagementExportExecutionHistory_GetViaIdentity.cs create mode 100644 src/CostManagement/generated/cmdlets/GetAzCostManagementExport_Get.cs create mode 100644 src/CostManagement/generated/cmdlets/GetAzCostManagementExport_GetViaIdentity.cs create mode 100644 src/CostManagement/generated/cmdlets/GetAzCostManagementExport_List.cs create mode 100644 src/CostManagement/generated/cmdlets/GetAzCostManagementOperation_List.cs create mode 100644 src/CostManagement/generated/cmdlets/InvokeAzCostManagementExecuteExport_Execute.cs create mode 100644 src/CostManagement/generated/cmdlets/InvokeAzCostManagementExecuteExport_ExecuteViaIdentity.cs create mode 100644 src/CostManagement/generated/cmdlets/NewAzCostManagementExport_CreateExpanded.cs create mode 100644 src/CostManagement/generated/cmdlets/RemoveAzCostManagementExport_Delete.cs create mode 100644 src/CostManagement/generated/cmdlets/RemoveAzCostManagementExport_DeleteViaIdentity.cs create mode 100644 src/CostManagement/generated/cmdlets/UpdateAzCostManagementExport_UpdateExpanded.cs create mode 100644 src/CostManagement/generated/cmdlets/UpdateAzCostManagementExport_UpdateViaIdentityExpanded.cs create mode 100644 src/CostManagement/generated/runtime/AsyncCommandRuntime.cs create mode 100644 src/CostManagement/generated/runtime/AsyncJob.cs create mode 100644 src/CostManagement/generated/runtime/AsyncOperationResponse.cs create mode 100644 src/CostManagement/generated/runtime/BuildTime/Cmdlets/ExportCmdletSurface.cs create mode 100644 src/CostManagement/generated/runtime/BuildTime/Cmdlets/ExportExampleStub.cs create mode 100644 src/CostManagement/generated/runtime/BuildTime/Cmdlets/ExportFormatPs1xml.cs create mode 100644 src/CostManagement/generated/runtime/BuildTime/Cmdlets/ExportHelpMarkdown.cs create mode 100644 src/CostManagement/generated/runtime/BuildTime/Cmdlets/ExportModelSurface.cs create mode 100644 src/CostManagement/generated/runtime/BuildTime/Cmdlets/ExportProxyCmdlet.cs create mode 100644 src/CostManagement/generated/runtime/BuildTime/Cmdlets/ExportPsd1.cs create mode 100644 src/CostManagement/generated/runtime/BuildTime/Cmdlets/ExportTestStub.cs create mode 100644 src/CostManagement/generated/runtime/BuildTime/Cmdlets/GetCommonParameter.cs create mode 100644 src/CostManagement/generated/runtime/BuildTime/Cmdlets/GetModuleGuid.cs create mode 100644 src/CostManagement/generated/runtime/BuildTime/Cmdlets/GetScriptCmdlet.cs create mode 100644 src/CostManagement/generated/runtime/BuildTime/CollectionExtensions.cs create mode 100644 src/CostManagement/generated/runtime/BuildTime/MarkdownRenderer.cs create mode 100644 src/CostManagement/generated/runtime/BuildTime/Models/PsFormatTypes.cs create mode 100644 src/CostManagement/generated/runtime/BuildTime/Models/PsHelpMarkdownOutputs.cs create mode 100644 src/CostManagement/generated/runtime/BuildTime/Models/PsHelpTypes.cs create mode 100644 src/CostManagement/generated/runtime/BuildTime/Models/PsMarkdownTypes.cs create mode 100644 src/CostManagement/generated/runtime/BuildTime/Models/PsProxyOutputs.cs create mode 100644 src/CostManagement/generated/runtime/BuildTime/Models/PsProxyTypes.cs create mode 100644 src/CostManagement/generated/runtime/BuildTime/PsAttributes.cs create mode 100644 src/CostManagement/generated/runtime/BuildTime/PsExtensions.cs create mode 100644 src/CostManagement/generated/runtime/BuildTime/PsHelpers.cs create mode 100644 src/CostManagement/generated/runtime/BuildTime/StringExtensions.cs create mode 100644 src/CostManagement/generated/runtime/BuildTime/XmlExtensions.cs create mode 100644 src/CostManagement/generated/runtime/CmdInfoHandler.cs create mode 100644 src/CostManagement/generated/runtime/Conversions/ConversionException.cs create mode 100644 src/CostManagement/generated/runtime/Conversions/IJsonConverter.cs create mode 100644 src/CostManagement/generated/runtime/Conversions/Instances/BinaryConverter.cs create mode 100644 src/CostManagement/generated/runtime/Conversions/Instances/BooleanConverter.cs create mode 100644 src/CostManagement/generated/runtime/Conversions/Instances/DateTimeConverter.cs create mode 100644 src/CostManagement/generated/runtime/Conversions/Instances/DateTimeOffsetConverter.cs create mode 100644 src/CostManagement/generated/runtime/Conversions/Instances/DecimalConverter.cs create mode 100644 src/CostManagement/generated/runtime/Conversions/Instances/DoubleConverter.cs create mode 100644 src/CostManagement/generated/runtime/Conversions/Instances/EnumConverter.cs create mode 100644 src/CostManagement/generated/runtime/Conversions/Instances/GuidConverter.cs create mode 100644 src/CostManagement/generated/runtime/Conversions/Instances/HashSet'1Converter.cs create mode 100644 src/CostManagement/generated/runtime/Conversions/Instances/Int16Converter.cs create mode 100644 src/CostManagement/generated/runtime/Conversions/Instances/Int32Converter.cs create mode 100644 src/CostManagement/generated/runtime/Conversions/Instances/Int64Converter.cs create mode 100644 src/CostManagement/generated/runtime/Conversions/Instances/JsonArrayConverter.cs create mode 100644 src/CostManagement/generated/runtime/Conversions/Instances/JsonObjectConverter.cs create mode 100644 src/CostManagement/generated/runtime/Conversions/Instances/SingleConverter.cs create mode 100644 src/CostManagement/generated/runtime/Conversions/Instances/StringConverter.cs create mode 100644 src/CostManagement/generated/runtime/Conversions/Instances/TimeSpanConverter.cs create mode 100644 src/CostManagement/generated/runtime/Conversions/Instances/UInt16Converter.cs create mode 100644 src/CostManagement/generated/runtime/Conversions/Instances/UInt32Converter.cs create mode 100644 src/CostManagement/generated/runtime/Conversions/Instances/UInt64Converter.cs create mode 100644 src/CostManagement/generated/runtime/Conversions/Instances/UriConverter.cs create mode 100644 src/CostManagement/generated/runtime/Conversions/JsonConverter.cs create mode 100644 src/CostManagement/generated/runtime/Conversions/JsonConverterAttribute.cs create mode 100644 src/CostManagement/generated/runtime/Conversions/JsonConverterFactory.cs create mode 100644 src/CostManagement/generated/runtime/Conversions/StringLikeConverter.cs create mode 100644 src/CostManagement/generated/runtime/Customizations/IJsonSerializable.cs create mode 100644 src/CostManagement/generated/runtime/Customizations/JsonArray.cs create mode 100644 src/CostManagement/generated/runtime/Customizations/JsonBoolean.cs create mode 100644 src/CostManagement/generated/runtime/Customizations/JsonNode.cs create mode 100644 src/CostManagement/generated/runtime/Customizations/JsonNumber.cs create mode 100644 src/CostManagement/generated/runtime/Customizations/JsonObject.cs create mode 100644 src/CostManagement/generated/runtime/Customizations/JsonString.cs create mode 100644 src/CostManagement/generated/runtime/Customizations/XNodeArray.cs create mode 100644 src/CostManagement/generated/runtime/Debugging.cs create mode 100644 src/CostManagement/generated/runtime/DictionaryExtensions.cs create mode 100644 src/CostManagement/generated/runtime/EventData.cs create mode 100644 src/CostManagement/generated/runtime/EventDataExtensions.cs create mode 100644 src/CostManagement/generated/runtime/EventListener.cs create mode 100644 src/CostManagement/generated/runtime/Events.cs create mode 100644 src/CostManagement/generated/runtime/EventsExtensions.cs create mode 100644 src/CostManagement/generated/runtime/Extensions.cs create mode 100644 src/CostManagement/generated/runtime/Helpers/Extensions/StringBuilderExtensions.cs create mode 100644 src/CostManagement/generated/runtime/Helpers/Extensions/TypeExtensions.cs create mode 100644 src/CostManagement/generated/runtime/Helpers/Seperator.cs create mode 100644 src/CostManagement/generated/runtime/Helpers/TypeDetails.cs create mode 100644 src/CostManagement/generated/runtime/Helpers/XHelper.cs create mode 100644 src/CostManagement/generated/runtime/HttpPipeline.cs create mode 100644 src/CostManagement/generated/runtime/HttpPipelineMocking.ps1 create mode 100644 src/CostManagement/generated/runtime/IAssociativeArray.cs create mode 100644 src/CostManagement/generated/runtime/IHeaderSerializable.cs create mode 100644 src/CostManagement/generated/runtime/ISendAsync.cs create mode 100644 src/CostManagement/generated/runtime/InfoAttribute.cs create mode 100644 src/CostManagement/generated/runtime/Iso/IsoDate.cs create mode 100644 src/CostManagement/generated/runtime/JsonType.cs create mode 100644 src/CostManagement/generated/runtime/Method.cs create mode 100644 src/CostManagement/generated/runtime/Models/JsonMember.cs create mode 100644 src/CostManagement/generated/runtime/Models/JsonModel.cs create mode 100644 src/CostManagement/generated/runtime/Models/JsonModelCache.cs create mode 100644 src/CostManagement/generated/runtime/Nodes/Collections/JsonArray.cs create mode 100644 src/CostManagement/generated/runtime/Nodes/Collections/XImmutableArray.cs create mode 100644 src/CostManagement/generated/runtime/Nodes/Collections/XList.cs create mode 100644 src/CostManagement/generated/runtime/Nodes/Collections/XNodeArray.cs create mode 100644 src/CostManagement/generated/runtime/Nodes/Collections/XSet.cs create mode 100644 src/CostManagement/generated/runtime/Nodes/JsonBoolean.cs create mode 100644 src/CostManagement/generated/runtime/Nodes/JsonDate.cs create mode 100644 src/CostManagement/generated/runtime/Nodes/JsonNode.cs create mode 100644 src/CostManagement/generated/runtime/Nodes/JsonNumber.cs create mode 100644 src/CostManagement/generated/runtime/Nodes/JsonObject.cs create mode 100644 src/CostManagement/generated/runtime/Nodes/JsonString.cs create mode 100644 src/CostManagement/generated/runtime/Nodes/XBinary.cs create mode 100644 src/CostManagement/generated/runtime/Nodes/XNull.cs create mode 100644 src/CostManagement/generated/runtime/Parser/Exceptions/ParseException.cs create mode 100644 src/CostManagement/generated/runtime/Parser/JsonParser.cs create mode 100644 src/CostManagement/generated/runtime/Parser/JsonToken.cs create mode 100644 src/CostManagement/generated/runtime/Parser/JsonTokenizer.cs create mode 100644 src/CostManagement/generated/runtime/Parser/Location.cs create mode 100644 src/CostManagement/generated/runtime/Parser/Readers/SourceReader.cs create mode 100644 src/CostManagement/generated/runtime/Parser/TokenReader.cs create mode 100644 src/CostManagement/generated/runtime/PipelineMocking.cs create mode 100644 src/CostManagement/generated/runtime/Response.cs create mode 100644 src/CostManagement/generated/runtime/Serialization/JsonSerializer.cs create mode 100644 src/CostManagement/generated/runtime/Serialization/PropertyTransformation.cs create mode 100644 src/CostManagement/generated/runtime/Serialization/SerializationOptions.cs create mode 100644 src/CostManagement/generated/runtime/SerializationMode.cs create mode 100644 src/CostManagement/generated/runtime/TypeConverterExtensions.cs create mode 100644 src/CostManagement/generated/runtime/UndeclaredResponseException.cs create mode 100644 src/CostManagement/generated/runtime/Writers/JsonWriter.cs create mode 100644 src/CostManagement/generated/runtime/delegates.cs create mode 100644 src/CostManagement/help/Az.CostManagement.md create mode 100644 src/CostManagement/help/Get-AzCostManagementExport.md create mode 100644 src/CostManagement/help/Get-AzCostManagementExportExecutionHistory.md create mode 100644 src/CostManagement/help/Invoke-AzCostManagementExecuteExport.md create mode 100644 src/CostManagement/help/Invoke-AzCostManagementQuery.md create mode 100644 src/CostManagement/help/New-AzCostManagementExport.md create mode 100644 src/CostManagement/help/New-AzCostManagementQueryComparisonExpressionObject.md create mode 100644 src/CostManagement/help/New-AzCostManagementQueryFilterObject.md create mode 100644 src/CostManagement/help/Remove-AzCostManagementExport.md create mode 100644 src/CostManagement/help/Update-AzCostManagementExport.md create mode 100644 src/CostManagement/how-to.md create mode 100644 src/CostManagement/internal/Az.CostManagement.internal.psm1 create mode 100644 src/CostManagement/internal/Get-AzCostManagementOperation.ps1 create mode 100644 src/CostManagement/internal/New-AzCostManagementExport.ps1 create mode 100644 src/CostManagement/internal/ProxyCmdletDefinitions.ps1 create mode 100644 src/CostManagement/internal/Update-AzCostManagementExport.ps1 create mode 100644 src/CostManagement/internal/readme.md create mode 100644 src/CostManagement/pack-module.ps1 create mode 100644 src/CostManagement/readme.md create mode 100644 src/CostManagement/run-module.ps1 create mode 100644 src/CostManagement/test-module.ps1 create mode 100644 src/CostManagement/test/Az.Cost-TestResults.xml create mode 100644 src/CostManagement/test/Get-AzCostManagementExport.Recording.json create mode 100644 src/CostManagement/test/Get-AzCostManagementExport.Tests.ps1 create mode 100644 src/CostManagement/test/Get-AzCostManagementExportExecutionHistory.Recording.json create mode 100644 src/CostManagement/test/Get-AzCostManagementExportExecutionHistory.Tests.ps1 create mode 100644 src/CostManagement/test/Invoke-AzCostManagementExecuteExport.Recording.json create mode 100644 src/CostManagement/test/Invoke-AzCostManagementExecuteExport.Tests.ps1 create mode 100644 src/CostManagement/test/Invoke-AzCostManagementQuery.Tests.ps1 create mode 100644 src/CostManagement/test/New-AzCostManagementExport.Recording.json create mode 100644 src/CostManagement/test/New-AzCostManagementExport.Tests.ps1 create mode 100644 src/CostManagement/test/New-AzCostManagementQueryColumnObject.Tests.ps1 create mode 100644 src/CostManagement/test/New-AzCostManagementQueryComparisonExpressionObject.Tests.ps1 create mode 100644 src/CostManagement/test/New-AzCostManagementQueryFilterObject.Tests.ps1 create mode 100644 src/CostManagement/test/Remove-AzCostManagementExport.Recording.json create mode 100644 src/CostManagement/test/Remove-AzCostManagementExport.Tests.ps1 create mode 100644 src/CostManagement/test/Update-AzCostManagementExport.Recording.json create mode 100644 src/CostManagement/test/Update-AzCostManagementExport.Tests.ps1 create mode 100644 src/CostManagement/test/deployment-templates/storage-account/parameters.json create mode 100644 src/CostManagement/test/deployment-templates/storage-account/template.json create mode 100644 src/CostManagement/test/env.json create mode 100644 src/CostManagement/test/loadEnv.ps1 create mode 100644 src/CostManagement/test/readme.md create mode 100644 src/CostManagement/test/test-script.ps1 create mode 100644 src/CostManagement/test/utils.ps1 diff --git a/documentation/azure-powershell-modules.md b/documentation/azure-powershell-modules.md index 1a0e90e4a032..8a4f91ed170e 100644 --- a/documentation/azure-powershell-modules.md +++ b/documentation/azure-powershell-modules.md @@ -32,6 +32,7 @@ Connected Machine | `Az.ConnectedMachine` Container Instance | `Az.ContainerInstance` | [![ContainerInstance]][ContainerInstanceGallery] Container Registry | `Az.ContainerRegistry` | [![ContainerRegistry]][ContainerRegistryGallery] Cosmos DB | `Az.CosmosDB` | [![CosmosDB]][CosmosDBGallery] +Cost Management | `Az.CostManagement` | [![CostManagement]][CostManagementGallery] Custom Resource Providers | `Az.CustomProviders` | [![CustomProviders]][CustomProvidersGallery] Data Box | `Az.DataBox` | [![DataBox]][DataBoxGallery] Data Box Edge (Stack Edge) | `Az.DataBoxEdge` | [![DataBoxEdge]][DataBoxEdgeGallery] @@ -146,6 +147,7 @@ Windows Iot Services | `Az.WindowsIotServices` [ContainerInstance]: https://img.shields.io/powershellgallery/v/Az.ContainerInstance.svg?style=flat-square&label=Az.ContainerInstance [ContainerRegistry]: https://img.shields.io/powershellgallery/v/Az.ContainerRegistry.svg?style=flat-square&label=Az.ContainerRegistry [CosmosDB]: https://img.shields.io/powershellgallery/v/Az.CosmosDB.svg?style=flat-square&label=Az.CosmosDB +[CostManagement]: https://img.shields.io/powershellgallery/v/Az.CostManagement.svg?style=flat-square&label=Az.CostManagement [CustomProviders]: https://img.shields.io/powershellgallery/v/Az.CustomProviders.svg?style=flat-square&label=Az.CustomProviders [DataBox]: https://img.shields.io/powershellgallery/v/Az.DataBox.svg?style=flat-square&label=Az.DataBox [DataBoxEdge]: https://img.shields.io/powershellgallery/v/Az.DataBoxEdge.svg?style=flat-square&label=Az.DataBoxEdge @@ -258,6 +260,7 @@ Windows Iot Services | `Az.WindowsIotServices` [ContainerInstanceGallery]: https://www.powershellgallery.com/packages/Az.ContainerInstance/ [ContainerRegistryGallery]: https://www.powershellgallery.com/packages/Az.ContainerRegistry/ [CosmosDBGallery]: https://www.powershellgallery.com/packages/Az.CosmosDB/ +[CostManagementGallery]: https://www.powershellgallery.com/packages/Az.CostManagement/ [CustomProvidersGallery]: https://www.powershellgallery.com/packages/Az.CustomProviders/ [DataBoxGallery]: https://www.powershellgallery.com/packages/Az.DataBox/ [DataBoxEdgeGallery]: https://www.powershellgallery.com/packages/Az.DataBoxEdge/ diff --git a/src/CostManagement/Az.CostManagement.csproj b/src/CostManagement/Az.CostManagement.csproj new file mode 100644 index 000000000000..59a96f4ec517 --- /dev/null +++ b/src/CostManagement/Az.CostManagement.csproj @@ -0,0 +1,7 @@ + + + CostManagement + + + + diff --git a/src/CostManagement/Az.CostManagement.format.ps1xml b/src/CostManagement/Az.CostManagement.format.ps1xml new file mode 100644 index 000000000000..afb1615de2cc --- /dev/null +++ b/src/CostManagement/Az.CostManagement.format.ps1xml @@ -0,0 +1,1817 @@ + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.CostManagementIdentity + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.CostManagementIdentity + + + + + + + + + + + + + + + + + + + + + + + + + + + AlertId + + + ExportName + + + ExternalCloudProviderId + + + ExternalCloudProviderType + + + Scope + + + ViewName + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.Alert + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.Alert + + + + + + + + + + + + + + + Name + + + Type + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.AlertProperties + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.AlertProperties + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CloseTime + + + CostEntityId + + + CreationTime + + + Description + + + ModificationTime + + + Source + + + Status + + + StatusModificationTime + + + StatusModificationUserName + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.AlertPropertiesDefinition + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.AlertPropertiesDefinition + + + + + + + + + + + + + + + + + + Category + + + Criterion + + + Type + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.AlertPropertiesDetails + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.AlertPropertiesDetails + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Amount + + + ContactEmail + + + ContactGroup + + + ContactRole + + + CurrentSpend + + + MeterFilter + + + Operator + + + OverridingAlert + + + PeriodStartDate + + + ResourceFilter + + + ResourceGroupFilter + + + Threshold + + + TimeGrainType + + + TriggeredBy + + + Unit + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.AlertsResult + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.AlertsResult + + + + + + + + + + + + NextLink + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.CommonExportProperties + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.CommonExportProperties + + + + + + + + + + + + + + + Format + + + NextRunTimeEstimate + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.Dimension + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.Dimension + + + + + + + + + + + + + + + Name + + + Type + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.DimensionProperties + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.DimensionProperties + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Category + + + Data + + + Description + + + FilterEnabled + + + GroupingEnabled + + + NextLink + + + Total + + + UsageEnd + + + UsageStart + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ErrorDetails + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ErrorDetails + + + + + + + + + + + + + + + Code + + + Message + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.Export + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.Export + + + + + + + + + + + + + + + + + + ETag + + + Name + + + Type + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDataset + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDataset + + + + + + + + + + + + Granularity + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDatasetConfiguration + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDatasetConfiguration + + + + + + + + + + + + Column + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDefinition + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDefinition + + + + + + + + + + + + + + + Timeframe + + + Type + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDeliveryDestination + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDeliveryDestination + + + + + + + + + + + + + + + + + + Container + + + ResourceId + + + RootFolderPath + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportExecution + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportExecution + + + + + + + + + + + + + + + + + + + + + + + + ExecutionType + + + ProcessingStartTime + + + ProcessingEndTime + + + Status + + + FileName + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportExecutionProperties + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportExecutionProperties + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ExecutionType + + + FileName + + + ProcessingEndTime + + + ProcessingStartTime + + + Status + + + SubmittedBy + + + SubmittedTime + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportProperties + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportProperties + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ConfigurationColumn + + + DataSetGranularity + + + DefinitionTimeframe + + + DefinitionType + + + DestinationContainer + + + DestinationResourceId + + + DestinationRootFolderPath + + + Format + + + NextRunTimeEstimate + + + TimePeriodFrom + + + TimePeriodTo + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportRecurrencePeriod + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportRecurrencePeriod + + + + + + + + + + + + + + + From + + + To + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportSchedule + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportSchedule + + + + + + + + + + + + + + + Recurrence + + + Status + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportTimePeriod + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportTimePeriod + + + + + + + + + + + + + + + From + + + To + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ForecastDataset + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ForecastDataset + + + + + + + + + + + + Granularity + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ForecastDefinition + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ForecastDefinition + + + + + + + + + + + + + + + + + + + + + IncludeActualCost + + + IncludeFreshPartialCost + + + Timeframe + + + Type + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.KpiProperties + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.KpiProperties + + + + + + + + + + + + + + + Enabled + + + Type + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.Operation + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.Operation + + + + + + + + + + + + Name + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.OperationDisplay + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.OperationDisplay + + + + + + + + + + + + + + + + + + Operation + + + Provider + + + Resource + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.OperationListResult + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.OperationListResult + + + + + + + + + + + + NextLink + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.PivotProperties + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.PivotProperties + + + + + + + + + + + + + + + Name + + + Type + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ProxyResource + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ProxyResource + + + + + + + + + + + + + + + + + + ETag + + + Name + + + Type + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryAggregation + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryAggregation + + + + + + + + + + + + + + + Function + + + Name + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryColumn + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryColumn + + + + + + + + + + + + + + + Name + + + Type + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryComparisonExpression + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryComparisonExpression + + + + + + + + + + + + + + + + + + Name + + + Operator + + + Value + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryDataset + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryDataset + + + + + + + + + + + + Granularity + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryDatasetConfiguration + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryDatasetConfiguration + + + + + + + + + + + + Column + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryDefinition + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryDefinition + + + + + + + + + + + + + + + Timeframe + + + Type + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryGrouping + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryGrouping + + + + + + + + + + + + + + + Name + + + Type + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryProperties + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryProperties + + + + + + + + + + + + + + + NextLink + + + Row + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryResult + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryResult + + + + + + + + + + + + + + + Column + + + Row + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryTimePeriod + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryTimePeriod + + + + + + + + + + + + + + + From + + + To + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigAggregation + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigAggregation + + + + + + + + + + + + + + + Function + + + Name + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigComparisonExpression + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigComparisonExpression + + + + + + + + + + + + + + + + + + Name + + + Operator + + + Value + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDataset + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDataset + + + + + + + + + + + + Granularity + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDataset1 + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDataset1 + + + + + + + + + + + + Granularity + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDatasetConfiguration + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDatasetConfiguration + + + + + + + + + + + + Column + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDefinition + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDefinition + + + + + + + + + + + + + + + Timeframe + + + Type + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDefinition1 + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDefinition1 + + + + + + + + + + + + + + + Timeframe + + + Type + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigGrouping + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigGrouping + + + + + + + + + + + + + + + Name + + + Type + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigSorting + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigSorting + + + + + + + + + + + + + + + Direction + + + Name + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigTimePeriod + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigTimePeriod + + + + + + + + + + + + + + + From + + + To + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.Resource + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.Resource + + + + + + + + + + + + + + + Name + + + Type + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ResourceTags + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ResourceTags + + + + + + + + + + + + Item + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.View + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.View + + + + + + + + + + + + + + + + + + ETag + + + Name + + + Type + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ViewListResult + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ViewListResult + + + + + + + + + + + + NextLink + + + + + + + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ViewProperties + + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ViewProperties + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Accumulated + + + Chart + + + CreatedOn + + + DisplayName + + + Metric + + + ModifiedOn + + + Scope + + + + + + + + \ No newline at end of file diff --git a/src/CostManagement/Az.CostManagement.psd1 b/src/CostManagement/Az.CostManagement.psd1 new file mode 100644 index 000000000000..129670e8a64f --- /dev/null +++ b/src/CostManagement/Az.CostManagement.psd1 @@ -0,0 +1,138 @@ +# +# Module manifest for module 'Az.CostManagement' +# +# Generated by: Microsoft Corporation +# +# Generated on: 2020-12-02 +# + +@{ + +# Script module or binary module file associated with this manifest. +RootModule = './Az.CostManagement.psm1' + +# Version number of this module. +ModuleVersion = '0.1.0' + +# Supported PSEditions +CompatiblePSEditions = 'Core', 'Desktop' + +# ID used to uniquely identify this module +GUID = '4cd9af10-559e-4fb9-8dcd-d3e8eb9e03b7' + +# Author of this module +Author = 'Microsoft Corporation' + +# Company or vendor of this module +CompanyName = 'Microsoft Corporation' + +# Copyright statement for this module +Copyright = 'Microsoft Corporation. All rights reserved.' + +# Description of the functionality provided by this module +Description = 'Microsoft Azure PowerShell: Cost cmdlets' + +# Minimum version of the PowerShell engine required by this module +PowerShellVersion = '5.1' + +# Name of the PowerShell host required by this module +# PowerShellHostName = '' + +# Minimum version of the PowerShell host required by this module +# PowerShellHostVersion = '' + +# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only. +DotNetFrameworkVersion = '4.7.2' + +# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only. +# ClrVersion = '' + +# Processor architecture (None, X86, Amd64) required by this module +# ProcessorArchitecture = '' + +# Modules that must be imported into the global environment prior to importing this module +RequiredModules = @(@{ModuleName = 'Az.Accounts'; ModuleVersion = '2.2.1'; }) + +# Assemblies that must be loaded prior to importing this module +RequiredAssemblies = './bin/Az.CostManagement.private.dll' + +# Script files (.ps1) that are run in the caller's environment prior to importing this module. +# ScriptsToProcess = @() + +# Type files (.ps1xml) to be loaded when importing this module +# TypesToProcess = @() + +# Format files (.ps1xml) to be loaded when importing this module +FormatsToProcess = './Az.CostManagement.format.ps1xml' + +# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess +# NestedModules = @() + +# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. +FunctionsToExport = 'Get-AzCostManagementExport', + 'Get-AzCostManagementExportExecutionHistory', + 'Invoke-AzCostManagementExecuteExport', + 'Invoke-AzCostManagementQuery', 'New-AzCostManagementExport', + 'New-AzCostManagementQueryComparisonExpressionObject', + 'New-AzCostManagementQueryFilterObject', + 'Remove-AzCostManagementExport', 'Update-AzCostManagementExport' + +# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. +CmdletsToExport = @() + +# Variables to export from this module +# VariablesToExport = @() + +# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. +AliasesToExport = '*' + +# DSC resources to export from this module +# DscResourcesToExport = @() + +# List of all modules packaged with this module +# ModuleList = @() + +# List of all files packaged with this module +# FileList = @() + +# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. +PrivateData = @{ + + PSData = @{ + + # Tags applied to this module. These help with module discovery in online galleries. + Tags = 'Azure','ResourceManager','ARM','PSModule','Cost' + + # A URL to the license for this module. + LicenseUri = 'https://aka.ms/azps-license' + + # A URL to the main website for this project. + ProjectUri = 'https://github.com/Azure/azure-powershell' + + # A URL to an icon representing this module. + # IconUri = '' + + # ReleaseNotes of this module + # ReleaseNotes = '' + + # Prerelease string of this module + # Prerelease = '' + + # Flag to indicate whether the module requires explicit user acceptance for install/update/save + # RequireLicenseAcceptance = $false + + # External dependent modules of this module + # ExternalModuleDependencies = @() + + } # End of PSData hashtable + + } # End of PrivateData hashtable + +# HelpInfo URI of this module +# HelpInfoURI = '' + +# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. +# DefaultCommandPrefix = '' + +} + diff --git a/src/CostManagement/Az.CostManagement.psm1 b/src/CostManagement/Az.CostManagement.psm1 new file mode 100644 index 000000000000..7465a93bfd8f --- /dev/null +++ b/src/CostManagement/Az.CostManagement.psm1 @@ -0,0 +1,109 @@ +# region Generated + # ---------------------------------------------------------------------------------- + # + # Copyright Microsoft Corporation + # Licensed under the Apache License, Version 2.0 (the "License"); + # you may not use this file except in compliance with the License. + # You may obtain a copy of the License at + # http://www.apache.org/licenses/LICENSE-2.0 + # Unless required by applicable law or agreed to in writing, software + # distributed under the License is distributed on an "AS IS" BASIS, + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + # See the License for the specific language governing permissions and + # limitations under the License. + # ---------------------------------------------------------------------------------- + # Load required Az.Accounts module + $accountsName = 'Az.Accounts' + $accountsModule = Get-Module -Name $accountsName + if(-not $accountsModule) { + $localAccountsPath = Join-Path $PSScriptRoot 'generated\modules' + if(Test-Path -Path $localAccountsPath) { + $localAccounts = Get-ChildItem -Path $localAccountsPath -Recurse -Include 'Az.Accounts.psd1' | Select-Object -Last 1 + if($localAccounts) { + $accountsModule = Import-Module -Name ($localAccounts.FullName) -Scope Global -PassThru + } + } + if(-not $accountsModule) { + $hasAdequateVersion = (Get-Module -Name $accountsName -ListAvailable | Where-Object { $_.Version -ge [System.Version]'1.8.1' } | Measure-Object).Count -gt 0 + if($hasAdequateVersion) { + $accountsModule = Import-Module -Name $accountsName -MinimumVersion 1.8.1 -Scope Global -PassThru + } + } + } + + if(-not $accountsModule) { + Write-Error "`nThis module requires $accountsName version 1.8.1 or greater. For installation instructions, please see: https://docs.microsoft.com/en-us/powershell/azure/install-az-ps" -ErrorAction Stop + } elseif (($accountsModule.Version -lt [System.Version]'1.8.1') -and (-not $localAccounts)) { + Write-Error "`nThis module requires $accountsName version 1.8.1 or greater. An earlier version of Az.Accounts is imported in the current PowerShell session. If you are running test, please try to remove '.PSSharedModules' in your home directory. Otherwise please open a new PowerShell session and import this module again.`nAdditionally, this error could indicate that multiple incompatible versions of Azure PowerShell modules are installed on your system. For troubleshooting information, please see: https://aka.ms/azps-version-error" -ErrorAction Stop + } + Write-Information "Loaded Module '$($accountsModule.Name)'" + + # Load the private module dll + $null = Import-Module -Name (Join-Path $PSScriptRoot './bin/Az.CostManagement.private.dll') + + # Get the private module's instance + $instance = [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Module]::Instance + + # Ask for the shared functionality table + $VTable = Register-AzModule + + # Tweaks the pipeline on module load + $instance.OnModuleLoad = $VTable.OnModuleLoad + + # Tweaks the pipeline per call + $instance.OnNewRequest = $VTable.OnNewRequest + + # Gets shared parameter values + $instance.GetParameterValue = $VTable.GetParameterValue + + # Allows shared module to listen to events from this module + $instance.EventListener = $VTable.EventListener + + # Gets shared argument completers + $instance.ArgumentCompleter = $VTable.ArgumentCompleter + + # The name of the currently selected Azure profile + $instance.ProfileName = $VTable.ProfileName + + + # Load the custom module + $customModulePath = Join-Path $PSScriptRoot './custom/Az.CostManagement.custom.psm1' + if(Test-Path $customModulePath) { + $null = Import-Module -Name $customModulePath + } + + # Export nothing to clear implicit exports + Export-ModuleMember + + # Export proxy cmdlet scripts + $exportsPath = Join-Path $PSScriptRoot './exports' + $directories = Get-ChildItem -Directory -Path $exportsPath + $profileDirectory = $null + if($instance.ProfileName) { + if(($directories | ForEach-Object { $_.Name }) -contains $instance.ProfileName) { + $profileDirectory = $directories | Where-Object { $_.Name -eq $instance.ProfileName } + } else { + # Don't export anything if the profile doesn't exist for the module + $exportsPath = $null + Write-Warning "Selected Azure profile '$($instance.ProfileName)' does not exist for module '$($instance.Name)'. No cmdlets were loaded." + } + } elseif(($directories | Measure-Object).Count -gt 0) { + # Load the last folder if no profile is selected + $profileDirectory = $directories | Select-Object -Last 1 + } + + if($profileDirectory) { + Write-Information "Loaded Azure profile '$($profileDirectory.Name)' for module '$($instance.Name)'" + $exportsPath = $profileDirectory.FullName + } + + if($exportsPath) { + Get-ChildItem -Path $exportsPath -Recurse -Include '*.ps1' -File | ForEach-Object { . $_.FullName } + $cmdletNames = Get-ScriptCmdlet -ScriptFolder $exportsPath + Export-ModuleMember -Function $cmdletNames -Alias (Get-ScriptCmdlet -ScriptFolder $exportsPath -AsAlias) + } + + # Finalize initialization of this module + $instance.Init(); + Write-Information "Loaded Module '$($instance.Name)'" +# endregion diff --git a/src/CostManagement/Changelog.md b/src/CostManagement/Changelog.md new file mode 100644 index 000000000000..a8a29db2e3de --- /dev/null +++ b/src/CostManagement/Changelog.md @@ -0,0 +1,24 @@ + +## Upcoming Release + +## Version 0.1.0 +* First preview release for module Az.CostManagement + diff --git a/src/CostManagement/CostManagement.sln b/src/CostManagement/CostManagement.sln new file mode 100644 index 000000000000..e489f2fdd651 --- /dev/null +++ b/src/CostManagement/CostManagement.sln @@ -0,0 +1,48 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29709.97 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Accounts", "..\Accounts\Accounts\Accounts.csproj", "{142D7B0B-388A-4CEB-A228-7F6D423C5C2E}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Authentication", "..\Accounts\Authentication\Authentication.csproj", "{62843FE6-7575-4D88-B989-7DF7EEC0BC01}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Authentication.ResourceManager", "..\Accounts\Authentication.ResourceManager\Authentication.ResourceManager.csproj", "{442C609B-A431-4A71-B289-08F0B63C83E5}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Authenticators", "..\Accounts\Authenticators\Authenticators.csproj", "{59E8F6B8-8F0E-403F-B88B-9736DBC396D9}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Az.CostManagement", "Az.CostManagement.csproj", "{1C203C0C-E0FD-40D2-B79E-C6DA52E4E350}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {142D7B0B-388A-4CEB-A228-7F6D423C5C2E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {142D7B0B-388A-4CEB-A228-7F6D423C5C2E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {142D7B0B-388A-4CEB-A228-7F6D423C5C2E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {142D7B0B-388A-4CEB-A228-7F6D423C5C2E}.Release|Any CPU.Build.0 = Release|Any CPU + {62843FE6-7575-4D88-B989-7DF7EEC0BC01}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {62843FE6-7575-4D88-B989-7DF7EEC0BC01}.Debug|Any CPU.Build.0 = Debug|Any CPU + {62843FE6-7575-4D88-B989-7DF7EEC0BC01}.Release|Any CPU.ActiveCfg = Release|Any CPU + {62843FE6-7575-4D88-B989-7DF7EEC0BC01}.Release|Any CPU.Build.0 = Release|Any CPU + {442C609B-A431-4A71-B289-08F0B63C83E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {442C609B-A431-4A71-B289-08F0B63C83E5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {442C609B-A431-4A71-B289-08F0B63C83E5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {442C609B-A431-4A71-B289-08F0B63C83E5}.Release|Any CPU.Build.0 = Release|Any CPU + {59E8F6B8-8F0E-403F-B88B-9736DBC396D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {59E8F6B8-8F0E-403F-B88B-9736DBC396D9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {59E8F6B8-8F0E-403F-B88B-9736DBC396D9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {59E8F6B8-8F0E-403F-B88B-9736DBC396D9}.Release|Any CPU.Build.0 = Release|Any CPU + {1C203C0C-E0FD-40D2-B79E-C6DA52E4E350}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1C203C0C-E0FD-40D2-B79E-C6DA52E4E350}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1C203C0C-E0FD-40D2-B79E-C6DA52E4E350}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1C203C0C-E0FD-40D2-B79E-C6DA52E4E350}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {F9B3D96E-9680-40BE-A917-02EE655D6030} + EndGlobalSection +EndGlobal diff --git a/src/CostManagement/Properties/AssemblyInfo.cs b/src/CostManagement/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..799c67664473 --- /dev/null +++ b/src/CostManagement/Properties/AssemblyInfo.cs @@ -0,0 +1,28 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using System; +using System.Reflection; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("Microsoft Azure Powershell - CostManagement")] +[assembly: AssemblyCompany(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyCompany)] +[assembly: AssemblyProduct(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyProduct)] +[assembly: AssemblyCopyright(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyCopyright)] + +[assembly: ComVisible(false)] +[assembly: CLSCompliant(false)] +[assembly: Guid("7be1c102-af7d-4855-8609-ce6f2b3fddc6")] +[assembly: AssemblyVersion("0.1.0")] +[assembly: AssemblyFileVersion("0.1.0")] diff --git a/src/CostManagement/build-module.ps1 b/src/CostManagement/build-module.ps1 new file mode 100644 index 000000000000..0efab39d18f9 --- /dev/null +++ b/src/CostManagement/build-module.ps1 @@ -0,0 +1,153 @@ +# ---------------------------------------------------------------------------------- +# +# Copyright Microsoft Corporation +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ---------------------------------------------------------------------------------- +param([switch]$Isolated, [switch]$Run, [switch]$Test, [switch]$Docs, [switch]$Pack, [switch]$Code, [switch]$Release, [switch]$Debugger, [switch]$NoDocs) +$ErrorActionPreference = 'Stop' + +if($PSEdition -ne 'Core') { + Write-Error 'This script requires PowerShell Core to execute. [Note] Generated cmdlets will work in both PowerShell Core or Windows PowerShell.' +} + +if(-not $Isolated -and -not $Debugger) { + Write-Host -ForegroundColor Green 'Creating isolated process...' + $pwsh = [System.Diagnostics.Process]::GetCurrentProcess().Path + & "$pwsh" -NonInteractive -NoLogo -NoProfile -File $MyInvocation.MyCommand.Path @PSBoundParameters -Isolated + + if($LastExitCode -ne 0) { + # Build failed. Don't attempt to run the module. + return + } + + if($Test) { + . (Join-Path $PSScriptRoot 'test-module.ps1') + if($LastExitCode -ne 0) { + # Tests failed. Don't attempt to run the module. + return + } + } + + if($Docs) { + . (Join-Path $PSScriptRoot 'generate-help.ps1') + if($LastExitCode -ne 0) { + # Docs generation failed. Don't attempt to run the module. + return + } + } + + if($Pack) { + . (Join-Path $PSScriptRoot 'pack-module.ps1') + if($LastExitCode -ne 0) { + # Packing failed. Don't attempt to run the module. + return + } + } + + $runModulePath = Join-Path $PSScriptRoot 'run-module.ps1' + if($Code) { + . $runModulePath -Code + } elseif($Run) { + . $runModulePath + } else { + Write-Host -ForegroundColor Cyan "To run this module in an isolated PowerShell session, run the 'run-module.ps1' script or provide the '-Run' parameter to this script." + } + return +} + +$binFolder = Join-Path $PSScriptRoot 'bin' +$objFolder = Join-Path $PSScriptRoot 'obj' + +if(-not $Debugger) { + Write-Host -ForegroundColor Green 'Cleaning build folders...' + $null = Remove-Item -Recurse -ErrorAction SilentlyContinue -Path $binFolder, $objFolder + + if((Test-Path $binFolder) -or (Test-Path $objFolder)) { + Write-Host -ForegroundColor Cyan 'Did you forget to exit your isolated module session before rebuilding?' + Write-Error 'Unable to clean ''bin'' or ''obj'' folder. A process may have an open handle.' + } + + Write-Host -ForegroundColor Green 'Compiling module...' + $buildConfig = 'Debug' + if($Release) { + $buildConfig = 'Release' + } + dotnet publish $PSScriptRoot --verbosity quiet --configuration $buildConfig /nologo + if($LastExitCode -ne 0) { + Write-Error 'Compilation failed.' + } + + $null = Remove-Item -Recurse -ErrorAction SilentlyContinue -Path (Join-Path $binFolder 'Debug'), (Join-Path $binFolder 'Release') +} + +$dll = Join-Path $PSScriptRoot 'bin\Az.CostManagement.private.dll' +if(-not (Test-Path $dll)) { + Write-Error "Unable to find output assembly in '$binFolder'." +} + +# Load DLL to use build-time cmdlets +$null = Import-Module -Name $dll + +$modulePaths = $dll +$customPsm1 = Join-Path $PSScriptRoot 'custom\Az.CostManagement.custom.psm1' +if(Test-Path $customPsm1) { + $modulePaths = @($dll, $customPsm1) +} + +$exportsFolder = Join-Path $PSScriptRoot 'exports' +if(Test-Path $exportsFolder) { + $null = Get-ChildItem -Path $exportsFolder -Recurse -Exclude 'readme.md' | Remove-Item -Recurse -ErrorAction SilentlyContinue +} +$null = New-Item -ItemType Directory -Force -Path $exportsFolder + +$internalFolder = Join-Path $PSScriptRoot 'internal' +if(Test-Path $internalFolder) { + $null = Get-ChildItem -Path $internalFolder -Recurse -Exclude '*.psm1', 'readme.md' | Remove-Item -Recurse -ErrorAction SilentlyContinue +} +$null = New-Item -ItemType Directory -Force -Path $internalFolder + +$psd1 = Join-Path $PSScriptRoot './Az.CostManagement.psd1' +$guid = Get-ModuleGuid -Psd1Path $psd1 +$moduleName = 'Az.CostManagement' +$examplesFolder = Join-Path $PSScriptRoot 'examples' +$null = New-Item -ItemType Directory -Force -Path $examplesFolder + +if($NoDocs) { + Write-Host -ForegroundColor Green 'Creating exports...' + Export-ProxyCmdlet -ModuleName $moduleName -ModulePath $modulePaths -ExportsFolder $exportsFolder -InternalFolder $internalFolder -ExcludeDocs +} else { + Write-Host -ForegroundColor Green 'Creating exports and docs...' + $moduleDescription = 'Microsoft Azure PowerShell: Cost cmdlets' + $docsFolder = Join-Path $PSScriptRoot 'docs' + if(Test-Path $docsFolder) { + $null = Get-ChildItem -Path $docsFolder -Recurse -Exclude 'readme.md' | Remove-Item -Recurse -ErrorAction SilentlyContinue + } + $null = New-Item -ItemType Directory -Force -Path $docsFolder + Export-ProxyCmdlet -ModuleName $moduleName -ModulePath $modulePaths -ExportsFolder $exportsFolder -InternalFolder $internalFolder -ModuleDescription $moduleDescription -DocsFolder $docsFolder -ExamplesFolder $examplesFolder -ModuleGuid $guid +} + +Write-Host -ForegroundColor Green 'Creating format.ps1xml...' +$formatPs1xml = Join-Path $PSScriptRoot './Az.CostManagement.format.ps1xml' +Export-FormatPs1xml -FilePath $formatPs1xml + +Write-Host -ForegroundColor Green 'Creating psd1...' +$customFolder = Join-Path $PSScriptRoot 'custom' +Export-Psd1 -ExportsFolder $exportsFolder -CustomFolder $customFolder -Psd1Path $psd1 -ModuleGuid $guid + +Write-Host -ForegroundColor Green 'Creating test stubs...' +$testFolder = Join-Path $PSScriptRoot 'test' +$null = New-Item -ItemType Directory -Force -Path $testFolder +Export-TestStub -ModuleName $moduleName -ExportsFolder $exportsFolder -OutputFolder $testFolder + +Write-Host -ForegroundColor Green 'Creating example stubs...' +Export-ExampleStub -ExportsFolder $exportsFolder -OutputFolder $examplesFolder + +Write-Host -ForegroundColor Green '-------------Done-------------' diff --git a/src/CostManagement/check-dependencies.ps1 b/src/CostManagement/check-dependencies.ps1 new file mode 100644 index 000000000000..513c52ca2fb5 --- /dev/null +++ b/src/CostManagement/check-dependencies.ps1 @@ -0,0 +1,64 @@ +# ---------------------------------------------------------------------------------- +# +# Copyright Microsoft Corporation +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ---------------------------------------------------------------------------------- +param([switch]$Isolated, [switch]$Accounts, [switch]$Pester, [switch]$Resources) +$ErrorActionPreference = 'Stop' + +if(-not $Isolated) { + Write-Host -ForegroundColor Green 'Creating isolated process...' + $pwsh = [System.Diagnostics.Process]::GetCurrentProcess().Path + & "$pwsh" -NoExit -NoLogo -NoProfile -File $MyInvocation.MyCommand.Path @PSBoundParameters -Isolated + return +} + +function DownloadModule ([bool]$predicate, [string]$path, [string]$moduleName, [string]$versionMinimum, [string]$requiredVersion) { + if($predicate) { + $module = Get-Module -ListAvailable -Name $moduleName + if((-not $module) -or ($versionMinimum -and ($module | ForEach-Object { $_.Version } | Where-Object { $_ -ge [System.Version]$versionMinimum } | Measure-Object).Count -eq 0)) { + $null = New-Item -ItemType Directory -Force -Path $path + Write-Host -ForegroundColor Green "Installing local $moduleName module into '$path'..." + if ($requiredVersion) { + Find-Module -Name $moduleName -RequiredVersion $requiredVersion -Repository PSGallery | Save-Module -Path $path + }elseif($versionMinimum) { + Find-Module -Name $moduleName -MinimumVersion $versionMinimum -Repository PSGallery | Save-Module -Path $path + } else { + Find-Module -Name $moduleName -Repository PSGallery | Save-Module -Path $path + } + } + } +} + +$ProgressPreference = 'SilentlyContinue' +$all = (@($Accounts.IsPresent, $Pester.IsPresent) | Select-Object -Unique | Measure-Object).Count -eq 1 + +$localModulesPath = Join-Path $PSScriptRoot 'generated\modules' +if(Test-Path -Path $localModulesPath) { + $env:PSModulePath = "$localModulesPath$([IO.Path]::PathSeparator)$env:PSModulePath" +} + +DownloadModule -predicate ($all -or $Accounts) -path $localModulesPath -moduleName 'Az.Accounts' -versionMinimum '1.8.1' +DownloadModule -predicate ($all -or $Pester) -path $localModulesPath -moduleName 'Pester' -requiredVersion '4.10.1' + +$tools = Join-Path $PSScriptRoot 'tools' +$resourceDir = Join-Path $tools 'Resources' +$resourceModule = Join-Path $HOME '.PSSharedModules\Resources\Az.Resources.TestSupport.psm1' + +if ($Resources.IsPresent -and (-not (Test-Path -Path $resourceModule))) { + Write-Host -ForegroundColor Green "Building local Resource module used for test..." + Set-Location $resourceDir + $null = autorest-beta .\readme.md --output-folder=$HOME/.PSSharedModules/Resources + $null = Copy-Item custom/* $HOME/.PSSharedModules/Resources/custom/ + Set-Location $HOME/.PSSharedModules/Resources + $null = .\build-module.ps1 + Set-Location $PSScriptRoot +} diff --git a/src/CostManagement/custom/Az.CostManagement.custom.psm1 b/src/CostManagement/custom/Az.CostManagement.custom.psm1 new file mode 100644 index 000000000000..663c86abe4c6 --- /dev/null +++ b/src/CostManagement/custom/Az.CostManagement.custom.psm1 @@ -0,0 +1,17 @@ +# region Generated + # Load the private module dll + $null = Import-Module -PassThru -Name (Join-Path $PSScriptRoot '..\bin\Az.CostManagement.private.dll') + + # Load the internal module + $internalModulePath = Join-Path $PSScriptRoot '..\internal\Az.CostManagement.internal.psm1' + if(Test-Path $internalModulePath) { + $null = Import-Module -Name $internalModulePath + } + + # Export nothing to clear implicit exports + Export-ModuleMember + + # Export script cmdlets + Get-ChildItem -Path $PSScriptRoot -Recurse -Include '*.ps1' -File | ForEach-Object { . $_.FullName } + Export-ModuleMember -Function (Get-ScriptCmdlet -ScriptFolder $PSScriptRoot) -Alias (Get-ScriptCmdlet -ScriptFolder $PSScriptRoot -AsAlias) +# endregion diff --git a/src/CostManagement/custom/Invoke-AzCostManagementQuery.ps1 b/src/CostManagement/custom/Invoke-AzCostManagementQuery.ps1 new file mode 100644 index 000000000000..f3dd057cfe6a --- /dev/null +++ b/src/CostManagement/custom/Invoke-AzCostManagementQuery.ps1 @@ -0,0 +1,276 @@ + +# ---------------------------------------------------------------------------------- +# +# Copyright Microsoft Corporation +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ---------------------------------------------------------------------------------- + +<# +.Synopsis +Query the usage data for scope defined. +.Description +Query the usage data for scope defined. +#> +function Invoke-AzCostManagementQuery { +[OutputType([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryResult])] +[CmdletBinding(DefaultParameterSetName='UsageExpanded', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')] +param( + [Parameter(ParameterSetName='UsageExpanded', Mandatory, HelpMessage="This includes 'subscriptions/{subscriptionId}/' for subscription scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId} for Management Group scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' for invoiceSection scope, and 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' specific for partners.")] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [System.String] + # The scope associated with query and export operations. + # This includes '/subscriptions/{subscriptionId}/' for subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount scope, '/providers/Microsoft.Management/managementGroups/{managementGroupId} for Management Group scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' for invoiceSection scope, and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' specific for partners. + ${Scope}, + + [Parameter(ParameterSetName='UsageExpanded1', Mandatory, HelpMessage="This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' for consolidated account used with dimension/query operations.")] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [System.String] + # This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' for consolidated account used with dimension/query operations. + ${ExternalCloudProviderId}, + + [Parameter(ParameterSetName='UsageExpanded1', Mandatory, HelpMessage="The external cloud provider type associated with dimension/query operations.")] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExternalCloudProviderType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExternalCloudProviderType] + # The external cloud provider type associated with dimension/query operations. + # This includes 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated account. + ${ExternalCloudProviderType}, + + [Parameter(ParameterSetName='UsageExpanded', Mandatory, HelpMessage="The time frame for pulling data for the query.")] + [Parameter(ParameterSetName='UsageExpanded1', Mandatory, HelpMessage="The time frame for pulling data for the query.")] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType] + # The time frame for pulling data for the query. + # If custom, then a specific time period must be provided. + ${Timeframe}, + + [Parameter(ParameterSetName='UsageExpanded', Mandatory, HelpMessage="The type of the query.")] + [Parameter(ParameterSetName='UsageExpanded1', Mandatory, HelpMessage="The type of the query.")] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType] + # The type of the query. + ${Type}, + + [Parameter(ParameterSetName='UsageExpanded', HelpMessage="Array of column names to be included in the query.")] + [Parameter(ParameterSetName='UsageExpanded1', HelpMessage="Array of column names to be included in the query.")] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String[]] + # Array of column names to be included in the query. + # Any valid query column name is allowed. + # If not provided, then query includes all columns. + ${ConfigurationColumn}, + + [Parameter(ParameterSetName='UsageExpanded', HelpMessage="Dictionary of aggregation expression to use in the query.")] + [Parameter(ParameterSetName='UsageExpanded1', HelpMessage="Dictionary of aggregation expression to use in the query.")] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info(PossibleTypes=([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetAggregation]))] + [System.Collections.Hashtable] + # Dictionary of aggregation expression to use in the query. + # The key of each item in the dictionary is the alias for the aggregated column. + # Query can have up to 2 aggregation clauses. + ${DatasetAggregation}, + + [Parameter(ParameterSetName='UsageExpanded', HelpMessage="Has filter expression to use in the query.")] + [Parameter(ParameterSetName='UsageExpanded1', HelpMessage="Has filter expression to use in the query.")] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter] + # Has filter expression to use in the query. + # To construct, see NOTES section for DATASETFILTER properties and create a hash table. + ${DatasetFilter}, + + [Parameter(ParameterSetName='UsageExpanded', HelpMessage="The granularity of rows in the query.")] + [Parameter(ParameterSetName='UsageExpanded1', HelpMessage="The granularity of rows in the query.")] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType] + # The granularity of rows in the query. + ${DatasetGranularity}, + + [Parameter(ParameterSetName='UsageExpanded', HelpMessage='Array of group by expression to use in the query.')] + [Parameter(ParameterSetName='UsageExpanded1', HelpMessage="Array of group by expression to use in the query.")] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryGrouping[]] + # Array of group by expression to use in the query. + # Query can have up to 2 group by clauses. + # To construct, see NOTES section for DATASETGROUPING properties and create a hash table. + ${DatasetGrouping}, + + [Parameter(ParameterSetName='UsageExpanded', HelpMessage="The start date to pull data from.")] + [Parameter(ParameterSetName='UsageExpanded1', HelpMessage="The start date to pull data from.")] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.DateTime] + # The start date to pull data from. + ${TimePeriodFrom}, + + [Parameter(ParameterSetName='UsageExpanded', HelpMessage="The end date to pull data to.")] + [Parameter(ParameterSetName='UsageExpanded1', HelpMessage="The end date to pull data to.")] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.DateTime] + # The end date to pull data to. + ${TimePeriodTo}, + + [Parameter()] + [Alias('AzureRMContext', 'AzureCredential')] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Azure')] + [System.Management.Automation.PSObject] + # The credentials, account, tenant, and subscription used for communication with Azure. + ${DefaultProfile}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Wait for .NET debugger to attach + ${Break}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be appended to the front of the pipeline + ${HttpPipelineAppend}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be prepended to the front of the pipeline + ${HttpPipelinePrepend}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Uri] + # The URI for the proxy server to use + ${Proxy}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.PSCredential] + # Credentials for a proxy server to use for the remote call + ${ProxyCredential}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Use the default credentials for the proxy + ${ProxyUseDefaultCredentials} +) + + process { + $ApiVersion = '2019-11-01' + $URL = '' + if ($PSBoundParameters.ContainsKey('ExternalCloudProviderType')) { + $URL = [System.Text.RegularExpressions.Regex]::Replace( + "providers/Microsoft.CostManagement/$ExternalCloudProviderType/$ExternalCloudProviderId/query?api-version=$ApiVersion" ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2") + } else { + $URL = [System.Text.RegularExpressions.Regex]::Replace( + "$Scope/providers/Microsoft.CostManagement/query?api-version=$ApiVersion", "\\?&*$|&*$|(\\?)&+|(&)&+","$1$2") + } + + $Request = [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryDefinition]::New() + if ($PSBoundParameters.ContainsKey('ConfigurationColumn')) { + $Request.ConfigurationColumn = $ConfigurationColumn + } + if ($PSBoundParameters.ContainsKey('DatasetAggregation')) { + $Request.DatasetAggregation = $DatasetAggregation + } + if ($PSBoundParameters.ContainsKey('DatasetFilter')) { + $Request.DatasetFilter = $DatasetFilter + } + if ($PSBoundParameters.ContainsKey('DatasetGranularity')) { + $Request.DatasetGranularity = $DatasetGranularity + } + if ($PSBoundParameters.ContainsKey('DatasetGrouping')) { + $Request.DatasetGrouping = $DatasetGrouping + } + if ($PSBoundParameters.ContainsKey('TimePeriodFrom')) { + $Request.TimePeriodFrom = $TimePeriodFrom + } + if ($PSBoundParameters.ContainsKey('TimePeriodTo')) { + $Request.TimePeriodTo = $TimePeriodTo + } + if ($PSBoundParameters.ContainsKey('Timeframe')) { + $Request.Timeframe = $Timeframe + } + if ($PSBoundParameters.ContainsKey('Type')) { + $Request.Type = $Type + } + $Result = [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryResult]::New() + $SkipToken = $null + $RowList = New-Object System.Collections.Generic.List[System.Collections.Generic.List[string]] + while ($true) { + $Response = Invoke-AzCostManagementUsageQueryInternal -URL $URL -SkipToken $SkipToken -Payload $Request.ToJsonString() -Scope $Scope + $Result.Column = $Response.Column + foreach ($Row in $Response.Row) { + $RowList.Add($Row) + } + if ($null -ne $Response.NextLink -and '' -ne $Response.nextlink) + { + $SkipToken = $Response.nextLink + } else { + break + } + } + $Result.Row = $RowList + return $Result + } +} + +function Invoke-AzCostManagementUsageQueryInternal { + [OutputType([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryResult])] + param( + [System.String] + ${URL}, + [System.String] + ${SkipToken}, + [System.String] + ${Payload}, + [System.String] + ${Scope} + ) + process { + if ($null -ne $SkipToken -and $SkipToken -ne '') { + $URL = "$URL&$SkipToken" + } + $ResponseContent = (Invoke-AzRest -Path $URL -Payload $Payload -Method POST).Content | ConvertFrom-Json + + $Result = [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryResult]::New() + if ($null -ne $ResponseContent.Properties.NextLink) + { + $Result.NextLink = $ResponseContent.Properties.NextLink.split('&')[1] + } + + $ColumnList = New-Object System.Collections.Generic.List[Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryColumn] + foreach ($Column in $ResponseContent.Properties.Columns) { + Write-Host $Column.ToString() + $QueryColumn = [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryColumn]::New() + $QueryColumn.Name = $Column.Name + $QueryColumn.Type = $Column.Type + $ColumnList.Add($QueryColumn) + } + $Result.Column = $ColumnList + + $RowList = New-Object System.Collections.Generic.List[System.Collections.Generic.List[string]] + foreach ($Row in $ResponseContent.Properties.Rows) { + $QueryRow = New-Object System.Collections.Generic.List[string] + foreach ($Item in $Row) { + $QueryRow.Add($Item.ToString()) + } + $RowList.Add($QueryRow) + } + $Result.Row = $RowList + + return $Result + } +} diff --git a/src/CostManagement/custom/New-AzCostManagementExport.ps1 b/src/CostManagement/custom/New-AzCostManagementExport.ps1 new file mode 100644 index 000000000000..fa6166f87426 --- /dev/null +++ b/src/CostManagement/custom/New-AzCostManagementExport.ps1 @@ -0,0 +1,231 @@ + +# ---------------------------------------------------------------------------------- +# +# Copyright Microsoft Corporation +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ---------------------------------------------------------------------------------- + +<# +.Synopsis +The operation to create or update a export. +Update operation requires latest eTag to be set in the request. +You may obtain the latest eTag by performing a get operation. +Create operation does not require eTag. +.Description +The operation to create or update a export. +Update operation requires latest eTag to be set in the request. +You may obtain the latest eTag by performing a get operation. +Create operation does not require eTag. +#> +function New-AzCostManagementExport { +[OutputType([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport])] +[CmdletBinding(DefaultParameterSetName='CreateExpanded', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')] +param( + [Parameter(Mandatory)] + [Alias('ExportName')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [System.String] + # Export Name. + ${Name}, + + [Parameter(Mandatory)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [System.String] + # This parameter defines the scope of costmanagement from different perspectives 'Subscription','ResourceGroup' and 'Provide Service'. + ${Scope}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String[]] + # Array of column names to be included in the export. + # If not provided then the export will include all available columns. + # The available columns can vary by customer channel (see examples). + ${ConfigurationColumn}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType] + # The granularity of rows in the export. + # Currently only 'Daily' is supported. + ${DataSetGranularity}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType] + # The time frame for pulling data for the export. + # If custom, then a specific time period must be provided. + ${DefinitionTimeframe}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType] + # The type of the export. + # Note that 'Usage' is equivalent to 'ActualCost' and is applicable to exports that do not yet provide data for charges or amortization for service reservations. + ${DefinitionType}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String] + # The name of the container where exports will be uploaded. + ${DestinationContainer}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String] + # The resource id of the storage account where exports will be delivered. + ${DestinationResourceId}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String] + # The name of the directory where exports will be uploaded. + ${DestinationRootFolderPath}, + + # [Parameter()] + # [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + # [System.String] + # # eTag of the resource. + # # To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not. + # ${ETag}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType] + # The format of the export being delivered. + # Currently only 'Csv' is supported. + ${Format}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.DateTime] + # The start date of recurrence. + ${RecurrencePeriodFrom}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.DateTime] + # The end date of recurrence. + ${RecurrencePeriodTo}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType] + # The schedule recurrence. + ${ScheduleRecurrence}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType] + # The status of the export's schedule. + # If 'Inactive', the export's schedule is paused. + ${ScheduleStatus}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.DateTime] + # The start date for export data. + ${TimePeriodFrom}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.DateTime] + # The end date for export data. + ${TimePeriodTo}, + + [Parameter()] + [Alias('AzureRMContext', 'AzureCredential')] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Azure')] + [System.Management.Automation.PSObject] + # The credentials, account, tenant, and subscription used for communication with Azure. + ${DefaultProfile}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Wait for .NET debugger to attach + ${Break}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be appended to the front of the pipeline + ${HttpPipelineAppend}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be prepended to the front of the pipeline + ${HttpPipelinePrepend}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Uri] + # The URI for the proxy server to use + ${Proxy}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.PSCredential] + # Credentials for a proxy server to use for the remote call + ${ProxyCredential}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Use the default credentials for the proxy + ${ProxyUseDefaultCredentials} +) + +begin { + try { + $outBuffer = $null + if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer)) { + $PSBoundParameters['OutBuffer'] = 1 + } + $parameterSet = $PSCmdlet.ParameterSetName + $mapping = @{ + CreateExpanded = 'Az.CostManagement.private\New-AzCostManagementExport_CreateExpanded'; + } + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet) + $scriptCmd = {& $wrappedCmd @PSBoundParameters} + $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin) + $steppablePipeline.Begin($PSCmdlet) + } catch { + throw + } +} + +process { + try { + $steppablePipeline.Process($_) + } catch { + throw + } +} + +end { + try { + $steppablePipeline.End() + } catch { + throw + } +} +} diff --git a/src/CostManagement/custom/New-AzCostManagementQueryComparisonExpressionObject.ps1 b/src/CostManagement/custom/New-AzCostManagementQueryComparisonExpressionObject.ps1 new file mode 100644 index 000000000000..ea1030077d7f --- /dev/null +++ b/src/CostManagement/custom/New-AzCostManagementQueryComparisonExpressionObject.ps1 @@ -0,0 +1,52 @@ + +# ---------------------------------------------------------------------------------- +# +# Copyright Microsoft Corporation +# Licensed under the Apache License, Version 2.0 (the \"License\"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an \"AS IS\" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ---------------------------------------------------------------------------------- + +<# +.Synopsis +Create a in-memory object for QueryComparisonExpression +.Description +Create a in-memory object for QueryComparisonExpression + +.Outputs +Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryComparisonExpression +.Link +https://docs.microsoft.com/en-us/powershell/module/az.CostManagement/new-AzCostManagementQueryComparisonExpressionObject +#> +function New-AzCostManagementQueryComparisonExpressionObject { + [OutputType('Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryComparisonExpression')] + [CmdletBinding(PositionalBinding=$false)] + Param( + + [Parameter(Mandatory, HelpMessage="The name of the column to use in comparison.")] + [string] + $Name, + [Parameter(Mandatory, HelpMessage="The operator to use for comparison.")] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.OperatorType] + $Operator, + [Parameter(Mandatory, HelpMessage="Array of values to use for comparison.")] + [string[]] + $Value + ) + + process { + $Object = [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryComparisonExpression]::New() + + $Object.Name = $Name + $Object.Operator = $Operator + $Object.Value = $Value + return $Object + } +} + diff --git a/src/CostManagement/custom/New-AzCostManagementQueryFilterObject.ps1 b/src/CostManagement/custom/New-AzCostManagementQueryFilterObject.ps1 new file mode 100644 index 000000000000..946aedfa598c --- /dev/null +++ b/src/CostManagement/custom/New-AzCostManagementQueryFilterObject.ps1 @@ -0,0 +1,60 @@ + +# ---------------------------------------------------------------------------------- +# +# Copyright Microsoft Corporation +# Licensed under the Apache License, Version 2.0 (the \"License\"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an \"AS IS\" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ---------------------------------------------------------------------------------- + +<# +.Synopsis +Create a in-memory object for QueryFilter +.Description +Create a in-memory object for QueryFilter + +.Outputs +Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryFilter +.Link +https://docs.microsoft.com/en-us/powershell/module/az.CostManagement/new-AzCostManagementQueryFilterObject +#> +function New-AzCostManagementQueryFilterObject { + [OutputType('Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryFilter')] + [CmdletBinding(PositionalBinding=$false)] + Param( + + [Parameter(HelpMessage="The logical `"AND`" expression. Must have at least 2 items.")] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter[]] + $And, + [Parameter(HelpMessage="Has comparison expression for a dimensions.")] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryComparisonExpression] + $Dimensions, + [Parameter(HelpMessage="The logical `"NOT`" expression.")] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter] + $Not, + [Parameter(HelpMessage="The logical `"OR`" expression. Must have at least 2 items.")] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter[]] + $Or, + [Parameter(HelpMessage="Has comparison expression for a tag.")] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryComparisonExpression] + $Tag + ) + + process { + $Object = [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryFilter]::New() + + $Object.And = $And + $Object.Dimensions = $Dimensions + $Object.Not = $Not + $Object.Or = $Or + $Object.Tag = $Tag + return $Object + } +} + diff --git a/src/CostManagement/custom/Update-AzCostManagementExport.ps1 b/src/CostManagement/custom/Update-AzCostManagementExport.ps1 new file mode 100644 index 000000000000..3ecf17df8afb --- /dev/null +++ b/src/CostManagement/custom/Update-AzCostManagementExport.ps1 @@ -0,0 +1,294 @@ + +# ---------------------------------------------------------------------------------- +# +# Copyright Microsoft Corporation +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ---------------------------------------------------------------------------------- + +<# +.Synopsis +The operation to create or update a export. +Update operation requires latest eTag to be set in the request. +You may obtain the latest eTag by performing a get operation. +Create operation does not require eTag. +.Description +The operation to create or update a export. +Update operation requires latest eTag to be set in the request. +You may obtain the latest eTag by performing a get operation. +Create operation does not require eTag. +.Example +PS C:\> {{ Add code here }} + +{{ Add output here }} +.Example +PS C:\> {{ Add code here }} + +{{ Add output here }} + +.Inputs +Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity +.Outputs +Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport +.Notes +COMPLEX PARAMETER PROPERTIES + +To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables. + +INPUTOBJECT : Identity Parameter + [AlertId ]: Alert ID + [ExportName ]: Export Name. + [ExternalCloudProviderId ]: This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' for consolidated account used with dimension/query operations. + [ExternalCloudProviderType ]: The external cloud provider type associated with dimension/query operations. This includes 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated account. + [Id ]: Resource identity path + [Scope ]: The scope associated with view operations. This includes 'subscriptions/{subscriptionId}' for subscription scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for BillingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' for InvoiceSection scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope, 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for External Billing Account scope and 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for External Subscription scope. + [ViewName ]: View name +.Link +https://docs.microsoft.com/en-us/powershell/module/az.costmanagement/update-azcostmanagementexport +#> +function Update-AzCostManagementExport { +[OutputType([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport])] +[CmdletBinding(DefaultParameterSetName='UpdateExpanded', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')] +param( + [Parameter(ParameterSetName='UpdateExpanded', Mandatory)] + [Alias('ExportName')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [System.String] + # Export Name. + ${Name}, + + [Parameter(ParameterSetName='UpdateExpanded', Mandatory)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [System.String] + # This parameter defines the scope of costmanagement from different perspectives 'Subscription','ResourceGroup' and 'Provide Service'. + ${Scope}, + + [Parameter(ParameterSetName='UpdateViaIdentityExpanded', Mandatory, ValueFromPipeline)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity] + # Identity Parameter + # To construct, see NOTES section for INPUTOBJECT properties and create a hash table. + ${InputObject}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String[]] + # Array of column names to be included in the export. + # If not provided then the export will include all available columns. + # The available columns can vary by customer channel (see examples). + ${ConfigurationColumn}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType] + # The granularity of rows in the export. + # Currently only 'Daily' is supported. + ${DataSetGranularity}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType] + # The time frame for pulling data for the export. + # If custom, then a specific time period must be provided. + ${DefinitionTimeframe}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType] + # The type of the export. + # Note that 'Usage' is equivalent to 'ActualCost' and is applicable to exports that do not yet provide data for charges or amortization for service reservations. + ${DefinitionType}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String] + # The name of the container where exports will be uploaded. + ${DestinationContainer}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String] + # The resource id of the storage account where exports will be delivered. + ${DestinationResourceId}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String] + # The name of the directory where exports will be uploaded. + ${DestinationRootFolderPath}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String] + # eTag of the resource. + # To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not. + ${ETag}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType] + # The format of the export being delivered. + # Currently only 'Csv' is supported. + ${Format}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.DateTime] + # The start date of recurrence. + ${RecurrencePeriodFrom}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.DateTime] + # The end date of recurrence. + ${RecurrencePeriodTo}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType] + # The schedule recurrence. + ${ScheduleRecurrence}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType] + # The status of the export's schedule. + # If 'Inactive', the export's schedule is paused. + ${ScheduleStatus}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.DateTime] + # The start date for export data. + ${TimePeriodFrom}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.DateTime] + # The end date for export data. + ${TimePeriodTo}, + + [Parameter()] + [Alias('AzureRMContext', 'AzureCredential')] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Azure')] + [System.Management.Automation.PSObject] + # The credentials, account, tenant, and subscription used for communication with Azure. + ${DefaultProfile}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Wait for .NET debugger to attach + ${Break}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be appended to the front of the pipeline + ${HttpPipelineAppend}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be prepended to the front of the pipeline + ${HttpPipelinePrepend}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Uri] + # The URI for the proxy server to use + ${Proxy}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.PSCredential] + # Credentials for a proxy server to use for the remote call + ${ProxyCredential}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Use the default credentials for the proxy + ${ProxyUseDefaultCredentials} + ) + + process { + try { + $getExport + if($PSBoundParameters['InputObject'] -ne $null) + { + $InputExportObject = $PSBoundParameters['InputObject'] + $getExport = Get-AzCostManagementExport -InputObject $InputExportObject + }else{ + $InputExportScope = $PSBoundParameters['Scope'] + $InputExportName = $PSBoundParameters['Name'] + $getExport = Get-AzCostManagementExport -Scope $InputExportScope -Name $InputExportName + } + $null = $PSBoundParameters.Add("ETag",$getExport.Etag) + if($PSBoundParameters['DataSetGranularity'] -eq $null) + { + $null = $PSBoundParameters.Add("DataSetGranularity",$getExport.DataSetGranularity) + } + if($PSBoundParameters['DefinitionTimeframe'] -eq $null) + { + $null = $PSBoundParameters.Add("DefinitionTimeframe",$getExport.DefinitionTimeframe) + } + if($PSBoundParameters['DefinitionType'] -eq $null) + { + $null = $PSBoundParameters.Add("DefinitionType",$getExport.DefinitionType) + } + if($PSBoundParameters['DestinationContainer'] -eq $null) + { + $null = $PSBoundParameters.Add("DestinationContainer",$getExport.DestinationContainer) + } + if($PSBoundParameters['DestinationResourceId'] -eq $null) + { + $null = $PSBoundParameters.Add("DestinationResourceId",$getExport.DestinationResourceId) + } + if($PSBoundParameters['DestinationRootFolderPath'] -eq $null) + { + $null = $PSBoundParameters.Add("DestinationRootFolderPath",$getExport.DestinationRootFolderPath) + } + if($PSBoundParameters['Format'] -eq $null) + { + $null = $PSBoundParameters.Add("Format",$getExport.Format) + } + if($PSBoundParameters['RecurrencePeriodFrom'] -eq $null) + { + $null = $PSBoundParameters.Add("RecurrencePeriodFrom",$getExport.RecurrencePeriodFrom) + } + if($PSBoundParameters['RecurrencePeriodTo'] -eq $null) + { + $null = $PSBoundParameters.Add("RecurrencePeriodTo",$getExport.RecurrencePeriodTo) + } + if($PSBoundParameters['ScheduleStatus'] -eq $null) + { + $null = $PSBoundParameters.Add("ScheduleStatus",$getExport.ScheduleStatus) + } + if($PSBoundParameters['ScheduleRecurrence'] -eq $null) + { + $null = $PSBoundParameters.Add("ScheduleRecurrence",$getExport.ScheduleRecurrence) + } + Az.CostManagement.internal\Update-AzCostManagementExport @PSBoundParameters + } catch { + throw + } + } +} \ No newline at end of file diff --git a/src/CostManagement/custom/readme.md b/src/CostManagement/custom/readme.md new file mode 100644 index 000000000000..f488fa1a08b0 --- /dev/null +++ b/src/CostManagement/custom/readme.md @@ -0,0 +1,41 @@ +# Custom +This directory contains custom implementation for non-generated cmdlets for the `Az.CostManagement` module. Both scripts (`.ps1`) and C# files (`.cs`) can be implemented here. They will be used during the build process in `build-module.ps1`, and create cmdlets into the `..\exports` folder. The only generated file into this folder is the `Az.CostManagement.custom.psm1`. This file should not be modified. + +## Info +- Modifiable: yes +- Generated: partial +- Committed: yes +- Packaged: yes + +## Details +For `Az.CostManagement` to use custom cmdlets, it does this two different ways. We **highly recommend** creating script cmdlets, as they are easier to write and allow access to the other exported cmdlets. C# cmdlets *cannot access exported cmdlets*. + +For C# cmdlets, they are compiled with the rest of the generated low-level cmdlets into the `./bin/Az.CostManagement.private.dll`. The names of the cmdlets (methods) and files must follow the `[cmdletName]_[variantName]` syntax used for generated cmdlets. The `variantName` is used as the `ParameterSetName`, so use something appropriate that doesn't clash with already created variant or parameter set names. You cannot use the `ParameterSetName` property in the `Parameter` attribute on C# cmdlets. Each cmdlet must be separated into variants using the same pattern as seen in the `generated/cmdlets` folder. + +For script cmdlets, these are loaded via the `Az.CostManagement.custom.psm1`. Then, during the build process, this module is loaded and processed in the same manner as the C# cmdlets. The fundemental difference is the script cmdlets use the `ParameterSetName` attribute and C# cmdlets do not. To create a script cmdlet variant of a generated cmdlet, simply decorate all parameters in the script with the new `ParameterSetName` in the `Parameter` attribute. This will appropriately treat each parameter set as a separate variant when processed to be exported during the build. + +## Purpose +This allows the modules to have cmdlets that were not defined in the REST specification. It also allows combining logic using generated cmdlets. This is a level of customization beyond what can be done using the [readme configuration options](https://github.com/Azure/autorest/blob/master/docs/powershell/options.md) that are currently available. These custom cmdlets are then referenced by the cmdlets created at build-time in the `..\exports` folder. + +## Usage +The easiest way currently to start developing custom cmdlets is to copy an existing cmdlet. For C# cmdlets, copy one from the `generated/cmdlets` folder. For script cmdlets, build the project using `build-module.ps1` and copy one of the scripts from the `..\exports` folder. After that, if you want to add new parameter sets, follow the guidelines in the `Details` section above. For implementing a new cmdlets, at minimum, please keep these parameters: +- Break +- DefaultProfile +- HttpPipelineAppend +- HttpPipelinePrepend +- Proxy +- ProxyCredential +- ProxyUseDefaultCredentials + +These provide functionality to our HTTP pipeline and other useful features. In script, you can forward these parameters using `$PSBoundParameters` to the other cmdlets you're calling within `Az.CostManagement`. For C#, follow the usage seen in the `ProcessRecordAsync` method. + +### Attributes +For processing the cmdlets, we've created some additional attributes: +- `Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.DescriptionAttribute` + - Used in C# cmdlets to provide a high-level description of the cmdlet. This is propegated to reference documentation via [help comments](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_comment_based_help) in the exported scripts. +- `Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.DoNotExportAttribute` + - Used in C# and script cmdlets to suppress creating an exported cmdlet at build-time. These cmdlets will *not be exposed* by `Az.CostManagement`. +- `Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.InternalExportAttribute` + - Used in C# cmdlets to route exported cmdlets to the `..\internal`, which are *not exposed* by `Az.CostManagement`. For more information, see [readme.md](..\internal/readme.md) in the `..\internal` folder. +- `Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ProfileAttribute` + - Used in C# and script cmdlets to define which Azure profiles the cmdlet supports. This is only supported for Azure (`--azure`) modules. \ No newline at end of file diff --git a/src/CostManagement/examples/Get-AzCostManagementExport.md b/src/CostManagement/examples/Get-AzCostManagementExport.md new file mode 100644 index 000000000000..fbe3ad3dac03 --- /dev/null +++ b/src/CostManagement/examples/Get-AzCostManagementExport.md @@ -0,0 +1,24 @@ +### Example 1: Get all AzCostManagementExports by scope +```powershell +PS C:\> Get-AzCostManagementExport -Scope 'subscriptions/**********' + +ETag Name Type +---- ---- ---- +"************" TestExport Microsoft.CostManagement/exports +"************" TestExport1 Microsoft.CostManagement/exports +"************" TestExport2 Microsoft.CostManagement/exports +``` + +Get all AzCostManagementExports by Scope + +### Example 2: Get AzCostManagementExport by Name and scope +```powershell +PS C:\> Get-AzCostManagementExport -Name 'TestExport' -Scope 'subscriptions/**********' + +ETag Name Type +---- ---- ---- +"************" TestExport Microsoft.CostManagement/exports +``` + +Get AzCostManagementExport by Name and scope + diff --git a/src/CostManagement/examples/Get-AzCostManagementExportExecutionHistory.md b/src/CostManagement/examples/Get-AzCostManagementExportExecutionHistory.md new file mode 100644 index 000000000000..10a16ea48382 --- /dev/null +++ b/src/CostManagement/examples/Get-AzCostManagementExportExecutionHistory.md @@ -0,0 +1,25 @@ +### Example 1: Get AzCostManagementExportExecutionHistory +```powershell +PS C:\> Get-AzCostManagementExportExecutionHistory -ExportName 'TestExport' -Scope 'subscriptions/**********' + +ExecutionType ProcessingStartTime ProcessingEndTime Status FileName +------------- ------------------- ----------------- ------ -------- +Scheduled 2020/6/11 12:03:20 2020/6/11 12:03:43 Completed ad-hoc/TestExport/20200601-20200630/TestExport_00000000-0000-0000-0000-000000000000.csv +Scheduled 2020/6/12 12:03:37 2020/6/12 12:03:48 Completed ad-hoc/TestExport/20200601-20200630/TestExport_00000000-0000-0000-0000-000000000000.csv +``` + +Get AzCostManagementExportExecutionHistory By ExportName and Scope + +### Example 2: Get AzCostManagementExportExecutionHistory by InputObject +```powershell +PS C:\> $getExport = Get-AzCostManagementExport -Name 'TestExport' -Scope 'subscriptions/**********' +Get-AzCostManagementExportExecutionHistory -InputObject $getExport + +ExecutionType ProcessingStartTime ProcessingEndTime Status FileName +------------- ------------------- ----------------- ------ -------- +Scheduled 2020/6/11 12:03:20 2020/6/11 12:03:43 Completed ad-hoc/TestExport/20200601-20200630/TestExport_00000000-0000-0000-0000-000000000000.csv +Scheduled 2020/6/12 12:03:37 2020/6/12 12:03:48 Completed ad-hoc/TestExport/20200601-20200630/ +``` + +Get AzCostManagementExportExecutionHistory By InputObject + diff --git a/src/CostManagement/examples/Invoke-AzCostManagementExecuteExport.md b/src/CostManagement/examples/Invoke-AzCostManagementExecuteExport.md new file mode 100644 index 000000000000..cc22ce003f0a --- /dev/null +++ b/src/CostManagement/examples/Invoke-AzCostManagementExecuteExport.md @@ -0,0 +1,17 @@ +### Example 1: Invoke Export by ExportName and Scope +```powershell +PS C:\> Invoke-AzCostManagementExecuteExport -ExportName 'TestExport' -Scope 'subscriptions/**********' + +``` + +Invoke Export by ExportName and Scope + +### Example 2: Invoke Export by InputObject +```powershell +PS C:\> $getExport = Get-AzCostManagementExport -Name 'TestExport' -Scope 'subscriptions/**********' +Invoke-AzCostManagementExecuteExport -InputObject $getExport + +``` + +Invoke Export by InputObject + diff --git a/src/CostManagement/examples/Invoke-AzCostManagementQuery.md b/src/CostManagement/examples/Invoke-AzCostManagementQuery.md new file mode 100644 index 000000000000..ae4cf712e1b0 --- /dev/null +++ b/src/CostManagement/examples/Invoke-AzCostManagementQuery.md @@ -0,0 +1,24 @@ +### Example 1: Invoke AzCostManagementQuery by Scope +```powershell +PS C:\> Invoke-AzCostManagementQuery -Scope "/subscriptions/***********" -Timeframe MonthToDate -Type Usage -DatasetGranularity 'Daily' + +Column Row +------ --- +{UsageDate, Currency} {20201101 USD, 20201102 USD, 20201103 USD, 20201104 USD…} +``` + +Invoke AzCostManagementQuery by Scope + +### Example 2: Invoke AzCostManagementQuery by Scope with Dimensions +```powershell +PS C:\> $dimensions = New-AzCostManagementQueryComparisonExpressionObject -Name 'ResourceGroup' -Operator 'In' -Value 'API' +$filter = New-AzCostManagementQueryFilterObject -Dimensions $dimensions +Invoke-AzCostManagementQuery -Type Usage -Scope "subscriptions/***********" -DatasetGranularity 'Monthly' -DatasetFilter $filter -Timeframe MonthToDate -Debug + + +Column Row +------ --- +{BillingMonth, Currency} {} +``` + +Invoke AzCostManagementQuery by Scope with Dimensions \ No newline at end of file diff --git a/src/CostManagement/examples/New-AzCostManagementExport.md b/src/CostManagement/examples/New-AzCostManagementExport.md new file mode 100644 index 000000000000..b93092c35902 --- /dev/null +++ b/src/CostManagement/examples/New-AzCostManagementExport.md @@ -0,0 +1,11 @@ +### Example 1: Create an AzCostManagementExport +```powershell +PS C:\> New-AzCostManagementExport -Scope "subscriptions/***********" -Name "CostManagementExportTest" -ScheduleStatus "Active" -ScheduleRecurrence "Daily" -RecurrencePeriodFrom "2020-10-31T20:00:00Z" -RecurrencePeriodTo "2020-11-30T00:00:00Z" -Format "Csv" -DestinationResourceId "/subscriptions/*************/resourceGroups/ResourceGroupTest/providers/Microsoft.Storage/storageAccounts/storageAccountTest" ` -DestinationContainer "exports" -DestinationRootFolderPath "ad-hoc" -DefinitionType "Usage" -DefinitionTimeframe "MonthToDate" -DatasetGranularity "Daily" + +ETag Name Type +---- ---- ---- +"********" TestExportDatasetAggregationInfosagdhaghj Microsoft.CostManagement/exports +``` + +Create an AzCostManagementExport + diff --git a/src/CostManagement/examples/New-AzCostManagementQueryComparisonExpressionObject.md b/src/CostManagement/examples/New-AzCostManagementQueryComparisonExpressionObject.md new file mode 100644 index 000000000000..89f150db32d7 --- /dev/null +++ b/src/CostManagement/examples/New-AzCostManagementQueryComparisonExpressionObject.md @@ -0,0 +1,11 @@ +### Example 1: Create a comparison expression object of query for cost management export +```powershell +PS C:\> New-AzCostManagementQueryComparisonExpressionObject -Name 'ResourceLocation' -Operator In -Value @('East US', 'West Europe') + +Name Operator Value +---- -------- ----- +ResourceLocation In {East US, West Europe} +``` + +This command creates a comparison expression object of query for cost management export. + diff --git a/src/CostManagement/examples/New-AzCostManagementQueryFilterObject.md b/src/CostManagement/examples/New-AzCostManagementQueryFilterObject.md new file mode 100644 index 000000000000..08f45c24370c --- /dev/null +++ b/src/CostManagement/examples/New-AzCostManagementQueryFilterObject.md @@ -0,0 +1,15 @@ +### Example 1: Create a filter object of query for cost management export +```powershell +PS C:\> $orDimension = New-AzCostManagementQueryComparisonExpressionObject -Name 'ResourceLocation' -Operator In -Value @('East US', 'West Europe') +PS C:\> $orTag = New-AzCostManagementQueryComparisonExpressionObject -Name 'Environment' -Operator In -Value @('UAT', 'Prod') +PS C:\> New-AzCostManagementQueryFilterObject -or @((New-AzCostManagementQueryFilterObject -Dimension $orDimension), (New-AzCostManagementQueryFilterObject -Tag $orTag)) + +And : +Dimension : Microsoft.Azure.PowerShell.Cmdlets.Cost.Models.Api20200601.QueryComparisonExpression +Not : Microsoft.Azure.PowerShell.Cmdlets.Cost.Models.Api20200601.QueryFilter +Or : {Microsoft.Azure.PowerShell.Cmdlets.Cost.Models.Api20200601.QueryFilter, Microsoft.Azure.PowerShell.Cmdlets.Cost.Models.Api20200601.QueryFilter} +Tag : Microsoft.Azure.PowerShell.Cmdlets.Cost.Models.Api20200601.QueryComparisonExpression +``` + +this command creates a filter object of query for cost management export. + diff --git a/src/CostManagement/examples/Remove-AzCostManagementExport.md b/src/CostManagement/examples/Remove-AzCostManagementExport.md new file mode 100644 index 000000000000..b913c3e4c876 --- /dev/null +++ b/src/CostManagement/examples/Remove-AzCostManagementExport.md @@ -0,0 +1,19 @@ +### Example 1: Delete the AzCostManagementExport by Scope and Name +```powershell +PS C:\> Remove-AzCostManagementExport -Scope 'subscriptions/********' -name 'TestExportDatasetAggregationInfoYouri' + + +``` + +Delete the AzCostManagementExport By Scope and ExportName + +### Example 2: Delete the AzCostManagementExport by Export Object +```powershell +PS C:\> $getExport = Get-AzCostManagementExport -Scope 'subscriptions/*********' -name 'TestExportDatasetAggregationYouori' +Remove-AzCostManagementExport -InputObject $getExport + + +``` + +Delete the AzCostManagementExport By InputObject + diff --git a/src/CostManagement/examples/Update-AzCostManagementExport.md b/src/CostManagement/examples/Update-AzCostManagementExport.md new file mode 100644 index 000000000000..48744b80912b --- /dev/null +++ b/src/CostManagement/examples/Update-AzCostManagementExport.md @@ -0,0 +1,23 @@ +### Example 1: Update AzCostManagementExport by scope and name +```powershell +PS C:\> Update-AzCostManagementExport -Scope "subscriptions//*********" -Name "TestExport" -ScheduleRecurrence 'Weekly' + +ETag Name Type +---- ---- ---- +"********" TestExportDatasetAggregationInfo Microsoft.CostManagement/exports +``` + +Update AzCostManagementExport by Scope and name + +### Example 2: Update AzCostManagementExport by InputObject +```powershell +PS C:\> $oldExport = Get-AzCostManagementExport -Scope "subscriptions/*********" -Name "TestExport" +Update-AzCostManagementExport -InputObject $oldExport -ScheduleRecurrence 'Weekly' + +ETag Name Type +---- ---- ---- +"********" TestExportDatasetAggregationInfo Microsoft.CostManagement/exports +``` + +Update AzCostManagementExport by InputObject + diff --git a/src/CostManagement/export-surface.ps1 b/src/CostManagement/export-surface.ps1 new file mode 100644 index 000000000000..b3916fce9e94 --- /dev/null +++ b/src/CostManagement/export-surface.ps1 @@ -0,0 +1,40 @@ +# ---------------------------------------------------------------------------------- +# +# Copyright Microsoft Corporation +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ---------------------------------------------------------------------------------- +param([switch]$Isolated, [switch]$IncludeGeneralParameters, [switch]$UseExpandedFormat) +$ErrorActionPreference = 'Stop' + +$pwsh = [System.Diagnostics.Process]::GetCurrentProcess().Path +if(-not $Isolated) { + Write-Host -ForegroundColor Green 'Creating isolated process...' + & "$pwsh" -NonInteractive -NoLogo -NoProfile -File $MyInvocation.MyCommand.Path @PSBoundParameters -Isolated + return +} + +$dll = Join-Path $PSScriptRoot 'bin\Az.CostManagement.private.dll' +if(-not (Test-Path $dll)) { + Write-Error "Unable to find output assembly in '$binFolder'." +} +$null = Import-Module -Name $dll + +$moduleName = 'Az.CostManagement' +$exportsFolder = Join-Path $PSScriptRoot 'exports' +$resourcesFolder = Join-Path $PSScriptRoot 'resources' + +Export-CmdletSurface -ModuleName $moduleName -CmdletFolder $exportsFolder -OutputFolder $resourcesFolder -IncludeGeneralParameters $IncludeGeneralParameters.IsPresent -UseExpandedFormat $UseExpandedFormat.IsPresent +Write-Host -ForegroundColor Green "CmdletSurface file(s) created in '$resourcesFolder'" + +Export-ModelSurface -OutputFolder $resourcesFolder -UseExpandedFormat $UseExpandedFormat.IsPresent +Write-Host -ForegroundColor Green "ModelSurface file created in '$resourcesFolder'" + +Write-Host -ForegroundColor Green '-------------Done-------------' \ No newline at end of file diff --git a/src/CostManagement/exports/Get-AzCostManagementExport.ps1 b/src/CostManagement/exports/Get-AzCostManagementExport.ps1 new file mode 100644 index 000000000000..4562ccbb118f --- /dev/null +++ b/src/CostManagement/exports/Get-AzCostManagementExport.ps1 @@ -0,0 +1,172 @@ + +# ---------------------------------------------------------------------------------- +# +# Copyright Microsoft Corporation +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ---------------------------------------------------------------------------------- + +<# +.Synopsis +The operation to get the export for the defined scope by export name. +.Description +The operation to get the export for the defined scope by export name. +.Example +PS C:\> Get-AzCostManagementExport -Scope 'subscriptions/**********' + +ETag Name Type +---- ---- ---- +"************" TestExport Microsoft.CostManagement/exports +"************" TestExport1 Microsoft.CostManagement/exports +"************" TestExport2 Microsoft.CostManagement/exports +.Example +PS C:\> Get-AzCostManagementExport -Name 'TestExport' -Scope 'subscriptions/**********' + +ETag Name Type +---- ---- ---- +"************" TestExport Microsoft.CostManagement/exports + +.Inputs +Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity +.Outputs +Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport +.Notes +COMPLEX PARAMETER PROPERTIES + +To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables. + +INPUTOBJECT : Identity Parameter + [AlertId ]: Alert ID + [ExportName ]: Export Name. + [ExternalCloudProviderId ]: This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' for consolidated account used with dimension/query operations. + [ExternalCloudProviderType ]: The external cloud provider type associated with dimension/query operations. This includes 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated account. + [Id ]: Resource identity path + [Scope ]: The scope associated with view operations. This includes 'subscriptions/{subscriptionId}' for subscription scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for BillingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' for InvoiceSection scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope, 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for External Billing Account scope and 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for External Subscription scope. + [ViewName ]: View name +.Link +https://docs.microsoft.com/en-us/powershell/module/az.costmanagement/get-azcostmanagementexport +#> +function Get-AzCostManagementExport { +[OutputType([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport])] +[CmdletBinding(DefaultParameterSetName='List', PositionalBinding=$false)] +param( + [Parameter(ParameterSetName='Get', Mandatory)] + [Alias('ExportName')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [System.String] + # Export Name. + ${Name}, + + [Parameter(ParameterSetName='Get', Mandatory)] + [Parameter(ParameterSetName='List', Mandatory)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [System.String] + # This parameter defines the scope of costmanagement from different perspectives 'Subscription','ResourceGroup' and 'Provide Service'. + ${Scope}, + + [Parameter(ParameterSetName='GetViaIdentity', Mandatory, ValueFromPipeline)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity] + # Identity Parameter + # To construct, see NOTES section for INPUTOBJECT properties and create a hash table. + ${InputObject}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Query')] + [System.String] + # May be used to expand the properties within an export. + # Currently only 'runHistory' is supported and will return information for the last 10 executions of the export. + ${Expand}, + + [Parameter()] + [Alias('AzureRMContext', 'AzureCredential')] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Azure')] + [System.Management.Automation.PSObject] + # The credentials, account, tenant, and subscription used for communication with Azure. + ${DefaultProfile}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Wait for .NET debugger to attach + ${Break}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be appended to the front of the pipeline + ${HttpPipelineAppend}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be prepended to the front of the pipeline + ${HttpPipelinePrepend}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Uri] + # The URI for the proxy server to use + ${Proxy}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.PSCredential] + # Credentials for a proxy server to use for the remote call + ${ProxyCredential}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Use the default credentials for the proxy + ${ProxyUseDefaultCredentials} +) + +begin { + try { + $outBuffer = $null + if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer)) { + $PSBoundParameters['OutBuffer'] = 1 + } + $parameterSet = $PSCmdlet.ParameterSetName + $mapping = @{ + Get = 'Az.CostManagement.private\Get-AzCostManagementExport_Get'; + GetViaIdentity = 'Az.CostManagement.private\Get-AzCostManagementExport_GetViaIdentity'; + List = 'Az.CostManagement.private\Get-AzCostManagementExport_List'; + } + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet) + $scriptCmd = {& $wrappedCmd @PSBoundParameters} + $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin) + $steppablePipeline.Begin($PSCmdlet) + } catch { + throw + } +} + +process { + try { + $steppablePipeline.Process($_) + } catch { + throw + } +} + +end { + try { + $steppablePipeline.End() + } catch { + throw + } +} +} diff --git a/src/CostManagement/exports/Get-AzCostManagementExportExecutionHistory.ps1 b/src/CostManagement/exports/Get-AzCostManagementExportExecutionHistory.ps1 new file mode 100644 index 000000000000..9e12eaf98337 --- /dev/null +++ b/src/CostManagement/exports/Get-AzCostManagementExportExecutionHistory.ps1 @@ -0,0 +1,163 @@ + +# ---------------------------------------------------------------------------------- +# +# Copyright Microsoft Corporation +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ---------------------------------------------------------------------------------- + +<# +.Synopsis +The operation to get the execution history of an export for the defined scope and export name. +.Description +The operation to get the execution history of an export for the defined scope and export name. +.Example +PS C:\> Get-AzCostManagementExportExecutionHistory -ExportName 'TestExport' -Scope 'subscriptions/**********' + +ExecutionType ProcessingStartTime ProcessingEndTime Status FileName +------------- ------------------- ----------------- ------ -------- +Scheduled 2020/6/11 12:03:20 2020/6/11 12:03:43 Completed ad-hoc/TestExport/20200601-20200630/TestExport_00000000-0000-0000-0000-000000000000.csv +Scheduled 2020/6/12 12:03:37 2020/6/12 12:03:48 Completed ad-hoc/TestExport/20200601-20200630/TestExport_00000000-0000-0000-0000-000000000000.csv +.Example +PS C:\> $getExport = Get-AzCostManagementExport -Name 'TestExport' -Scope 'subscriptions/**********' +Get-AzCostManagementExportExecutionHistory -InputObject $getExport + +ExecutionType ProcessingStartTime ProcessingEndTime Status FileName +------------- ------------------- ----------------- ------ -------- +Scheduled 2020/6/11 12:03:20 2020/6/11 12:03:43 Completed ad-hoc/TestExport/20200601-20200630/TestExport_00000000-0000-0000-0000-000000000000.csv +Scheduled 2020/6/12 12:03:37 2020/6/12 12:03:48 Completed ad-hoc/TestExport/20200601-20200630/ + +.Inputs +Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity +.Outputs +Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution +.Notes +COMPLEX PARAMETER PROPERTIES + +To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables. + +INPUTOBJECT : Identity Parameter + [AlertId ]: Alert ID + [ExportName ]: Export Name. + [ExternalCloudProviderId ]: This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' for consolidated account used with dimension/query operations. + [ExternalCloudProviderType ]: The external cloud provider type associated with dimension/query operations. This includes 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated account. + [Id ]: Resource identity path + [Scope ]: The scope associated with view operations. This includes 'subscriptions/{subscriptionId}' for subscription scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for BillingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' for InvoiceSection scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope, 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for External Billing Account scope and 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for External Subscription scope. + [ViewName ]: View name +.Link +https://docs.microsoft.com/en-us/powershell/module/az.costmanagement/get-azcostmanagementexportexecutionhistory +#> +function Get-AzCostManagementExportExecutionHistory { +[OutputType([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution])] +[CmdletBinding(DefaultParameterSetName='Get', PositionalBinding=$false)] +param( + [Parameter(ParameterSetName='Get', Mandatory)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [System.String] + # Export Name. + ${ExportName}, + + [Parameter(ParameterSetName='Get', Mandatory)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [System.String] + # This parameter defines the scope of costmanagement from different perspectives 'Subscription','ResourceGroup' and 'Provide Service'. + ${Scope}, + + [Parameter(ParameterSetName='GetViaIdentity', Mandatory, ValueFromPipeline)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity] + # Identity Parameter + # To construct, see NOTES section for INPUTOBJECT properties and create a hash table. + ${InputObject}, + + [Parameter()] + [Alias('AzureRMContext', 'AzureCredential')] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Azure')] + [System.Management.Automation.PSObject] + # The credentials, account, tenant, and subscription used for communication with Azure. + ${DefaultProfile}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Wait for .NET debugger to attach + ${Break}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be appended to the front of the pipeline + ${HttpPipelineAppend}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be prepended to the front of the pipeline + ${HttpPipelinePrepend}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Uri] + # The URI for the proxy server to use + ${Proxy}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.PSCredential] + # Credentials for a proxy server to use for the remote call + ${ProxyCredential}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Use the default credentials for the proxy + ${ProxyUseDefaultCredentials} +) + +begin { + try { + $outBuffer = $null + if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer)) { + $PSBoundParameters['OutBuffer'] = 1 + } + $parameterSet = $PSCmdlet.ParameterSetName + $mapping = @{ + Get = 'Az.CostManagement.private\Get-AzCostManagementExportExecutionHistory_Get'; + GetViaIdentity = 'Az.CostManagement.private\Get-AzCostManagementExportExecutionHistory_GetViaIdentity'; + } + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet) + $scriptCmd = {& $wrappedCmd @PSBoundParameters} + $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin) + $steppablePipeline.Begin($PSCmdlet) + } catch { + throw + } +} + +process { + try { + $steppablePipeline.Process($_) + } catch { + throw + } +} + +end { + try { + $steppablePipeline.End() + } catch { + throw + } +} +} diff --git a/src/CostManagement/exports/Invoke-AzCostManagementExecuteExport.ps1 b/src/CostManagement/exports/Invoke-AzCostManagementExecuteExport.ps1 new file mode 100644 index 000000000000..a05512fe782d --- /dev/null +++ b/src/CostManagement/exports/Invoke-AzCostManagementExecuteExport.ps1 @@ -0,0 +1,161 @@ + +# ---------------------------------------------------------------------------------- +# +# Copyright Microsoft Corporation +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ---------------------------------------------------------------------------------- + +<# +.Synopsis +The operation to execute an export. +.Description +The operation to execute an export. +.Example +PS C:\> Invoke-AzCostManagementExecuteExport -ExportName 'TestExport' -Scope 'subscriptions/**********' + +.Example +PS C:\> $getExport = Get-AzCostManagementExport -Name 'TestExport' -Scope 'subscriptions/**********' +Invoke-AzCostManagementExecuteExport -InputObject $getExport + + +.Inputs +Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity +.Outputs +System.Boolean +.Notes +COMPLEX PARAMETER PROPERTIES + +To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables. + +INPUTOBJECT : Identity Parameter + [AlertId ]: Alert ID + [ExportName ]: Export Name. + [ExternalCloudProviderId ]: This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' for consolidated account used with dimension/query operations. + [ExternalCloudProviderType ]: The external cloud provider type associated with dimension/query operations. This includes 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated account. + [Id ]: Resource identity path + [Scope ]: The scope associated with view operations. This includes 'subscriptions/{subscriptionId}' for subscription scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for BillingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' for InvoiceSection scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope, 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for External Billing Account scope and 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for External Subscription scope. + [ViewName ]: View name +.Link +https://docs.microsoft.com/en-us/powershell/module/az.costmanagement/invoke-azcostmanagementexecuteexport +#> +function Invoke-AzCostManagementExecuteExport { +[OutputType([System.Boolean])] +[CmdletBinding(DefaultParameterSetName='Execute', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')] +param( + [Parameter(ParameterSetName='Execute', Mandatory)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [System.String] + # Export Name. + ${ExportName}, + + [Parameter(ParameterSetName='Execute', Mandatory)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [System.String] + # This parameter defines the scope of costmanagement from different perspectives 'Subscription','ResourceGroup' and 'Provide Service'. + ${Scope}, + + [Parameter(ParameterSetName='ExecuteViaIdentity', Mandatory, ValueFromPipeline)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity] + # Identity Parameter + # To construct, see NOTES section for INPUTOBJECT properties and create a hash table. + ${InputObject}, + + [Parameter()] + [Alias('AzureRMContext', 'AzureCredential')] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Azure')] + [System.Management.Automation.PSObject] + # The credentials, account, tenant, and subscription used for communication with Azure. + ${DefaultProfile}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Wait for .NET debugger to attach + ${Break}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be appended to the front of the pipeline + ${HttpPipelineAppend}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be prepended to the front of the pipeline + ${HttpPipelinePrepend}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Returns true when the command succeeds + ${PassThru}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Uri] + # The URI for the proxy server to use + ${Proxy}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.PSCredential] + # Credentials for a proxy server to use for the remote call + ${ProxyCredential}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Use the default credentials for the proxy + ${ProxyUseDefaultCredentials} +) + +begin { + try { + $outBuffer = $null + if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer)) { + $PSBoundParameters['OutBuffer'] = 1 + } + $parameterSet = $PSCmdlet.ParameterSetName + $mapping = @{ + Execute = 'Az.CostManagement.private\Invoke-AzCostManagementExecuteExport_Execute'; + ExecuteViaIdentity = 'Az.CostManagement.private\Invoke-AzCostManagementExecuteExport_ExecuteViaIdentity'; + } + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet) + $scriptCmd = {& $wrappedCmd @PSBoundParameters} + $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin) + $steppablePipeline.Begin($PSCmdlet) + } catch { + throw + } +} + +process { + try { + $steppablePipeline.Process($_) + } catch { + throw + } +} + +end { + try { + $steppablePipeline.End() + } catch { + throw + } +} +} diff --git a/src/CostManagement/exports/Invoke-AzCostManagementQuery.ps1 b/src/CostManagement/exports/Invoke-AzCostManagementQuery.ps1 new file mode 100644 index 000000000000..132efb3dbe01 --- /dev/null +++ b/src/CostManagement/exports/Invoke-AzCostManagementQuery.ps1 @@ -0,0 +1,226 @@ + +# ---------------------------------------------------------------------------------- +# +# Copyright Microsoft Corporation +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ---------------------------------------------------------------------------------- + +<# +.Synopsis +Query the usage data for scope defined. +.Description +Query the usage data for scope defined. +.Example +PS C:\> Invoke-AzCostManagementQuery -Scope "/subscriptions/***********" -Timeframe MonthToDate -Type Usage -DatasetGranularity 'Daily' + +Column Row +------ --- +{UsageDate, Currency} {20201101 USD, 20201102 USD, 20201103 USD, 20201104 USD…} +.Example +PS C:\> $dimensions = New-AzCostManagementQueryComparisonExpressionObject -Name 'ResourceGroup' -Operator 'In' -Value 'API' +$filter = New-AzCostManagementQueryFilterObject -Dimensions $dimensions +Invoke-AzCostManagementQuery -Type Usage -Scope "subscriptions/***********" -DatasetGranularity 'Monthly' -DatasetFilter $filter -Timeframe MonthToDate -Debug + + +Column Row +------ --- +{BillingMonth, Currency} {} + +.Outputs +Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryResult +.Notes +COMPLEX PARAMETER PROPERTIES + +To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables. + +DATASETFILTER : Has filter expression to use in the query. + [And ]: The logical "AND" expression. Must have at least 2 items. + [Dimensions ]: Has comparison expression for a dimension + Name : The name of the column to use in comparison. + Operator : The operator to use for comparison. + Value : Array of values to use for comparison + [Not ]: The logical "NOT" expression. + [Or ]: The logical "OR" expression. Must have at least 2 items. + [Tag ]: Has comparison expression for a tag + +DATASETGROUPING : Array of group by expression to use in the query. + Name : The name of the column to group. + Type : Has type of the column to group. +.Link +https://docs.microsoft.com/en-us/powershell/module/az.costmanagement/invoke-azcostmanagementquery +#> +function Invoke-AzCostManagementQuery { +[OutputType([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryResult])] +[CmdletBinding(DefaultParameterSetName='UsageExpanded', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')] +param( + [Parameter(ParameterSetName='UsageExpanded', Mandatory)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [System.String] + # This includes 'subscriptions/{subscriptionId}/' for subscription scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId} for Management Group scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' for invoiceSection scope, and 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' specific for partners. + ${Scope}, + + [Parameter(ParameterSetName='UsageExpanded1', Mandatory)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [System.String] + # This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' for consolidated account used with dimension/query operations. + ${ExternalCloudProviderId}, + + [Parameter(ParameterSetName='UsageExpanded1', Mandatory)] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExternalCloudProviderType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExternalCloudProviderType] + # The external cloud provider type associated with dimension/query operations. + ${ExternalCloudProviderType}, + + [Parameter(Mandatory)] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType] + # The time frame for pulling data for the query. + ${Timeframe}, + + [Parameter(Mandatory)] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType] + # The type of the query. + ${Type}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String[]] + # Array of column names to be included in the query. + ${ConfigurationColumn}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info(PossibleTypes=([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetAggregation]))] + [System.Collections.Hashtable] + # Dictionary of aggregation expression to use in the query. + ${DatasetAggregation}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter] + # Has filter expression to use in the query. + # To construct, see NOTES section for DATASETFILTER properties and create a hash table. + ${DatasetFilter}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType] + # The granularity of rows in the query. + ${DatasetGranularity}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryGrouping[]] + # Array of group by expression to use in the query. + # To construct, see NOTES section for DATASETGROUPING properties and create a hash table. + ${DatasetGrouping}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.DateTime] + # The start date to pull data from. + ${TimePeriodFrom}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.DateTime] + # The end date to pull data to. + ${TimePeriodTo}, + + [Parameter()] + [Alias('AzureRMContext', 'AzureCredential')] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Azure')] + [System.Management.Automation.PSObject] + # The credentials, account, tenant, and subscription used for communication with Azure. + ${DefaultProfile}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Wait for .NET debugger to attach + ${Break}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be appended to the front of the pipeline + ${HttpPipelineAppend}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be prepended to the front of the pipeline + ${HttpPipelinePrepend}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Uri] + # The URI for the proxy server to use + ${Proxy}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.PSCredential] + # Credentials for a proxy server to use for the remote call + ${ProxyCredential}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Use the default credentials for the proxy + ${ProxyUseDefaultCredentials} +) + +begin { + try { + $outBuffer = $null + if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer)) { + $PSBoundParameters['OutBuffer'] = 1 + } + $parameterSet = $PSCmdlet.ParameterSetName + $mapping = @{ + UsageExpanded = 'Az.CostManagement.custom\Invoke-AzCostManagementQuery'; + UsageExpanded1 = 'Az.CostManagement.custom\Invoke-AzCostManagementQuery'; + } + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet) + $scriptCmd = {& $wrappedCmd @PSBoundParameters} + $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin) + $steppablePipeline.Begin($PSCmdlet) + } catch { + throw + } +} + +process { + try { + $steppablePipeline.Process($_) + } catch { + throw + } +} + +end { + try { + $steppablePipeline.End() + } catch { + throw + } +} +} diff --git a/src/CostManagement/exports/New-AzCostManagementExport.ps1 b/src/CostManagement/exports/New-AzCostManagementExport.ps1 new file mode 100644 index 000000000000..09831083be90 --- /dev/null +++ b/src/CostManagement/exports/New-AzCostManagementExport.ps1 @@ -0,0 +1,241 @@ + +# ---------------------------------------------------------------------------------- +# +# Copyright Microsoft Corporation +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ---------------------------------------------------------------------------------- + +<# +.Synopsis +The operation to create or update a export. +Update operation requires latest eTag to be set in the request. +You may obtain the latest eTag by performing a get operation. +Create operation does not require eTag. +.Description +The operation to create or update a export. +Update operation requires latest eTag to be set in the request. +You may obtain the latest eTag by performing a get operation. +Create operation does not require eTag. +.Example +PS C:\> New-AzCostManagementExport -Scope "subscriptions/***********" -Name "CostManagementExportTest" -ScheduleStatus "Active" -ScheduleRecurrence "Daily" -RecurrencePeriodFrom "2020-10-31T20:00:00Z" -RecurrencePeriodTo "2020-11-30T00:00:00Z" -Format "Csv" -DestinationResourceId "/subscriptions/*************/resourceGroups/ResourceGroupTest/providers/Microsoft.Storage/storageAccounts/storageAccountTest" ` -DestinationContainer "exports" -DestinationRootFolderPath "ad-hoc" -DefinitionType "Usage" -DefinitionTimeframe "MonthToDate" -DatasetGranularity "Daily" + +ETag Name Type +---- ---- ---- +"********" TestExportDatasetAggregationInfosagdhaghj Microsoft.CostManagement/exports + +.Outputs +Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport +.Link +https://docs.microsoft.com/en-us/powershell/module/az.costmanagement/new-azcostmanagementexport +#> +function New-AzCostManagementExport { +[OutputType([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport])] +[CmdletBinding(DefaultParameterSetName='CreateExpanded', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')] +param( + [Parameter(Mandatory)] + [Alias('ExportName')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [System.String] + # Export Name. + ${Name}, + + [Parameter(Mandatory)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [System.String] + # This parameter defines the scope of costmanagement from different perspectives 'Subscription','ResourceGroup' and 'Provide Service'. + ${Scope}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String[]] + # Array of column names to be included in the export. + # If not provided then the export will include all available columns. + # The available columns can vary by customer channel (see examples). + ${ConfigurationColumn}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType] + # The granularity of rows in the export. + # Currently only 'Daily' is supported. + ${DataSetGranularity}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType] + # The time frame for pulling data for the export. + # If custom, then a specific time period must be provided. + ${DefinitionTimeframe}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType] + # The type of the export. + # Note that 'Usage' is equivalent to 'ActualCost' and is applicable to exports that do not yet provide data for charges or amortization for service reservations. + ${DefinitionType}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String] + # The name of the container where exports will be uploaded. + ${DestinationContainer}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String] + # The resource id of the storage account where exports will be delivered. + ${DestinationResourceId}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String] + # The name of the directory where exports will be uploaded. + ${DestinationRootFolderPath}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType] + # [Parameter()] + # [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + # [System.String] + # # eTag of the resource. + # # To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not. + # ${ETag}, + # The format of the export being delivered. + # Currently only 'Csv' is supported. + ${Format}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.DateTime] + # The start date of recurrence. + ${RecurrencePeriodFrom}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.DateTime] + # The end date of recurrence. + ${RecurrencePeriodTo}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType] + # The schedule recurrence. + ${ScheduleRecurrence}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType] + # The status of the export's schedule. + # If 'Inactive', the export's schedule is paused. + ${ScheduleStatus}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.DateTime] + # The start date for export data. + ${TimePeriodFrom}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.DateTime] + # The end date for export data. + ${TimePeriodTo}, + + [Parameter()] + [Alias('AzureRMContext', 'AzureCredential')] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Azure')] + [System.Management.Automation.PSObject] + # The credentials, account, tenant, and subscription used for communication with Azure. + ${DefaultProfile}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Wait for .NET debugger to attach + ${Break}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be appended to the front of the pipeline + ${HttpPipelineAppend}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be prepended to the front of the pipeline + ${HttpPipelinePrepend}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Uri] + # The URI for the proxy server to use + ${Proxy}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.PSCredential] + # Credentials for a proxy server to use for the remote call + ${ProxyCredential}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Use the default credentials for the proxy + ${ProxyUseDefaultCredentials} +) + +begin { + try { + $outBuffer = $null + if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer)) { + $PSBoundParameters['OutBuffer'] = 1 + } + $parameterSet = $PSCmdlet.ParameterSetName + $mapping = @{ + CreateExpanded = 'Az.CostManagement.custom\New-AzCostManagementExport'; + } + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet) + $scriptCmd = {& $wrappedCmd @PSBoundParameters} + $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin) + $steppablePipeline.Begin($PSCmdlet) + } catch { + throw + } +} + +process { + try { + $steppablePipeline.Process($_) + } catch { + throw + } +} + +end { + try { + $steppablePipeline.End() + } catch { + throw + } +} +} diff --git a/src/CostManagement/exports/New-AzCostManagementQueryComparisonExpressionObject.ps1 b/src/CostManagement/exports/New-AzCostManagementQueryComparisonExpressionObject.ps1 new file mode 100644 index 000000000000..195ef91a0c40 --- /dev/null +++ b/src/CostManagement/exports/New-AzCostManagementQueryComparisonExpressionObject.ps1 @@ -0,0 +1,90 @@ + +# ---------------------------------------------------------------------------------- +# +# Copyright Microsoft Corporation +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ---------------------------------------------------------------------------------- + +<# +.Synopsis +Create a in-memory object for QueryComparisonExpression +.Description +Create a in-memory object for QueryComparisonExpression +.Example +PS C:\> New-AzCostManagementQueryComparisonExpressionObject -Name 'ResourceLocation' -Operator In -Value @('East US', 'West Europe') + +Name Operator Value +---- -------- ----- +ResourceLocation In {East US, West Europe} + +.Outputs +Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryComparisonExpression +.Link +https://docs.microsoft.com/en-us/powershell/module/az.CostManagement/new-AzCostManagementQueryComparisonExpressionObject +#> +function New-AzCostManagementQueryComparisonExpressionObject { +[OutputType([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryComparisonExpression])] +[CmdletBinding(PositionalBinding=$false)] +param( + [Parameter(Mandatory)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String] + # The name of the column to use in comparison. + ${Name}, + + [Parameter(Mandatory)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.OperatorType] + # The operator to use for comparison. + ${Operator}, + + [Parameter(Mandatory)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String[]] + # Array of values to use for comparison. + ${Value} +) + +begin { + try { + $outBuffer = $null + if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer)) { + $PSBoundParameters['OutBuffer'] = 1 + } + $parameterSet = $PSCmdlet.ParameterSetName + $mapping = @{ + __AllParameterSets = 'Az.CostManagement.custom\New-AzCostManagementQueryComparisonExpressionObject'; + } + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet) + $scriptCmd = {& $wrappedCmd @PSBoundParameters} + $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin) + $steppablePipeline.Begin($PSCmdlet) + } catch { + throw + } +} + +process { + try { + $steppablePipeline.Process($_) + } catch { + throw + } +} + +end { + try { + $steppablePipeline.End() + } catch { + throw + } +} +} diff --git a/src/CostManagement/exports/New-AzCostManagementQueryFilterObject.ps1 b/src/CostManagement/exports/New-AzCostManagementQueryFilterObject.ps1 new file mode 100644 index 000000000000..1325caa84c00 --- /dev/null +++ b/src/CostManagement/exports/New-AzCostManagementQueryFilterObject.ps1 @@ -0,0 +1,157 @@ + +# ---------------------------------------------------------------------------------- +# +# Copyright Microsoft Corporation +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ---------------------------------------------------------------------------------- + +<# +.Synopsis +Create a in-memory object for QueryFilter +.Description +Create a in-memory object for QueryFilter +.Example +PS C:\> $orDimension = New-AzCostManagementQueryComparisonExpressionObject -Name 'ResourceLocation' -Operator In -Value @('East US', 'West Europe') +PS C:\> $orTag = New-AzCostManagementQueryComparisonExpressionObject -Name 'Environment' -Operator In -Value @('UAT', 'Prod') +PS C:\> New-AzCostManagementQueryFilterObject -or @((New-AzCostManagementQueryFilterObject -Dimension $orDimension), (New-AzCostManagementQueryFilterObject -Tag $orTag)) + +And : +Dimension : Microsoft.Azure.PowerShell.Cmdlets.Cost.Models.Api20200601.QueryComparisonExpression +Not : Microsoft.Azure.PowerShell.Cmdlets.Cost.Models.Api20200601.QueryFilter +Or : {Microsoft.Azure.PowerShell.Cmdlets.Cost.Models.Api20200601.QueryFilter, Microsoft.Azure.PowerShell.Cmdlets.Cost.Models.Api20200601.QueryFilter} +Tag : Microsoft.Azure.PowerShell.Cmdlets.Cost.Models.Api20200601.QueryComparisonExpression + +.Outputs +Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryFilter +.Notes +COMPLEX PARAMETER PROPERTIES + +To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables. + +AND : The logical "AND" expression. Must have at least 2 items. + [And ]: The logical "AND" expression. Must have at least 2 items. + [Dimensions ]: Has comparison expression for a dimension + Name : The name of the column to use in comparison. + Operator : The operator to use for comparison. + Value : Array of values to use for comparison + [Not ]: The logical "NOT" expression. + [Or ]: The logical "OR" expression. Must have at least 2 items. + [Tag ]: Has comparison expression for a tag + +DIMENSIONS : Has comparison expression for a dimensions. + Name : The name of the column to use in comparison. + Operator : The operator to use for comparison. + Value : Array of values to use for comparison + +NOT : The logical "NOT" expression. + [And ]: The logical "AND" expression. Must have at least 2 items. + [Dimensions ]: Has comparison expression for a dimension + Name : The name of the column to use in comparison. + Operator : The operator to use for comparison. + Value : Array of values to use for comparison + [Not ]: The logical "NOT" expression. + [Or ]: The logical "OR" expression. Must have at least 2 items. + [Tag ]: Has comparison expression for a tag + +OR : The logical "OR" expression. Must have at least 2 items. + [And ]: The logical "AND" expression. Must have at least 2 items. + [Dimensions ]: Has comparison expression for a dimension + Name : The name of the column to use in comparison. + Operator : The operator to use for comparison. + Value : Array of values to use for comparison + [Not ]: The logical "NOT" expression. + [Or ]: The logical "OR" expression. Must have at least 2 items. + [Tag ]: Has comparison expression for a tag + +TAG : Has comparison expression for a tag. + Name : The name of the column to use in comparison. + Operator : The operator to use for comparison. + Value : Array of values to use for comparison +.Link +https://docs.microsoft.com/en-us/powershell/module/az.CostManagement/new-AzCostManagementQueryFilterObject +#> +function New-AzCostManagementQueryFilterObject { +[OutputType([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryFilter])] +[CmdletBinding(PositionalBinding=$false)] +param( + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter[]] + # The logical "AND" expression. + # Must have at least 2 items. + # To construct, see NOTES section for AND properties and create a hash table. + ${And}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryComparisonExpression] + # Has comparison expression for a dimensions. + # To construct, see NOTES section for DIMENSIONS properties and create a hash table. + ${Dimensions}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter] + # The logical "NOT" expression. + # To construct, see NOTES section for NOT properties and create a hash table. + ${Not}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter[]] + # The logical "OR" expression. + # Must have at least 2 items. + # To construct, see NOTES section for OR properties and create a hash table. + ${Or}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryComparisonExpression] + # Has comparison expression for a tag. + # To construct, see NOTES section for TAG properties and create a hash table. + ${Tag} +) + +begin { + try { + $outBuffer = $null + if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer)) { + $PSBoundParameters['OutBuffer'] = 1 + } + $parameterSet = $PSCmdlet.ParameterSetName + $mapping = @{ + __AllParameterSets = 'Az.CostManagement.custom\New-AzCostManagementQueryFilterObject'; + } + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet) + $scriptCmd = {& $wrappedCmd @PSBoundParameters} + $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin) + $steppablePipeline.Begin($PSCmdlet) + } catch { + throw + } +} + +process { + try { + $steppablePipeline.Process($_) + } catch { + throw + } +} + +end { + try { + $steppablePipeline.End() + } catch { + throw + } +} +} diff --git a/src/CostManagement/exports/ProxyCmdletDefinitions.ps1 b/src/CostManagement/exports/ProxyCmdletDefinitions.ps1 new file mode 100644 index 000000000000..6608e60d4f57 --- /dev/null +++ b/src/CostManagement/exports/ProxyCmdletDefinitions.ps1 @@ -0,0 +1,1646 @@ + +# ---------------------------------------------------------------------------------- +# +# Copyright Microsoft Corporation +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ---------------------------------------------------------------------------------- + +<# +.Synopsis +The operation to get the execution history of an export for the defined scope and export name. +.Description +The operation to get the execution history of an export for the defined scope and export name. +.Example +PS C:\> Get-AzCostManagementExportExecutionHistory -ExportName 'TestExport' -Scope 'subscriptions/**********' + +ExecutionType ProcessingStartTime ProcessingEndTime Status FileName +------------- ------------------- ----------------- ------ -------- +Scheduled 2020/6/11 12:03:20 2020/6/11 12:03:43 Completed ad-hoc/TestExport/20200601-20200630/TestExport_00000000-0000-0000-0000-000000000000.csv +Scheduled 2020/6/12 12:03:37 2020/6/12 12:03:48 Completed ad-hoc/TestExport/20200601-20200630/TestExport_00000000-0000-0000-0000-000000000000.csv +.Example +PS C:\> $getExport = Get-AzCostManagementExport -Name 'TestExport' -Scope 'subscriptions/**********' +Get-AzCostManagementExportExecutionHistory -InputObject $getExport + +ExecutionType ProcessingStartTime ProcessingEndTime Status FileName +------------- ------------------- ----------------- ------ -------- +Scheduled 2020/6/11 12:03:20 2020/6/11 12:03:43 Completed ad-hoc/TestExport/20200601-20200630/TestExport_00000000-0000-0000-0000-000000000000.csv +Scheduled 2020/6/12 12:03:37 2020/6/12 12:03:48 Completed ad-hoc/TestExport/20200601-20200630/ + +.Inputs +Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity +.Outputs +Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution +.Notes +COMPLEX PARAMETER PROPERTIES + +To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables. + +INPUTOBJECT : Identity Parameter + [AlertId ]: Alert ID + [ExportName ]: Export Name. + [ExternalCloudProviderId ]: This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' for consolidated account used with dimension/query operations. + [ExternalCloudProviderType ]: The external cloud provider type associated with dimension/query operations. This includes 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated account. + [Id ]: Resource identity path + [Scope ]: The scope associated with view operations. This includes 'subscriptions/{subscriptionId}' for subscription scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for BillingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' for InvoiceSection scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope, 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for External Billing Account scope and 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for External Subscription scope. + [ViewName ]: View name +.Link +https://docs.microsoft.com/en-us/powershell/module/az.costmanagement/get-azcostmanagementexportexecutionhistory +#> +function Get-AzCostManagementExportExecutionHistory { +[OutputType([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution])] +[CmdletBinding(DefaultParameterSetName='Get', PositionalBinding=$false)] +param( + [Parameter(ParameterSetName='Get', Mandatory)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [System.String] + # Export Name. + ${ExportName}, + + [Parameter(ParameterSetName='Get', Mandatory)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [System.String] + # This parameter defines the scope of costmanagement from different perspectives 'Subscription','ResourceGroup' and 'Provide Service'. + ${Scope}, + + [Parameter(ParameterSetName='GetViaIdentity', Mandatory, ValueFromPipeline)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity] + # Identity Parameter + # To construct, see NOTES section for INPUTOBJECT properties and create a hash table. + ${InputObject}, + + [Parameter()] + [Alias('AzureRMContext', 'AzureCredential')] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Azure')] + [System.Management.Automation.PSObject] + # The credentials, account, tenant, and subscription used for communication with Azure. + ${DefaultProfile}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Wait for .NET debugger to attach + ${Break}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be appended to the front of the pipeline + ${HttpPipelineAppend}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be prepended to the front of the pipeline + ${HttpPipelinePrepend}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Uri] + # The URI for the proxy server to use + ${Proxy}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.PSCredential] + # Credentials for a proxy server to use for the remote call + ${ProxyCredential}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Use the default credentials for the proxy + ${ProxyUseDefaultCredentials} +) + +begin { + try { + $outBuffer = $null + if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer)) { + $PSBoundParameters['OutBuffer'] = 1 + } + $parameterSet = $PSCmdlet.ParameterSetName + $mapping = @{ + Get = 'Az.CostManagement.private\Get-AzCostManagementExportExecutionHistory_Get'; + GetViaIdentity = 'Az.CostManagement.private\Get-AzCostManagementExportExecutionHistory_GetViaIdentity'; + } + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet) + $scriptCmd = {& $wrappedCmd @PSBoundParameters} + $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin) + $steppablePipeline.Begin($PSCmdlet) + } catch { + throw + } +} + +process { + try { + $steppablePipeline.Process($_) + } catch { + throw + } +} + +end { + try { + $steppablePipeline.End() + } catch { + throw + } +} +} + +# ---------------------------------------------------------------------------------- +# +# Copyright Microsoft Corporation +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ---------------------------------------------------------------------------------- + +<# +.Synopsis +The operation to get the export for the defined scope by export name. +.Description +The operation to get the export for the defined scope by export name. +.Example +PS C:\> Get-AzCostManagementExport -Scope 'subscriptions/**********' + +ETag Name Type +---- ---- ---- +"************" TestExport Microsoft.CostManagement/exports +"************" TestExport1 Microsoft.CostManagement/exports +"************" TestExport2 Microsoft.CostManagement/exports +.Example +PS C:\> Get-AzCostManagementExport -Name 'TestExport' -Scope 'subscriptions/**********' + +ETag Name Type +---- ---- ---- +"************" TestExport Microsoft.CostManagement/exports + +.Inputs +Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity +.Outputs +Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport +.Notes +COMPLEX PARAMETER PROPERTIES + +To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables. + +INPUTOBJECT : Identity Parameter + [AlertId ]: Alert ID + [ExportName ]: Export Name. + [ExternalCloudProviderId ]: This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' for consolidated account used with dimension/query operations. + [ExternalCloudProviderType ]: The external cloud provider type associated with dimension/query operations. This includes 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated account. + [Id ]: Resource identity path + [Scope ]: The scope associated with view operations. This includes 'subscriptions/{subscriptionId}' for subscription scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for BillingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' for InvoiceSection scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope, 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for External Billing Account scope and 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for External Subscription scope. + [ViewName ]: View name +.Link +https://docs.microsoft.com/en-us/powershell/module/az.costmanagement/get-azcostmanagementexport +#> +function Get-AzCostManagementExport { +[OutputType([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport])] +[CmdletBinding(DefaultParameterSetName='List', PositionalBinding=$false)] +param( + [Parameter(ParameterSetName='Get', Mandatory)] + [Alias('ExportName')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [System.String] + # Export Name. + ${Name}, + + [Parameter(ParameterSetName='Get', Mandatory)] + [Parameter(ParameterSetName='List', Mandatory)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [System.String] + # This parameter defines the scope of costmanagement from different perspectives 'Subscription','ResourceGroup' and 'Provide Service'. + ${Scope}, + + [Parameter(ParameterSetName='GetViaIdentity', Mandatory, ValueFromPipeline)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity] + # Identity Parameter + # To construct, see NOTES section for INPUTOBJECT properties and create a hash table. + ${InputObject}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Query')] + [System.String] + # May be used to expand the properties within an export. + # Currently only 'runHistory' is supported and will return information for the last 10 executions of the export. + ${Expand}, + + [Parameter()] + [Alias('AzureRMContext', 'AzureCredential')] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Azure')] + [System.Management.Automation.PSObject] + # The credentials, account, tenant, and subscription used for communication with Azure. + ${DefaultProfile}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Wait for .NET debugger to attach + ${Break}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be appended to the front of the pipeline + ${HttpPipelineAppend}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be prepended to the front of the pipeline + ${HttpPipelinePrepend}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Uri] + # The URI for the proxy server to use + ${Proxy}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.PSCredential] + # Credentials for a proxy server to use for the remote call + ${ProxyCredential}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Use the default credentials for the proxy + ${ProxyUseDefaultCredentials} +) + +begin { + try { + $outBuffer = $null + if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer)) { + $PSBoundParameters['OutBuffer'] = 1 + } + $parameterSet = $PSCmdlet.ParameterSetName + $mapping = @{ + Get = 'Az.CostManagement.private\Get-AzCostManagementExport_Get'; + GetViaIdentity = 'Az.CostManagement.private\Get-AzCostManagementExport_GetViaIdentity'; + List = 'Az.CostManagement.private\Get-AzCostManagementExport_List'; + } + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet) + $scriptCmd = {& $wrappedCmd @PSBoundParameters} + $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin) + $steppablePipeline.Begin($PSCmdlet) + } catch { + throw + } +} + +process { + try { + $steppablePipeline.Process($_) + } catch { + throw + } +} + +end { + try { + $steppablePipeline.End() + } catch { + throw + } +} +} + +# ---------------------------------------------------------------------------------- +# +# Copyright Microsoft Corporation +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ---------------------------------------------------------------------------------- + +<# +.Synopsis +The operation to execute an export. +.Description +The operation to execute an export. +.Example +PS C:\> Invoke-AzCostManagementExecuteExport -ExportName 'TestExport' -Scope 'subscriptions/**********' + +.Example +PS C:\> $getExport = Get-AzCostManagementExport -Name 'TestExport' -Scope 'subscriptions/**********' +Invoke-AzCostManagementExecuteExport -InputObject $getExport + + +.Inputs +Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity +.Outputs +System.Boolean +.Notes +COMPLEX PARAMETER PROPERTIES + +To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables. + +INPUTOBJECT : Identity Parameter + [AlertId ]: Alert ID + [ExportName ]: Export Name. + [ExternalCloudProviderId ]: This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' for consolidated account used with dimension/query operations. + [ExternalCloudProviderType ]: The external cloud provider type associated with dimension/query operations. This includes 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated account. + [Id ]: Resource identity path + [Scope ]: The scope associated with view operations. This includes 'subscriptions/{subscriptionId}' for subscription scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for BillingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' for InvoiceSection scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope, 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for External Billing Account scope and 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for External Subscription scope. + [ViewName ]: View name +.Link +https://docs.microsoft.com/en-us/powershell/module/az.costmanagement/invoke-azcostmanagementexecuteexport +#> +function Invoke-AzCostManagementExecuteExport { +[OutputType([System.Boolean])] +[CmdletBinding(DefaultParameterSetName='Execute', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')] +param( + [Parameter(ParameterSetName='Execute', Mandatory)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [System.String] + # Export Name. + ${ExportName}, + + [Parameter(ParameterSetName='Execute', Mandatory)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [System.String] + # This parameter defines the scope of costmanagement from different perspectives 'Subscription','ResourceGroup' and 'Provide Service'. + ${Scope}, + + [Parameter(ParameterSetName='ExecuteViaIdentity', Mandatory, ValueFromPipeline)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity] + # Identity Parameter + # To construct, see NOTES section for INPUTOBJECT properties and create a hash table. + ${InputObject}, + + [Parameter()] + [Alias('AzureRMContext', 'AzureCredential')] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Azure')] + [System.Management.Automation.PSObject] + # The credentials, account, tenant, and subscription used for communication with Azure. + ${DefaultProfile}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Wait for .NET debugger to attach + ${Break}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be appended to the front of the pipeline + ${HttpPipelineAppend}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be prepended to the front of the pipeline + ${HttpPipelinePrepend}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Returns true when the command succeeds + ${PassThru}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Uri] + # The URI for the proxy server to use + ${Proxy}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.PSCredential] + # Credentials for a proxy server to use for the remote call + ${ProxyCredential}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Use the default credentials for the proxy + ${ProxyUseDefaultCredentials} +) + +begin { + try { + $outBuffer = $null + if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer)) { + $PSBoundParameters['OutBuffer'] = 1 + } + $parameterSet = $PSCmdlet.ParameterSetName + $mapping = @{ + Execute = 'Az.CostManagement.private\Invoke-AzCostManagementExecuteExport_Execute'; + ExecuteViaIdentity = 'Az.CostManagement.private\Invoke-AzCostManagementExecuteExport_ExecuteViaIdentity'; + } + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet) + $scriptCmd = {& $wrappedCmd @PSBoundParameters} + $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin) + $steppablePipeline.Begin($PSCmdlet) + } catch { + throw + } +} + +process { + try { + $steppablePipeline.Process($_) + } catch { + throw + } +} + +end { + try { + $steppablePipeline.End() + } catch { + throw + } +} +} + +# ---------------------------------------------------------------------------------- +# +# Copyright Microsoft Corporation +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ---------------------------------------------------------------------------------- + +<# +.Synopsis +The operation to delete a export. +.Description +The operation to delete a export. +.Example +PS C:\> Remove-AzCostManagementExport -Scope 'subscriptions/********' -name 'TestExportDatasetAggregationInfoYouri' + + +.Example +PS C:\> $getExport = Get-AzCostManagementExport -Scope 'subscriptions/*********' -name 'TestExportDatasetAggregationYouori' +Remove-AzCostManagementExport -InputObject $getExport + + + +.Inputs +Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity +.Outputs +System.Boolean +.Notes +COMPLEX PARAMETER PROPERTIES + +To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables. + +INPUTOBJECT : Identity Parameter + [AlertId ]: Alert ID + [ExportName ]: Export Name. + [ExternalCloudProviderId ]: This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' for consolidated account used with dimension/query operations. + [ExternalCloudProviderType ]: The external cloud provider type associated with dimension/query operations. This includes 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated account. + [Id ]: Resource identity path + [Scope ]: The scope associated with view operations. This includes 'subscriptions/{subscriptionId}' for subscription scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for BillingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' for InvoiceSection scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope, 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for External Billing Account scope and 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for External Subscription scope. + [ViewName ]: View name +.Link +https://docs.microsoft.com/en-us/powershell/module/az.costmanagement/remove-azcostmanagementexport +#> +function Remove-AzCostManagementExport { +[OutputType([System.Boolean])] +[CmdletBinding(DefaultParameterSetName='Delete', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')] +param( + [Parameter(ParameterSetName='Delete', Mandatory)] + [Alias('ExportName')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [System.String] + # Export Name. + ${Name}, + + [Parameter(ParameterSetName='Delete', Mandatory)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [System.String] + # This parameter defines the scope of costmanagement from different perspectives 'Subscription','ResourceGroup' and 'Provide Service'. + ${Scope}, + + [Parameter(ParameterSetName='DeleteViaIdentity', Mandatory, ValueFromPipeline)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity] + # Identity Parameter + # To construct, see NOTES section for INPUTOBJECT properties and create a hash table. + ${InputObject}, + + [Parameter()] + [Alias('AzureRMContext', 'AzureCredential')] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Azure')] + [System.Management.Automation.PSObject] + # The credentials, account, tenant, and subscription used for communication with Azure. + ${DefaultProfile}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Wait for .NET debugger to attach + ${Break}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be appended to the front of the pipeline + ${HttpPipelineAppend}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be prepended to the front of the pipeline + ${HttpPipelinePrepend}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Returns true when the command succeeds + ${PassThru}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Uri] + # The URI for the proxy server to use + ${Proxy}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.PSCredential] + # Credentials for a proxy server to use for the remote call + ${ProxyCredential}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Use the default credentials for the proxy + ${ProxyUseDefaultCredentials} +) + +begin { + try { + $outBuffer = $null + if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer)) { + $PSBoundParameters['OutBuffer'] = 1 + } + $parameterSet = $PSCmdlet.ParameterSetName + $mapping = @{ + Delete = 'Az.CostManagement.private\Remove-AzCostManagementExport_Delete'; + DeleteViaIdentity = 'Az.CostManagement.private\Remove-AzCostManagementExport_DeleteViaIdentity'; + } + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet) + $scriptCmd = {& $wrappedCmd @PSBoundParameters} + $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin) + $steppablePipeline.Begin($PSCmdlet) + } catch { + throw + } +} + +process { + try { + $steppablePipeline.Process($_) + } catch { + throw + } +} + +end { + try { + $steppablePipeline.End() + } catch { + throw + } +} +} + +# ---------------------------------------------------------------------------------- +# +# Copyright Microsoft Corporation +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ---------------------------------------------------------------------------------- + +<# +.Synopsis +Query the usage data for scope defined. +.Description +Query the usage data for scope defined. +.Example +PS C:\> Invoke-AzCostManagementQuery -Scope "/subscriptions/***********" -Timeframe MonthToDate -Type Usage -DatasetGranularity 'Daily' + +Column Row +------ --- +{UsageDate, Currency} {20201101 USD, 20201102 USD, 20201103 USD, 20201104 USD…} +.Example +PS C:\> $dimensions = New-AzCostManagementQueryComparisonExpressionObject -Name 'ResourceGroup' -Operator 'In' -Value 'API' +$filter = New-AzCostManagementQueryFilterObject -Dimensions $dimensions +Invoke-AzCostManagementQuery -Type Usage -Scope "subscriptions/***********" -DatasetGranularity 'Monthly' -DatasetFilter $filter -Timeframe MonthToDate -Debug + + +Column Row +------ --- +{BillingMonth, Currency} {} + +.Outputs +Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryResult +.Notes +COMPLEX PARAMETER PROPERTIES + +To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables. + +DATASETFILTER : Has filter expression to use in the query. + [And ]: The logical "AND" expression. Must have at least 2 items. + [Dimensions ]: Has comparison expression for a dimension + Name : The name of the column to use in comparison. + Operator : The operator to use for comparison. + Value : Array of values to use for comparison + [Not ]: The logical "NOT" expression. + [Or ]: The logical "OR" expression. Must have at least 2 items. + [Tag ]: Has comparison expression for a tag + +DATASETGROUPING : Array of group by expression to use in the query. + Name : The name of the column to group. + Type : Has type of the column to group. +.Link +https://docs.microsoft.com/en-us/powershell/module/az.costmanagement/invoke-azcostmanagementquery +#> +function Invoke-AzCostManagementQuery { +[OutputType([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryResult])] +[CmdletBinding(DefaultParameterSetName='UsageExpanded', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')] +param( + [Parameter(ParameterSetName='UsageExpanded', Mandatory)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [System.String] + # This includes 'subscriptions/{subscriptionId}/' for subscription scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId} for Management Group scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' for invoiceSection scope, and 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' specific for partners. + ${Scope}, + + [Parameter(ParameterSetName='UsageExpanded1', Mandatory)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [System.String] + # This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' for consolidated account used with dimension/query operations. + ${ExternalCloudProviderId}, + + [Parameter(ParameterSetName='UsageExpanded1', Mandatory)] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExternalCloudProviderType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExternalCloudProviderType] + # The external cloud provider type associated with dimension/query operations. + ${ExternalCloudProviderType}, + + [Parameter(Mandatory)] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType] + # The time frame for pulling data for the query. + ${Timeframe}, + + [Parameter(Mandatory)] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType] + # The type of the query. + ${Type}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String[]] + # Array of column names to be included in the query. + ${ConfigurationColumn}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info(PossibleTypes=([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetAggregation]))] + [System.Collections.Hashtable] + # Dictionary of aggregation expression to use in the query. + ${DatasetAggregation}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter] + # Has filter expression to use in the query. + # To construct, see NOTES section for DATASETFILTER properties and create a hash table. + ${DatasetFilter}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType] + # The granularity of rows in the query. + ${DatasetGranularity}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryGrouping[]] + # Array of group by expression to use in the query. + # To construct, see NOTES section for DATASETGROUPING properties and create a hash table. + ${DatasetGrouping}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.DateTime] + # The start date to pull data from. + ${TimePeriodFrom}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.DateTime] + # The end date to pull data to. + ${TimePeriodTo}, + + [Parameter()] + [Alias('AzureRMContext', 'AzureCredential')] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Azure')] + [System.Management.Automation.PSObject] + # The credentials, account, tenant, and subscription used for communication with Azure. + ${DefaultProfile}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Wait for .NET debugger to attach + ${Break}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be appended to the front of the pipeline + ${HttpPipelineAppend}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be prepended to the front of the pipeline + ${HttpPipelinePrepend}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Uri] + # The URI for the proxy server to use + ${Proxy}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.PSCredential] + # Credentials for a proxy server to use for the remote call + ${ProxyCredential}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Use the default credentials for the proxy + ${ProxyUseDefaultCredentials} +) + +begin { + try { + $outBuffer = $null + if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer)) { + $PSBoundParameters['OutBuffer'] = 1 + } + $parameterSet = $PSCmdlet.ParameterSetName + $mapping = @{ + UsageExpanded = 'Az.CostManagement.custom\Invoke-AzCostManagementQuery'; + UsageExpanded1 = 'Az.CostManagement.custom\Invoke-AzCostManagementQuery'; + } + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet) + $scriptCmd = {& $wrappedCmd @PSBoundParameters} + $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin) + $steppablePipeline.Begin($PSCmdlet) + } catch { + throw + } +} + +process { + try { + $steppablePipeline.Process($_) + } catch { + throw + } +} + +end { + try { + $steppablePipeline.End() + } catch { + throw + } +} +} + +# ---------------------------------------------------------------------------------- +# +# Copyright Microsoft Corporation +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ---------------------------------------------------------------------------------- + +<# +.Synopsis +The operation to create or update a export. +Update operation requires latest eTag to be set in the request. +You may obtain the latest eTag by performing a get operation. +Create operation does not require eTag. +.Description +The operation to create or update a export. +Update operation requires latest eTag to be set in the request. +You may obtain the latest eTag by performing a get operation. +Create operation does not require eTag. +.Example +PS C:\> New-AzCostManagementExport -Scope "subscriptions/***********" -Name "CostManagementExportTest" -ScheduleStatus "Active" -ScheduleRecurrence "Daily" -RecurrencePeriodFrom "2020-10-31T20:00:00Z" -RecurrencePeriodTo "2020-11-30T00:00:00Z" -Format "Csv" -DestinationResourceId "/subscriptions/*************/resourceGroups/ResourceGroupTest/providers/Microsoft.Storage/storageAccounts/storageAccountTest" ` -DestinationContainer "exports" -DestinationRootFolderPath "ad-hoc" -DefinitionType "Usage" -DefinitionTimeframe "MonthToDate" -DatasetGranularity "Daily" + +ETag Name Type +---- ---- ---- +"********" TestExportDatasetAggregationInfosagdhaghj Microsoft.CostManagement/exports + +.Outputs +Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport +.Link +https://docs.microsoft.com/en-us/powershell/module/az.costmanagement/new-azcostmanagementexport +#> +function New-AzCostManagementExport { +[OutputType([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport])] +[CmdletBinding(DefaultParameterSetName='CreateExpanded', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')] +param( + [Parameter(Mandatory)] + [Alias('ExportName')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [System.String] + # Export Name. + ${Name}, + + [Parameter(Mandatory)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [System.String] + # This parameter defines the scope of costmanagement from different perspectives 'Subscription','ResourceGroup' and 'Provide Service'. + ${Scope}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String[]] + # Array of column names to be included in the export. + # If not provided then the export will include all available columns. + # The available columns can vary by customer channel (see examples). + ${ConfigurationColumn}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType] + # The granularity of rows in the export. + # Currently only 'Daily' is supported. + ${DataSetGranularity}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType] + # The time frame for pulling data for the export. + # If custom, then a specific time period must be provided. + ${DefinitionTimeframe}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType] + # The type of the export. + # Note that 'Usage' is equivalent to 'ActualCost' and is applicable to exports that do not yet provide data for charges or amortization for service reservations. + ${DefinitionType}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String] + # The name of the container where exports will be uploaded. + ${DestinationContainer}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String] + # The resource id of the storage account where exports will be delivered. + ${DestinationResourceId}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String] + # The name of the directory where exports will be uploaded. + ${DestinationRootFolderPath}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType] + # [Parameter()] + # [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + # [System.String] + # # eTag of the resource. + # # To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not. + # ${ETag}, + # The format of the export being delivered. + # Currently only 'Csv' is supported. + ${Format}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.DateTime] + # The start date of recurrence. + ${RecurrencePeriodFrom}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.DateTime] + # The end date of recurrence. + ${RecurrencePeriodTo}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType] + # The schedule recurrence. + ${ScheduleRecurrence}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType] + # The status of the export's schedule. + # If 'Inactive', the export's schedule is paused. + ${ScheduleStatus}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.DateTime] + # The start date for export data. + ${TimePeriodFrom}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.DateTime] + # The end date for export data. + ${TimePeriodTo}, + + [Parameter()] + [Alias('AzureRMContext', 'AzureCredential')] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Azure')] + [System.Management.Automation.PSObject] + # The credentials, account, tenant, and subscription used for communication with Azure. + ${DefaultProfile}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Wait for .NET debugger to attach + ${Break}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be appended to the front of the pipeline + ${HttpPipelineAppend}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be prepended to the front of the pipeline + ${HttpPipelinePrepend}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Uri] + # The URI for the proxy server to use + ${Proxy}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.PSCredential] + # Credentials for a proxy server to use for the remote call + ${ProxyCredential}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Use the default credentials for the proxy + ${ProxyUseDefaultCredentials} +) + +begin { + try { + $outBuffer = $null + if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer)) { + $PSBoundParameters['OutBuffer'] = 1 + } + $parameterSet = $PSCmdlet.ParameterSetName + $mapping = @{ + CreateExpanded = 'Az.CostManagement.custom\New-AzCostManagementExport'; + } + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet) + $scriptCmd = {& $wrappedCmd @PSBoundParameters} + $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin) + $steppablePipeline.Begin($PSCmdlet) + } catch { + throw + } +} + +process { + try { + $steppablePipeline.Process($_) + } catch { + throw + } +} + +end { + try { + $steppablePipeline.End() + } catch { + throw + } +} +} + +# ---------------------------------------------------------------------------------- +# +# Copyright Microsoft Corporation +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ---------------------------------------------------------------------------------- + +<# +.Synopsis +Create a in-memory object for QueryComparisonExpression +.Description +Create a in-memory object for QueryComparisonExpression +.Example +PS C:\> New-AzCostManagementQueryComparisonExpressionObject -Name 'ResourceLocation' -Operator In -Value @('East US', 'West Europe') + +Name Operator Value +---- -------- ----- +ResourceLocation In {East US, West Europe} + +.Outputs +Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryComparisonExpression +.Link +https://docs.microsoft.com/en-us/powershell/module/az.CostManagement/new-AzCostManagementQueryComparisonExpressionObject +#> +function New-AzCostManagementQueryComparisonExpressionObject { +[OutputType([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryComparisonExpression])] +[CmdletBinding(PositionalBinding=$false)] +param( + [Parameter(Mandatory)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String] + # The name of the column to use in comparison. + ${Name}, + + [Parameter(Mandatory)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.OperatorType] + # The operator to use for comparison. + ${Operator}, + + [Parameter(Mandatory)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String[]] + # Array of values to use for comparison. + ${Value} +) + +begin { + try { + $outBuffer = $null + if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer)) { + $PSBoundParameters['OutBuffer'] = 1 + } + $parameterSet = $PSCmdlet.ParameterSetName + $mapping = @{ + __AllParameterSets = 'Az.CostManagement.custom\New-AzCostManagementQueryComparisonExpressionObject'; + } + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet) + $scriptCmd = {& $wrappedCmd @PSBoundParameters} + $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin) + $steppablePipeline.Begin($PSCmdlet) + } catch { + throw + } +} + +process { + try { + $steppablePipeline.Process($_) + } catch { + throw + } +} + +end { + try { + $steppablePipeline.End() + } catch { + throw + } +} +} + +# ---------------------------------------------------------------------------------- +# +# Copyright Microsoft Corporation +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ---------------------------------------------------------------------------------- + +<# +.Synopsis +Create a in-memory object for QueryFilter +.Description +Create a in-memory object for QueryFilter +.Example +PS C:\> $orDimension = New-AzCostManagementQueryComparisonExpressionObject -Name 'ResourceLocation' -Operator In -Value @('East US', 'West Europe') +PS C:\> $orTag = New-AzCostManagementQueryComparisonExpressionObject -Name 'Environment' -Operator In -Value @('UAT', 'Prod') +PS C:\> New-AzCostManagementQueryFilterObject -or @((New-AzCostManagementQueryFilterObject -Dimension $orDimension), (New-AzCostManagementQueryFilterObject -Tag $orTag)) + +And : +Dimension : Microsoft.Azure.PowerShell.Cmdlets.Cost.Models.Api20200601.QueryComparisonExpression +Not : Microsoft.Azure.PowerShell.Cmdlets.Cost.Models.Api20200601.QueryFilter +Or : {Microsoft.Azure.PowerShell.Cmdlets.Cost.Models.Api20200601.QueryFilter, Microsoft.Azure.PowerShell.Cmdlets.Cost.Models.Api20200601.QueryFilter} +Tag : Microsoft.Azure.PowerShell.Cmdlets.Cost.Models.Api20200601.QueryComparisonExpression + +.Outputs +Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryFilter +.Notes +COMPLEX PARAMETER PROPERTIES + +To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables. + +AND : The logical "AND" expression. Must have at least 2 items. + [And ]: The logical "AND" expression. Must have at least 2 items. + [Dimensions ]: Has comparison expression for a dimension + Name : The name of the column to use in comparison. + Operator : The operator to use for comparison. + Value : Array of values to use for comparison + [Not ]: The logical "NOT" expression. + [Or ]: The logical "OR" expression. Must have at least 2 items. + [Tag ]: Has comparison expression for a tag + +DIMENSIONS : Has comparison expression for a dimensions. + Name : The name of the column to use in comparison. + Operator : The operator to use for comparison. + Value : Array of values to use for comparison + +NOT : The logical "NOT" expression. + [And ]: The logical "AND" expression. Must have at least 2 items. + [Dimensions ]: Has comparison expression for a dimension + Name : The name of the column to use in comparison. + Operator : The operator to use for comparison. + Value : Array of values to use for comparison + [Not ]: The logical "NOT" expression. + [Or ]: The logical "OR" expression. Must have at least 2 items. + [Tag ]: Has comparison expression for a tag + +OR : The logical "OR" expression. Must have at least 2 items. + [And ]: The logical "AND" expression. Must have at least 2 items. + [Dimensions ]: Has comparison expression for a dimension + Name : The name of the column to use in comparison. + Operator : The operator to use for comparison. + Value : Array of values to use for comparison + [Not ]: The logical "NOT" expression. + [Or ]: The logical "OR" expression. Must have at least 2 items. + [Tag ]: Has comparison expression for a tag + +TAG : Has comparison expression for a tag. + Name : The name of the column to use in comparison. + Operator : The operator to use for comparison. + Value : Array of values to use for comparison +.Link +https://docs.microsoft.com/en-us/powershell/module/az.CostManagement/new-AzCostManagementQueryFilterObject +#> +function New-AzCostManagementQueryFilterObject { +[OutputType([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryFilter])] +[CmdletBinding(PositionalBinding=$false)] +param( + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter[]] + # The logical "AND" expression. + # Must have at least 2 items. + # To construct, see NOTES section for AND properties and create a hash table. + ${And}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryComparisonExpression] + # Has comparison expression for a dimensions. + # To construct, see NOTES section for DIMENSIONS properties and create a hash table. + ${Dimensions}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter] + # The logical "NOT" expression. + # To construct, see NOTES section for NOT properties and create a hash table. + ${Not}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter[]] + # The logical "OR" expression. + # Must have at least 2 items. + # To construct, see NOTES section for OR properties and create a hash table. + ${Or}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryComparisonExpression] + # Has comparison expression for a tag. + # To construct, see NOTES section for TAG properties and create a hash table. + ${Tag} +) + +begin { + try { + $outBuffer = $null + if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer)) { + $PSBoundParameters['OutBuffer'] = 1 + } + $parameterSet = $PSCmdlet.ParameterSetName + $mapping = @{ + __AllParameterSets = 'Az.CostManagement.custom\New-AzCostManagementQueryFilterObject'; + } + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet) + $scriptCmd = {& $wrappedCmd @PSBoundParameters} + $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin) + $steppablePipeline.Begin($PSCmdlet) + } catch { + throw + } +} + +process { + try { + $steppablePipeline.Process($_) + } catch { + throw + } +} + +end { + try { + $steppablePipeline.End() + } catch { + throw + } +} +} + +# ---------------------------------------------------------------------------------- +# +# Copyright Microsoft Corporation +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ---------------------------------------------------------------------------------- + +<# +.Synopsis +The operation to create or update a export. +Update operation requires latest eTag to be set in the request. +You may obtain the latest eTag by performing a get operation. +Create operation does not require eTag. +.Description +The operation to create or update a export. +Update operation requires latest eTag to be set in the request. +You may obtain the latest eTag by performing a get operation. +Create operation does not require eTag. +.Example +PS C:\> Update-AzCostManagementExport -Scope "subscriptions//*********" -Name "TestExport" -ScheduleRecurrence 'Weekly' + +ETag Name Type +---- ---- ---- +"********" TestExportDatasetAggregationInfo Microsoft.CostManagement/exports +.Example +PS C:\> $oldExport = Get-AzCostManagementExport -Scope "subscriptions/*********" -Name "TestExport" +Update-AzCostManagementExport -InputObject $oldExport -ScheduleRecurrence 'Weekly' + +ETag Name Type +---- ---- ---- +"********" TestExportDatasetAggregationInfo Microsoft.CostManagement/exports + +.Inputs +Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity +.Outputs +Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport +.Notes +COMPLEX PARAMETER PROPERTIES + +To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables. + +INPUTOBJECT : Identity Parameter + [AlertId ]: Alert ID + [ExportName ]: Export Name. + [ExternalCloudProviderId ]: This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' for consolidated account used with dimension/query operations. + [ExternalCloudProviderType ]: The external cloud provider type associated with dimension/query operations. This includes 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated account. + [Id ]: Resource identity path + [Scope ]: The scope associated with view operations. This includes 'subscriptions/{subscriptionId}' for subscription scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for BillingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' for InvoiceSection scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope, 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for External Billing Account scope and 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for External Subscription scope. + [ViewName ]: View name +.Link +https://docs.microsoft.com/en-us/powershell/module/az.costmanagement/update-azcostmanagementexport +#> +function Update-AzCostManagementExport { +[OutputType([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport])] +[CmdletBinding(DefaultParameterSetName='UpdateExpanded', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')] +param( + [Parameter(ParameterSetName='UpdateExpanded', Mandatory)] + [Alias('ExportName')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [System.String] + # Export Name. + ${Name}, + + [Parameter(ParameterSetName='UpdateExpanded', Mandatory)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [System.String] + # This parameter defines the scope of costmanagement from different perspectives 'Subscription','ResourceGroup' and 'Provide Service'. + ${Scope}, + + [Parameter(ParameterSetName='UpdateViaIdentityExpanded', Mandatory, ValueFromPipeline)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity] + # Identity Parameter + # To construct, see NOTES section for INPUTOBJECT properties and create a hash table. + ${InputObject}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String[]] + # Array of column names to be included in the export. + # If not provided then the export will include all available columns. + # The available columns can vary by customer channel (see examples). + ${ConfigurationColumn}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType] + # The granularity of rows in the export. + # Currently only 'Daily' is supported. + ${DataSetGranularity}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType] + # The time frame for pulling data for the export. + # If custom, then a specific time period must be provided. + ${DefinitionTimeframe}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType] + # The type of the export. + # Note that 'Usage' is equivalent to 'ActualCost' and is applicable to exports that do not yet provide data for charges or amortization for service reservations. + ${DefinitionType}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String] + # The name of the container where exports will be uploaded. + ${DestinationContainer}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String] + # The resource id of the storage account where exports will be delivered. + ${DestinationResourceId}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String] + # The name of the directory where exports will be uploaded. + ${DestinationRootFolderPath}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String] + # eTag of the resource. + # To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not. + ${ETag}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType] + # The format of the export being delivered. + # Currently only 'Csv' is supported. + ${Format}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.DateTime] + # The start date of recurrence. + ${RecurrencePeriodFrom}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.DateTime] + # The end date of recurrence. + ${RecurrencePeriodTo}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType] + # The schedule recurrence. + ${ScheduleRecurrence}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType] + # The status of the export's schedule. + # If 'Inactive', the export's schedule is paused. + ${ScheduleStatus}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.DateTime] + # The start date for export data. + ${TimePeriodFrom}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.DateTime] + # The end date for export data. + ${TimePeriodTo}, + + [Parameter()] + [Alias('AzureRMContext', 'AzureCredential')] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Azure')] + [System.Management.Automation.PSObject] + # The credentials, account, tenant, and subscription used for communication with Azure. + ${DefaultProfile}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Wait for .NET debugger to attach + ${Break}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be appended to the front of the pipeline + ${HttpPipelineAppend}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be prepended to the front of the pipeline + ${HttpPipelinePrepend}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Uri] + # The URI for the proxy server to use + ${Proxy}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.PSCredential] + # Credentials for a proxy server to use for the remote call + ${ProxyCredential}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Use the default credentials for the proxy + ${ProxyUseDefaultCredentials} +) + +begin { + try { + $outBuffer = $null + if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer)) { + $PSBoundParameters['OutBuffer'] = 1 + } + $parameterSet = $PSCmdlet.ParameterSetName + $mapping = @{ + UpdateExpanded = 'Az.CostManagement.custom\Update-AzCostManagementExport'; + UpdateViaIdentityExpanded = 'Az.CostManagement.custom\Update-AzCostManagementExport'; + } + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet) + $scriptCmd = {& $wrappedCmd @PSBoundParameters} + $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin) + $steppablePipeline.Begin($PSCmdlet) + } catch { + throw + } +} + +process { + try { + $steppablePipeline.Process($_) + } catch { + throw + } +} + +end { + try { + $steppablePipeline.End() + } catch { + throw + } +} +} diff --git a/src/CostManagement/exports/Remove-AzCostManagementExport.ps1 b/src/CostManagement/exports/Remove-AzCostManagementExport.ps1 new file mode 100644 index 000000000000..e865b21bd3fb --- /dev/null +++ b/src/CostManagement/exports/Remove-AzCostManagementExport.ps1 @@ -0,0 +1,164 @@ + +# ---------------------------------------------------------------------------------- +# +# Copyright Microsoft Corporation +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ---------------------------------------------------------------------------------- + +<# +.Synopsis +The operation to delete a export. +.Description +The operation to delete a export. +.Example +PS C:\> Remove-AzCostManagementExport -Scope 'subscriptions/********' -name 'TestExportDatasetAggregationInfoYouri' + + +.Example +PS C:\> $getExport = Get-AzCostManagementExport -Scope 'subscriptions/*********' -name 'TestExportDatasetAggregationYouori' +Remove-AzCostManagementExport -InputObject $getExport + + + +.Inputs +Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity +.Outputs +System.Boolean +.Notes +COMPLEX PARAMETER PROPERTIES + +To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables. + +INPUTOBJECT : Identity Parameter + [AlertId ]: Alert ID + [ExportName ]: Export Name. + [ExternalCloudProviderId ]: This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' for consolidated account used with dimension/query operations. + [ExternalCloudProviderType ]: The external cloud provider type associated with dimension/query operations. This includes 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated account. + [Id ]: Resource identity path + [Scope ]: The scope associated with view operations. This includes 'subscriptions/{subscriptionId}' for subscription scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for BillingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' for InvoiceSection scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope, 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for External Billing Account scope and 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for External Subscription scope. + [ViewName ]: View name +.Link +https://docs.microsoft.com/en-us/powershell/module/az.costmanagement/remove-azcostmanagementexport +#> +function Remove-AzCostManagementExport { +[OutputType([System.Boolean])] +[CmdletBinding(DefaultParameterSetName='Delete', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')] +param( + [Parameter(ParameterSetName='Delete', Mandatory)] + [Alias('ExportName')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [System.String] + # Export Name. + ${Name}, + + [Parameter(ParameterSetName='Delete', Mandatory)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [System.String] + # This parameter defines the scope of costmanagement from different perspectives 'Subscription','ResourceGroup' and 'Provide Service'. + ${Scope}, + + [Parameter(ParameterSetName='DeleteViaIdentity', Mandatory, ValueFromPipeline)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity] + # Identity Parameter + # To construct, see NOTES section for INPUTOBJECT properties and create a hash table. + ${InputObject}, + + [Parameter()] + [Alias('AzureRMContext', 'AzureCredential')] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Azure')] + [System.Management.Automation.PSObject] + # The credentials, account, tenant, and subscription used for communication with Azure. + ${DefaultProfile}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Wait for .NET debugger to attach + ${Break}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be appended to the front of the pipeline + ${HttpPipelineAppend}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be prepended to the front of the pipeline + ${HttpPipelinePrepend}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Returns true when the command succeeds + ${PassThru}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Uri] + # The URI for the proxy server to use + ${Proxy}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.PSCredential] + # Credentials for a proxy server to use for the remote call + ${ProxyCredential}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Use the default credentials for the proxy + ${ProxyUseDefaultCredentials} +) + +begin { + try { + $outBuffer = $null + if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer)) { + $PSBoundParameters['OutBuffer'] = 1 + } + $parameterSet = $PSCmdlet.ParameterSetName + $mapping = @{ + Delete = 'Az.CostManagement.private\Remove-AzCostManagementExport_Delete'; + DeleteViaIdentity = 'Az.CostManagement.private\Remove-AzCostManagementExport_DeleteViaIdentity'; + } + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet) + $scriptCmd = {& $wrappedCmd @PSBoundParameters} + $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin) + $steppablePipeline.Begin($PSCmdlet) + } catch { + throw + } +} + +process { + try { + $steppablePipeline.Process($_) + } catch { + throw + } +} + +end { + try { + $steppablePipeline.End() + } catch { + throw + } +} +} diff --git a/src/CostManagement/exports/Update-AzCostManagementExport.ps1 b/src/CostManagement/exports/Update-AzCostManagementExport.ps1 new file mode 100644 index 000000000000..9e898644c76a --- /dev/null +++ b/src/CostManagement/exports/Update-AzCostManagementExport.ps1 @@ -0,0 +1,272 @@ + +# ---------------------------------------------------------------------------------- +# +# Copyright Microsoft Corporation +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ---------------------------------------------------------------------------------- + +<# +.Synopsis +The operation to create or update a export. +Update operation requires latest eTag to be set in the request. +You may obtain the latest eTag by performing a get operation. +Create operation does not require eTag. +.Description +The operation to create or update a export. +Update operation requires latest eTag to be set in the request. +You may obtain the latest eTag by performing a get operation. +Create operation does not require eTag. +.Example +PS C:\> Update-AzCostManagementExport -Scope "subscriptions//*********" -Name "TestExport" -ScheduleRecurrence 'Weekly' + +ETag Name Type +---- ---- ---- +"********" TestExportDatasetAggregationInfo Microsoft.CostManagement/exports +.Example +PS C:\> $oldExport = Get-AzCostManagementExport -Scope "subscriptions/*********" -Name "TestExport" +Update-AzCostManagementExport -InputObject $oldExport -ScheduleRecurrence 'Weekly' + +ETag Name Type +---- ---- ---- +"********" TestExportDatasetAggregationInfo Microsoft.CostManagement/exports + +.Inputs +Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity +.Outputs +Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport +.Notes +COMPLEX PARAMETER PROPERTIES + +To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables. + +INPUTOBJECT : Identity Parameter + [AlertId ]: Alert ID + [ExportName ]: Export Name. + [ExternalCloudProviderId ]: This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' for consolidated account used with dimension/query operations. + [ExternalCloudProviderType ]: The external cloud provider type associated with dimension/query operations. This includes 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated account. + [Id ]: Resource identity path + [Scope ]: The scope associated with view operations. This includes 'subscriptions/{subscriptionId}' for subscription scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for BillingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' for InvoiceSection scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope, 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for External Billing Account scope and 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for External Subscription scope. + [ViewName ]: View name +.Link +https://docs.microsoft.com/en-us/powershell/module/az.costmanagement/update-azcostmanagementexport +#> +function Update-AzCostManagementExport { +[OutputType([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport])] +[CmdletBinding(DefaultParameterSetName='UpdateExpanded', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')] +param( + [Parameter(ParameterSetName='UpdateExpanded', Mandatory)] + [Alias('ExportName')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [System.String] + # Export Name. + ${Name}, + + [Parameter(ParameterSetName='UpdateExpanded', Mandatory)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [System.String] + # This parameter defines the scope of costmanagement from different perspectives 'Subscription','ResourceGroup' and 'Provide Service'. + ${Scope}, + + [Parameter(ParameterSetName='UpdateViaIdentityExpanded', Mandatory, ValueFromPipeline)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity] + # Identity Parameter + # To construct, see NOTES section for INPUTOBJECT properties and create a hash table. + ${InputObject}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String[]] + # Array of column names to be included in the export. + # If not provided then the export will include all available columns. + # The available columns can vary by customer channel (see examples). + ${ConfigurationColumn}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType] + # The granularity of rows in the export. + # Currently only 'Daily' is supported. + ${DataSetGranularity}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType] + # The time frame for pulling data for the export. + # If custom, then a specific time period must be provided. + ${DefinitionTimeframe}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType] + # The type of the export. + # Note that 'Usage' is equivalent to 'ActualCost' and is applicable to exports that do not yet provide data for charges or amortization for service reservations. + ${DefinitionType}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String] + # The name of the container where exports will be uploaded. + ${DestinationContainer}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String] + # The resource id of the storage account where exports will be delivered. + ${DestinationResourceId}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String] + # The name of the directory where exports will be uploaded. + ${DestinationRootFolderPath}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String] + # eTag of the resource. + # To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not. + ${ETag}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType] + # The format of the export being delivered. + # Currently only 'Csv' is supported. + ${Format}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.DateTime] + # The start date of recurrence. + ${RecurrencePeriodFrom}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.DateTime] + # The end date of recurrence. + ${RecurrencePeriodTo}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType] + # The schedule recurrence. + ${ScheduleRecurrence}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType] + # The status of the export's schedule. + # If 'Inactive', the export's schedule is paused. + ${ScheduleStatus}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.DateTime] + # The start date for export data. + ${TimePeriodFrom}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.DateTime] + # The end date for export data. + ${TimePeriodTo}, + + [Parameter()] + [Alias('AzureRMContext', 'AzureCredential')] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Azure')] + [System.Management.Automation.PSObject] + # The credentials, account, tenant, and subscription used for communication with Azure. + ${DefaultProfile}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Wait for .NET debugger to attach + ${Break}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be appended to the front of the pipeline + ${HttpPipelineAppend}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be prepended to the front of the pipeline + ${HttpPipelinePrepend}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Uri] + # The URI for the proxy server to use + ${Proxy}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.PSCredential] + # Credentials for a proxy server to use for the remote call + ${ProxyCredential}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Use the default credentials for the proxy + ${ProxyUseDefaultCredentials} +) + +begin { + try { + $outBuffer = $null + if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer)) { + $PSBoundParameters['OutBuffer'] = 1 + } + $parameterSet = $PSCmdlet.ParameterSetName + $mapping = @{ + UpdateExpanded = 'Az.CostManagement.custom\Update-AzCostManagementExport'; + UpdateViaIdentityExpanded = 'Az.CostManagement.custom\Update-AzCostManagementExport'; + } + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet) + $scriptCmd = {& $wrappedCmd @PSBoundParameters} + $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin) + $steppablePipeline.Begin($PSCmdlet) + } catch { + throw + } +} + +process { + try { + $steppablePipeline.Process($_) + } catch { + throw + } +} + +end { + try { + $steppablePipeline.End() + } catch { + throw + } +} +} diff --git a/src/CostManagement/exports/readme.md b/src/CostManagement/exports/readme.md new file mode 100644 index 000000000000..f9461d382772 --- /dev/null +++ b/src/CostManagement/exports/readme.md @@ -0,0 +1,20 @@ +# Exports +This directory contains the cmdlets *exported by* `Az.CostManagement`. No other cmdlets in this repository are directly exported. What that means is the `Az.CostManagement` module will run [Export-ModuleMember](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/export-modulemember) on the cmldets in this directory. The cmdlets in this directory are generated at **build-time**. Do not put any custom code, files, cmdlets, etc. into this directory. Please use `..\custom` for all custom implementation. + +## Info +- Modifiable: no +- Generated: all +- Committed: no +- Packaged: yes + +## Details +The cmdlets generated here are created every time you run `build-module.ps1`. These cmdlets are a merge of all (excluding `InternalExport`) cmdlets from the private binary (`..\bin\Az.CostManagement.private.dll`) and from the `..\custom\Az.CostManagement.custom.psm1` module. Cmdlets that are *not merged* from those directories are decorated with the `InternalExport` attribute. This happens when you set the cmdlet to **hide** from configuration. For more information on hiding, see [cmdlet hiding](https://github.com/Azure/autorest/blob/master/docs/powershell/options.md#cmdlet-hiding-exportation-suppression) or the [readme.md](..\internal/readme.md) in the `..\internal` folder. + +## Purpose +We generate script cmdlets out of the binary cmdlets and custom cmdlets. The format of script cmdlets are simplistic; thus, easier to generate at build time. Generating the cmdlets is required as to allow merging of generated binary, hand-written binary, and hand-written custom cmdlets. For Azure cmdlets, having script cmdlets simplifies the mechanism for exporting Azure profiles. + +## Structure +The cmdlets generated here will flat in the directory (no sub-folders) as long as there are no Azure profiles specified for any cmdlets. Azure profiles (the `Profiles` attribute) is only applied when generating with the `--azure` attribute (or `azure: true` in the configuration). When Azure profiles are applied, the folder structure has a folder per profile. Each profile folder has only those cmdlets that apply to that profile. + +## Usage +When `./Az.CostManagement.psm1` is loaded, it dynamically exports cmdlets here based on the folder structure and on the selected profile. If there are no sub-folders, it exports all cmdlets at the root of this folder. If there are sub-folders, it checks to see the selected profile. If no profile is selected, it exports the cmdlets in the last sub-folder (alphabetically). If a profile is selected, it exports the cmdlets in the sub-folder that matches the profile name. If there is no sub-folder that matches the profile name, it exports no cmdlets and writes a warning message. \ No newline at end of file diff --git a/src/CostManagement/generate-help.ps1 b/src/CostManagement/generate-help.ps1 new file mode 100644 index 000000000000..c9f419de7c66 --- /dev/null +++ b/src/CostManagement/generate-help.ps1 @@ -0,0 +1,73 @@ +# ---------------------------------------------------------------------------------- +# +# Copyright Microsoft Corporation +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ---------------------------------------------------------------------------------- +param([switch]$Isolated) +$ErrorActionPreference = 'Stop' + +$pwsh = [System.Diagnostics.Process]::GetCurrentProcess().Path +if(-not $Isolated) { + Write-Host -ForegroundColor Green 'Creating isolated process...' + & "$pwsh" -NonInteractive -NoLogo -NoProfile -File $MyInvocation.MyCommand.Path @PSBoundParameters -Isolated + return +} + +$exportsFolder = Join-Path $PSScriptRoot 'exports' +if(-not (Test-Path $exportsFolder)) { + Write-Error "Exports folder '$exportsFolder' was not found." +} + +$directories = Get-ChildItem -Directory -Path $exportsFolder +$hasProfiles = ($directories | Measure-Object).Count -gt 0 +if(-not $hasProfiles) { + $directories = Get-Item -Path $exportsFolder +} + +$docsFolder = Join-Path $PSScriptRoot 'docs' +if(Test-Path $docsFolder) { + $null = Get-ChildItem -Path $docsFolder -Recurse -Exclude 'readme.md' | Remove-Item -Recurse -ErrorAction SilentlyContinue +} +$null = New-Item -ItemType Directory -Force -Path $docsFolder -ErrorAction SilentlyContinue +$examplesFolder = Join-Path $PSScriptRoot 'examples' + +$modulePsd1 = Get-Item -Path (Join-Path $PSScriptRoot './Az.CostManagement.psd1') +$modulePath = $modulePsd1.FullName +$moduleName = $modulePsd1.BaseName + +# Load DLL to use build-time cmdlets +Import-Module -Name $modulePath +Import-Module -Name (Join-Path $PSScriptRoot './bin/Az.CostManagement.private.dll') +$instance = [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Module]::Instance +# Module info is shared per profile +$moduleInfo = Get-Module -Name $moduleName + +foreach($directory in $directories) +{ + if($hasProfiles) { + Select-AzProfile -Name $directory.Name + } + # Reload module per profile + Import-Module -Name $modulePath -Force + + $cmdletNames = Get-ScriptCmdlet -ScriptFolder $directory.FullName + $cmdletHelpInfo = $cmdletNames | ForEach-Object { Get-Help -Name $_ -Full } + $cmdletFunctionInfo = Get-ScriptCmdlet -ScriptFolder $directory.FullName -AsFunctionInfo + + $docsPath = Join-Path $docsFolder $directory.Name + $null = New-Item -ItemType Directory -Force -Path $docsPath -ErrorAction SilentlyContinue + $examplesPath = Join-Path $examplesFolder $directory.Name + + Export-HelpMarkdown -ModuleInfo $moduleInfo -FunctionInfo $cmdletFunctionInfo -HelpInfo $cmdletHelpInfo -DocsFolder $docsPath -ExamplesFolder $examplesPath + Write-Host -ForegroundColor Green "Created documentation in '$docsPath'" +} + +Write-Host -ForegroundColor Green '-------------Done-------------' \ No newline at end of file diff --git a/src/CostManagement/generate-info.json b/src/CostManagement/generate-info.json new file mode 100644 index 000000000000..517daf06ab11 --- /dev/null +++ b/src/CostManagement/generate-info.json @@ -0,0 +1,8 @@ +{ + "autorest_core": "3.0.6320", + "autorest_powershell": "2.1.401", + "autorest_remodeler": "2.1.27", + "autorest": "3.0.6149", + "swagger_commit": "f02941a88045ddd076a6cc3a103a7ee82ed61cb9", + "node": "v10.16.3" +} diff --git a/src/CostManagement/generated/Module.cs b/src/CostManagement/generated/Module.cs new file mode 100644 index 000000000000..7b685934e703 --- /dev/null +++ b/src/CostManagement/generated/Module.cs @@ -0,0 +1,158 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + using SendAsyncStepDelegate = global::System.Func, global::System.Threading.Tasks.Task>, global::System.Func, global::System.Threading.Tasks.Task>, global::System.Threading.Tasks.Task>, global::System.Threading.Tasks.Task>; + using PipelineChangeDelegate = global::System.Action, global::System.Threading.Tasks.Task>, global::System.Func, global::System.Threading.Tasks.Task>, global::System.Threading.Tasks.Task>, global::System.Threading.Tasks.Task>>; + using GetParameterDelegate = global::System.Func; + using ModuleLoadPipelineDelegate = global::System.Action, global::System.Threading.Tasks.Task>, global::System.Func, global::System.Threading.Tasks.Task>, global::System.Threading.Tasks.Task>, global::System.Threading.Tasks.Task>>, global::System.Action, global::System.Threading.Tasks.Task>, global::System.Func, global::System.Threading.Tasks.Task>, global::System.Threading.Tasks.Task>, global::System.Threading.Tasks.Task>>>; + using NewRequestPipelineDelegate = global::System.Action, global::System.Threading.Tasks.Task>, global::System.Func, global::System.Threading.Tasks.Task>, global::System.Threading.Tasks.Task>, global::System.Threading.Tasks.Task>>, global::System.Action, global::System.Threading.Tasks.Task>, global::System.Func, global::System.Threading.Tasks.Task>, global::System.Threading.Tasks.Task>, global::System.Threading.Tasks.Task>>>; + using ArgumentCompleterDelegate = global::System.Func; + using SignalDelegate = global::System.Func, global::System.Threading.Tasks.Task>; + using EventListenerDelegate = global::System.Func, global::System.Func, global::System.Threading.Tasks.Task>, global::System.Management.Automation.InvocationInfo, string, string, string, global::System.Exception, global::System.Threading.Tasks.Task>; + using NextDelegate = global::System.Func, global::System.Threading.Tasks.Task>, global::System.Threading.Tasks.Task>; + + /// A class that contains the module-common code and data. + public partial class Module + { + /// The currently selected profile. + public string Profile = global::System.String.Empty; + + public global::System.Net.Http.HttpClientHandler _handler = new global::System.Net.Http.HttpClientHandler(); + + /// the ISendAsync pipeline instance + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.HttpPipeline _pipeline; + + /// the ISendAsync pipeline instance (when proxy is enabled) + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.HttpPipeline _pipelineWithProxy; + + public global::System.Net.WebProxy _webProxy = new global::System.Net.WebProxy(); + + /// Gets completion data for azure specific fields + public ArgumentCompleterDelegate ArgumentCompleter { get; set; } + + /// The instance of the Client API + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.CostManagement ClientAPI { get; set; } + + /// A delegate that gets called for each signalled event + public EventListenerDelegate EventListener { get; set; } + + /// The delegate to call to get parameter data from a common module. + public GetParameterDelegate GetParameterValue { get; set; } + + /// Backing field for property. + private static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Module _instance; + + /// the singleton of this module class + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Module Instance => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Module._instance?? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Module._instance = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Module()); + + /// The Name of this module + public string Name => @"Az.CostManagement"; + + /// The delegate to call when this module is loaded (supporting a commmon module). + public ModuleLoadPipelineDelegate OnModuleLoad { get; set; } + + /// The delegate to call before each new request (supporting a commmon module). + public NewRequestPipelineDelegate OnNewRequest { get; set; } + + /// The name of the currently selected Azure profile + public global::System.String ProfileName { get; set; } + + /// The ResourceID for this module (azure arm). + public string ResourceId => @"Az.CostManagement"; + + /// The from the cmdlet + /// The HttpPipeline for the request + + partial void AfterCreatePipeline(global::System.Management.Automation.InvocationInfo invocationInfo, ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.HttpPipeline pipeline); + + /// The from the cmdlet + /// The HttpPipeline for the request + + partial void BeforeCreatePipeline(global::System.Management.Automation.InvocationInfo invocationInfo, ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.HttpPipeline pipeline); + + partial void CustomInit(); + + /// Creates an instance of the HttpPipeline for each call. + /// The from the cmdlet + /// the cmdlet's correlation id. + /// the cmdlet's process record correlation id. + /// the cmdlet's parameterset name. + /// An instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.HttpPipeline for the remote call. + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.HttpPipeline CreatePipeline(global::System.Management.Automation.InvocationInfo invocationInfo, string correlationId, string processRecordId, string parameterSetName = null) + { + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.HttpPipeline pipeline = null; + BeforeCreatePipeline(invocationInfo, ref pipeline); + pipeline = (pipeline ?? (_handler.UseProxy ? _pipelineWithProxy : _pipeline)).Clone(); + AfterCreatePipeline(invocationInfo, ref pipeline); + pipeline.Append(new Runtime.CmdInfoHandler(processRecordId, invocationInfo, parameterSetName).SendAsync); + OnNewRequest?.Invoke( invocationInfo, correlationId,processRecordId, (step)=> { pipeline.Prepend(step); } , (step)=> { pipeline.Append(step); } ); + return pipeline; + } + + /// Gets parameters from a common module. + /// The from the cmdlet + /// the cmdlet's correlation id. + /// The name of the parameter to get the value for. + /// + /// The parameter value from the common module. (Note: this should be type converted on the way back) + /// + public object GetParameter(global::System.Management.Automation.InvocationInfo invocationInfo, string correlationId, string parameterName) => GetParameterValue?.Invoke( ResourceId, Name, invocationInfo, correlationId,parameterName ); + + /// Initialization steps performed after the module is loaded. + public void Init() + { + OnModuleLoad?.Invoke( ResourceId, Name ,(step)=> { _pipeline.Prepend(step); } , (step)=> { _pipeline.Append(step); } ); + OnModuleLoad?.Invoke( ResourceId, Name ,(step)=> { _pipelineWithProxy.Prepend(step); } , (step)=> { _pipelineWithProxy.Append(step); } ); + CustomInit(); + } + + /// Creates the module instance. + private Module() + { + /// constructor + ClientAPI = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.CostManagement(); + _handler.Proxy = _webProxy; + _pipeline = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.HttpPipeline(new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.HttpClientFactory(new global::System.Net.Http.HttpClient())); + _pipelineWithProxy = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.HttpPipeline(new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.HttpClientFactory(new global::System.Net.Http.HttpClient(_handler))); + } + + /// The HTTP Proxy to use. + /// The HTTP Proxy Credentials + /// True if the proxy should use default credentials + public void SetProxyConfiguration(global::System.Uri proxy, global::System.Management.Automation.PSCredential proxyCredential, bool proxyUseDefaultCredentials) + { + // set the proxy configuration + _webProxy.Address = proxy; + _webProxy.BypassProxyOnLocal = false; + _webProxy.Credentials = proxyCredential ?.GetNetworkCredential(); + _webProxy.UseDefaultCredentials = proxyUseDefaultCredentials; + _handler.UseProxy = proxy != null; + } + + /// Called to dispatch events to the common module listener + /// The ID of the event + /// The cancellation token for the event + /// A delegate to get the detailed event data + /// The callback for the event dispatcher + /// The from the cmdlet + /// the cmdlet's parameterset name. + /// the cmdlet's correlation id. + /// the cmdlet's process record correlation id. + /// the exception that is being thrown (if available) + /// + /// A that will be complete when handling of the event is completed. + /// + public async global::System.Threading.Tasks.Task Signal(string id, global::System.Threading.CancellationToken token, global::System.Func getEventData, SignalDelegate signal, global::System.Management.Automation.InvocationInfo invocationInfo, string parameterSetName, string correlationId, string processRecordId, global::System.Exception exception) + { + using( NoSynchronizationContext ) + { + await EventListener?.Invoke(id,token,getEventData, signal, invocationInfo, parameterSetName, correlationId,processRecordId,exception); + } + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/CostManagement.cs b/src/CostManagement/generated/api/CostManagement.cs new file mode 100644 index 000000000000..ab959d9b5e59 --- /dev/null +++ b/src/CostManagement/generated/api/CostManagement.cs @@ -0,0 +1,4410 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// + /// Low-level API implementation for the CostManagement service. + /// + public partial class CostManagement + { + + /// Dismisses the specified alert + /// The scope associated with alerts operations. This includes '/subscriptions/{subscriptionId}/' for + /// subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for Billing Account scope and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, '/providers/Microsoft.Management/managementGroups/{managementGroupId} for Management Group + /// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile + /// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// Alert ID + /// Parameters supplied to the Dismiss Alert operation. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task AlertsDismiss(string scope, string alertId, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayload body, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + var apiVersion = @"2020-06-01"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // construct URL + var _url = new global::System.Uri(global::System.Text.RegularExpressions.Regex.Replace( + "https://management.azure.com/" + + (scope) + + "/providers/Microsoft.CostManagement/alerts/" + + (alertId) + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2")); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.URLCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Patch, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.RequestCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.HeaderParametersAdded, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // set body content + request.Content = new global::System.Net.Http.StringContent(null != body ? body.ToJson(null).ToString() : @"{}", global::System.Text.Encoding.UTF8); + request.Content.Headers.ContentType = global::System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BodyContentSet, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.AlertsDismiss_Call(request,onOk,onDefault,eventListener,sender); + } + } + + /// Dismisses the specified alert + /// + /// Parameters supplied to the Dismiss Alert operation. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task AlertsDismissViaIdentity(global::System.String viaIdentity, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayload body, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + var apiVersion = @"2020-06-01"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // verify that Identity format is an exact match for uri + + var _match = new global::System.Text.RegularExpressions.Regex("(?.+)/providers/Microsoft.CostManagement/alerts/(?[^/]+)$").Match(viaIdentity); + if (!_match.Success) + { + throw new global::System.Exception("Invalid identity for URI '/{scope}/providers/Microsoft.CostManagement/alerts/{alertId}'"); + } + + // replace URI parameters with values from identity + var scope = _match.Groups["scope"].Value; + var alertId = _match.Groups["alertId"].Value; + // construct URL + var _url = new global::System.Uri(global::System.Text.RegularExpressions.Regex.Replace( + "https://management.azure.com/" + + scope + + "/providers/Microsoft.CostManagement/alerts/" + + alertId + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2")); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.URLCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Patch, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.RequestCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.HeaderParametersAdded, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // set body content + request.Content = new global::System.Net.Http.StringContent(null != body ? body.ToJson(null).ToString() : @"{}", global::System.Text.Encoding.UTF8); + request.Content.Headers.ContentType = global::System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BodyContentSet, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.AlertsDismiss_Call(request,onOk,onDefault,eventListener,sender); + } + } + + /// Actual wire call for method. + /// the prepared HttpRequestMessage to send. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + internal async global::System.Threading.Tasks.Task AlertsDismiss_Call(global::System.Net.Http.HttpRequestMessage request, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + using( NoSynchronizationContext ) + { + global::System.Net.Http.HttpResponseMessage _response = null; + try + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return; } + _response = await sender.SendAsync(request, eventListener); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + var _contentType = _response.Content.Headers.ContentType?.MediaType; + + switch ( _response.StatusCode ) + { + case global::System.Net.HttpStatusCode.OK: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onOk(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.Alert.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + default: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + } + } + finally + { + // finally statements + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Finally, request, _response); + _response?.Dispose(); + request?.Dispose(); + } + } + } + + /// + /// Validation method for method. Call this like the actual call, but you will get validation + /// events back. + /// + /// The scope associated with alerts operations. This includes '/subscriptions/{subscriptionId}/' for + /// subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for Billing Account scope and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, '/providers/Microsoft.Management/managementGroups/{managementGroupId} for Management Group + /// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile + /// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// Alert ID + /// Parameters supplied to the Dismiss Alert operation. + /// an instance that will receive events. + /// + /// A that will be complete when handling of the response is completed. + /// + internal async global::System.Threading.Tasks.Task AlertsDismiss_Validate(string scope, string alertId, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayload body, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener) + { + using( NoSynchronizationContext ) + { + await eventListener.AssertNotNull(nameof(scope),scope); + await eventListener.AssertNotNull(nameof(alertId),alertId); + await eventListener.AssertNotNull(nameof(body), body); + await eventListener.AssertObjectIsValid(nameof(body), body); + } + } + + /// Gets the alert for the scope by alert ID. + /// The scope associated with alerts operations. This includes '/subscriptions/{subscriptionId}/' for + /// subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for Billing Account scope and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, '/providers/Microsoft.Management/managementGroups/{managementGroupId} for Management Group + /// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile + /// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// Alert ID + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task AlertsGet(string scope, string alertId, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + var apiVersion = @"2020-06-01"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // construct URL + var _url = new global::System.Uri(global::System.Text.RegularExpressions.Regex.Replace( + "https://management.azure.com/" + + (scope) + + "/providers/Microsoft.CostManagement/alerts/" + + (alertId) + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2")); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.URLCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Get, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.RequestCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.HeaderParametersAdded, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.AlertsGet_Call(request,onOk,onDefault,eventListener,sender); + } + } + + /// Gets the alert for the scope by alert ID. + /// + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task AlertsGetViaIdentity(global::System.String viaIdentity, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + var apiVersion = @"2020-06-01"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // verify that Identity format is an exact match for uri + + var _match = new global::System.Text.RegularExpressions.Regex("(?.+)/providers/Microsoft.CostManagement/alerts/(?[^/]+)$").Match(viaIdentity); + if (!_match.Success) + { + throw new global::System.Exception("Invalid identity for URI '/{scope}/providers/Microsoft.CostManagement/alerts/{alertId}'"); + } + + // replace URI parameters with values from identity + var scope = _match.Groups["scope"].Value; + var alertId = _match.Groups["alertId"].Value; + // construct URL + var _url = new global::System.Uri(global::System.Text.RegularExpressions.Regex.Replace( + "https://management.azure.com/" + + scope + + "/providers/Microsoft.CostManagement/alerts/" + + alertId + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2")); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.URLCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Get, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.RequestCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.HeaderParametersAdded, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.AlertsGet_Call(request,onOk,onDefault,eventListener,sender); + } + } + + /// Actual wire call for method. + /// the prepared HttpRequestMessage to send. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + internal async global::System.Threading.Tasks.Task AlertsGet_Call(global::System.Net.Http.HttpRequestMessage request, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + using( NoSynchronizationContext ) + { + global::System.Net.Http.HttpResponseMessage _response = null; + try + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return; } + _response = await sender.SendAsync(request, eventListener); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + var _contentType = _response.Content.Headers.ContentType?.MediaType; + + switch ( _response.StatusCode ) + { + case global::System.Net.HttpStatusCode.OK: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onOk(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.Alert.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + default: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + } + } + finally + { + // finally statements + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Finally, request, _response); + _response?.Dispose(); + request?.Dispose(); + } + } + } + + /// + /// Validation method for method. Call this like the actual call, but you will get validation events + /// back. + /// + /// The scope associated with alerts operations. This includes '/subscriptions/{subscriptionId}/' for + /// subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for Billing Account scope and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, '/providers/Microsoft.Management/managementGroups/{managementGroupId} for Management Group + /// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile + /// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// Alert ID + /// an instance that will receive events. + /// + /// A that will be complete when handling of the response is completed. + /// + internal async global::System.Threading.Tasks.Task AlertsGet_Validate(string scope, string alertId, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener) + { + using( NoSynchronizationContext ) + { + await eventListener.AssertNotNull(nameof(scope),scope); + await eventListener.AssertNotNull(nameof(alertId),alertId); + } + } + + /// Lists the alerts for scope defined. + /// The scope associated with alerts operations. This includes '/subscriptions/{subscriptionId}/' for + /// subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for Billing Account scope and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, '/providers/Microsoft.Management/managementGroups/{managementGroupId} for Management Group + /// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile + /// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task AlertsList(string scope, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + var apiVersion = @"2020-06-01"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // construct URL + var _url = new global::System.Uri(global::System.Text.RegularExpressions.Regex.Replace( + "https://management.azure.com/" + + (scope) + + "/providers/Microsoft.CostManagement/alerts" + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2")); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.URLCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Get, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.RequestCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.HeaderParametersAdded, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.AlertsList_Call(request,onOk,onDefault,eventListener,sender); + } + } + + /// Lists the Alerts for external cloud provider type defined. + /// The external cloud provider type associated with dimension/query operations. This + /// includes 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated account. + /// This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' + /// for consolidated account used with dimension/query operations. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task AlertsListExternal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExternalCloudProviderType externalCloudProviderType, string externalCloudProviderId, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + var apiVersion = @"2020-06-01"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // construct URL + var _url = new global::System.Uri(global::System.Text.RegularExpressions.Regex.Replace( + "https://management.azure.com/providers/Microsoft.CostManagement/" + + global::System.Uri.EscapeDataString(externalCloudProviderType) + + "/" + + global::System.Uri.EscapeDataString(externalCloudProviderId) + + "/alerts" + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2")); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.URLCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Get, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.RequestCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.HeaderParametersAdded, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.AlertsListExternal_Call(request,onOk,onDefault,eventListener,sender); + } + } + + /// Lists the Alerts for external cloud provider type defined. + /// + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task AlertsListExternalViaIdentity(global::System.String viaIdentity, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + var apiVersion = @"2020-06-01"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // verify that Identity format is an exact match for uri + + var _match = new global::System.Text.RegularExpressions.Regex("^/providers/Microsoft.CostManagement/(?[^/]+)/(?[^/]+)/alerts$").Match(viaIdentity); + if (!_match.Success) + { + throw new global::System.Exception("Invalid identity for URI '/providers/Microsoft.CostManagement/{externalCloudProviderType}/{externalCloudProviderId}/alerts'"); + } + + // replace URI parameters with values from identity + var externalCloudProviderType = _match.Groups["externalCloudProviderType"].Value; + var externalCloudProviderId = _match.Groups["externalCloudProviderId"].Value; + // construct URL + var _url = new global::System.Uri(global::System.Text.RegularExpressions.Regex.Replace( + "https://management.azure.com/providers/Microsoft.CostManagement/" + + externalCloudProviderType + + "/" + + externalCloudProviderId + + "/alerts" + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2")); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.URLCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Get, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.RequestCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.HeaderParametersAdded, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.AlertsListExternal_Call(request,onOk,onDefault,eventListener,sender); + } + } + + /// Actual wire call for method. + /// the prepared HttpRequestMessage to send. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + internal async global::System.Threading.Tasks.Task AlertsListExternal_Call(global::System.Net.Http.HttpRequestMessage request, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + using( NoSynchronizationContext ) + { + global::System.Net.Http.HttpResponseMessage _response = null; + try + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return; } + _response = await sender.SendAsync(request, eventListener); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + var _contentType = _response.Content.Headers.ContentType?.MediaType; + + switch ( _response.StatusCode ) + { + case global::System.Net.HttpStatusCode.OK: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onOk(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.AlertsResult.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + default: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + } + } + finally + { + // finally statements + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Finally, request, _response); + _response?.Dispose(); + request?.Dispose(); + } + } + } + + /// + /// Validation method for method. Call this like the actual call, but you will get validation + /// events back. + /// + /// The external cloud provider type associated with dimension/query operations. This + /// includes 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated account. + /// This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' + /// for consolidated account used with dimension/query operations. + /// an instance that will receive events. + /// + /// A that will be complete when handling of the response is completed. + /// + internal async global::System.Threading.Tasks.Task AlertsListExternal_Validate(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExternalCloudProviderType externalCloudProviderType, string externalCloudProviderId, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener) + { + using( NoSynchronizationContext ) + { + await eventListener.AssertNotNull(nameof(externalCloudProviderType),externalCloudProviderType); + await eventListener.AssertEnum(nameof(externalCloudProviderType),externalCloudProviderType,@"externalSubscriptions", @"externalBillingAccounts"); + await eventListener.AssertNotNull(nameof(externalCloudProviderId),externalCloudProviderId); + } + } + + /// Lists the alerts for scope defined. + /// + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task AlertsListViaIdentity(global::System.String viaIdentity, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + var apiVersion = @"2020-06-01"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // verify that Identity format is an exact match for uri + + var _match = new global::System.Text.RegularExpressions.Regex("(?.+)/providers/Microsoft.CostManagement/alerts$").Match(viaIdentity); + if (!_match.Success) + { + throw new global::System.Exception("Invalid identity for URI '/{scope}/providers/Microsoft.CostManagement/alerts'"); + } + + // replace URI parameters with values from identity + var scope = _match.Groups["scope"].Value; + // construct URL + var _url = new global::System.Uri(global::System.Text.RegularExpressions.Regex.Replace( + "https://management.azure.com/" + + scope + + "/providers/Microsoft.CostManagement/alerts" + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2")); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.URLCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Get, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.RequestCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.HeaderParametersAdded, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.AlertsList_Call(request,onOk,onDefault,eventListener,sender); + } + } + + /// Actual wire call for method. + /// the prepared HttpRequestMessage to send. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + internal async global::System.Threading.Tasks.Task AlertsList_Call(global::System.Net.Http.HttpRequestMessage request, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + using( NoSynchronizationContext ) + { + global::System.Net.Http.HttpResponseMessage _response = null; + try + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return; } + _response = await sender.SendAsync(request, eventListener); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + var _contentType = _response.Content.Headers.ContentType?.MediaType; + + switch ( _response.StatusCode ) + { + case global::System.Net.HttpStatusCode.OK: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onOk(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.AlertsResult.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + default: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + } + } + finally + { + // finally statements + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Finally, request, _response); + _response?.Dispose(); + request?.Dispose(); + } + } + } + + /// + /// Validation method for method. Call this like the actual call, but you will get validation events + /// back. + /// + /// The scope associated with alerts operations. This includes '/subscriptions/{subscriptionId}/' for + /// subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for Billing Account scope and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, '/providers/Microsoft.Management/managementGroups/{managementGroupId} for Management Group + /// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile + /// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// an instance that will receive events. + /// + /// A that will be complete when handling of the response is completed. + /// + internal async global::System.Threading.Tasks.Task AlertsList_Validate(string scope, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener) + { + using( NoSynchronizationContext ) + { + await eventListener.AssertNotNull(nameof(scope),scope); + } + } + + /// Lists the dimensions by the external cloud provider type. + /// The external cloud provider type associated with dimension/query operations. This + /// includes 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated account. + /// This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' + /// for consolidated account used with dimension/query operations. + /// May be used to filter dimensions by properties/category, properties/usageStart, properties/usageEnd. + /// Supported operators are 'eq','lt', 'gt', 'le', 'ge'. + /// May be used to expand the properties/data within a dimension category. By default, data is not included + /// when listing dimensions. + /// Skiptoken is only used if a previous operation returned a partial result. If a previous response + /// contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting + /// point to use for subsequent calls. + /// May be used to limit the number of results to the most recent N dimension data. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task DimensionsByExternalCloudProviderType(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExternalCloudProviderType externalCloudProviderType, string externalCloudProviderId, string Filter, string Expand, string Skiptoken, int? Top, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + var apiVersion = @"2020-06-01"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // construct URL + var _url = new global::System.Uri(global::System.Text.RegularExpressions.Regex.Replace( + "https://management.azure.com/providers/Microsoft.CostManagement/" + + global::System.Uri.EscapeDataString(externalCloudProviderType) + + "/" + + global::System.Uri.EscapeDataString(externalCloudProviderId) + + "/dimensions" + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + + "&" + + (string.IsNullOrEmpty(Filter) ? global::System.String.Empty : "$filter=" + global::System.Uri.EscapeDataString(Filter)) + + "&" + + (string.IsNullOrEmpty(Expand) ? global::System.String.Empty : "$expand=" + global::System.Uri.EscapeDataString(Expand)) + + "&" + + (string.IsNullOrEmpty(Skiptoken) ? global::System.String.Empty : "$skiptoken=" + global::System.Uri.EscapeDataString(Skiptoken)) + + "&" + + (null == Top ? global::System.String.Empty : "$top=" + global::System.Uri.EscapeDataString(Top.ToString())) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2")); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.URLCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Get, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.RequestCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.HeaderParametersAdded, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.DimensionsByExternalCloudProviderType_Call(request,onOk,onDefault,eventListener,sender); + } + } + + /// Lists the dimensions by the external cloud provider type. + /// + /// May be used to filter dimensions by properties/category, properties/usageStart, properties/usageEnd. + /// Supported operators are 'eq','lt', 'gt', 'le', 'ge'. + /// May be used to expand the properties/data within a dimension category. By default, data is not included + /// when listing dimensions. + /// Skiptoken is only used if a previous operation returned a partial result. If a previous response + /// contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting + /// point to use for subsequent calls. + /// May be used to limit the number of results to the most recent N dimension data. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task DimensionsByExternalCloudProviderTypeViaIdentity(global::System.String viaIdentity, string Filter, string Expand, string Skiptoken, int? Top, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + var apiVersion = @"2020-06-01"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // verify that Identity format is an exact match for uri + + var _match = new global::System.Text.RegularExpressions.Regex("^/providers/Microsoft.CostManagement/(?[^/]+)/(?[^/]+)/dimensions$").Match(viaIdentity); + if (!_match.Success) + { + throw new global::System.Exception("Invalid identity for URI '/providers/Microsoft.CostManagement/{externalCloudProviderType}/{externalCloudProviderId}/dimensions'"); + } + + // replace URI parameters with values from identity + var externalCloudProviderType = _match.Groups["externalCloudProviderType"].Value; + var externalCloudProviderId = _match.Groups["externalCloudProviderId"].Value; + // construct URL + var _url = new global::System.Uri(global::System.Text.RegularExpressions.Regex.Replace( + "https://management.azure.com/providers/Microsoft.CostManagement/" + + externalCloudProviderType + + "/" + + externalCloudProviderId + + "/dimensions" + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + + "&" + + (string.IsNullOrEmpty(Filter) ? global::System.String.Empty : "$filter=" + global::System.Uri.EscapeDataString(Filter)) + + "&" + + (string.IsNullOrEmpty(Expand) ? global::System.String.Empty : "$expand=" + global::System.Uri.EscapeDataString(Expand)) + + "&" + + (string.IsNullOrEmpty(Skiptoken) ? global::System.String.Empty : "$skiptoken=" + global::System.Uri.EscapeDataString(Skiptoken)) + + "&" + + (null == Top ? global::System.String.Empty : "$top=" + global::System.Uri.EscapeDataString(Top.ToString())) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2")); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.URLCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Get, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.RequestCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.HeaderParametersAdded, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.DimensionsByExternalCloudProviderType_Call(request,onOk,onDefault,eventListener,sender); + } + } + + /// + /// Actual wire call for method. + /// + /// the prepared HttpRequestMessage to send. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + internal async global::System.Threading.Tasks.Task DimensionsByExternalCloudProviderType_Call(global::System.Net.Http.HttpRequestMessage request, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + using( NoSynchronizationContext ) + { + global::System.Net.Http.HttpResponseMessage _response = null; + try + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return; } + _response = await sender.SendAsync(request, eventListener); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + var _contentType = _response.Content.Headers.ContentType?.MediaType; + + switch ( _response.StatusCode ) + { + case global::System.Net.HttpStatusCode.OK: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onOk(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.DimensionsListResult.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + default: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + } + } + finally + { + // finally statements + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Finally, request, _response); + _response?.Dispose(); + request?.Dispose(); + } + } + } + + /// + /// Validation method for method. Call this like the actual call, but + /// you will get validation events back. + /// + /// The external cloud provider type associated with dimension/query operations. This + /// includes 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated account. + /// This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' + /// for consolidated account used with dimension/query operations. + /// May be used to filter dimensions by properties/category, properties/usageStart, properties/usageEnd. + /// Supported operators are 'eq','lt', 'gt', 'le', 'ge'. + /// May be used to expand the properties/data within a dimension category. By default, data is not included + /// when listing dimensions. + /// Skiptoken is only used if a previous operation returned a partial result. If a previous response + /// contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting + /// point to use for subsequent calls. + /// May be used to limit the number of results to the most recent N dimension data. + /// an instance that will receive events. + /// + /// A that will be complete when handling of the response is completed. + /// + internal async global::System.Threading.Tasks.Task DimensionsByExternalCloudProviderType_Validate(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExternalCloudProviderType externalCloudProviderType, string externalCloudProviderId, string Filter, string Expand, string Skiptoken, int? Top, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener) + { + using( NoSynchronizationContext ) + { + await eventListener.AssertNotNull(nameof(externalCloudProviderType),externalCloudProviderType); + await eventListener.AssertEnum(nameof(externalCloudProviderType),externalCloudProviderType,@"externalSubscriptions", @"externalBillingAccounts"); + await eventListener.AssertNotNull(nameof(externalCloudProviderId),externalCloudProviderId); + await eventListener.AssertNotNull(nameof(Filter),Filter); + await eventListener.AssertNotNull(nameof(Expand),Expand); + await eventListener.AssertNotNull(nameof(Skiptoken),Skiptoken); + await eventListener.AssertIsGreaterThanOrEqual(nameof(Top),Top,1); + await eventListener.AssertIsLessThanOrEqual(nameof(Top),Top,1000); + } + } + + /// Lists the dimensions by the defined scope. + /// The scope associated with dimension operations. This includes '/subscriptions/{subscriptionId}/' for + /// subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for Billing Account scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, '/providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group + /// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile + /// scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// May be used to filter dimensions by properties/category, properties/usageStart, properties/usageEnd. + /// Supported operators are 'eq','lt', 'gt', 'le', 'ge'. + /// May be used to expand the properties/data within a dimension category. By default, data is not included + /// when listing dimensions. + /// Skiptoken is only used if a previous operation returned a partial result. If a previous response + /// contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting + /// point to use for subsequent calls. + /// May be used to limit the number of results to the most recent N dimension data. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task DimensionsList(string scope, string Filter, string Expand, string Skiptoken, int? Top, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + var apiVersion = @"2020-06-01"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // construct URL + var _url = new global::System.Uri(global::System.Text.RegularExpressions.Regex.Replace( + "https://management.azure.com/" + + (scope) + + "/providers/Microsoft.CostManagement/dimensions" + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + + "&" + + (string.IsNullOrEmpty(Filter) ? global::System.String.Empty : "$filter=" + global::System.Uri.EscapeDataString(Filter)) + + "&" + + (string.IsNullOrEmpty(Expand) ? global::System.String.Empty : "$expand=" + global::System.Uri.EscapeDataString(Expand)) + + "&" + + (string.IsNullOrEmpty(Skiptoken) ? global::System.String.Empty : "$skiptoken=" + global::System.Uri.EscapeDataString(Skiptoken)) + + "&" + + (null == Top ? global::System.String.Empty : "$top=" + global::System.Uri.EscapeDataString(Top.ToString())) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2")); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.URLCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Get, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.RequestCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.HeaderParametersAdded, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.DimensionsList_Call(request,onOk,onDefault,eventListener,sender); + } + } + + /// Lists the dimensions by the defined scope. + /// + /// May be used to filter dimensions by properties/category, properties/usageStart, properties/usageEnd. + /// Supported operators are 'eq','lt', 'gt', 'le', 'ge'. + /// May be used to expand the properties/data within a dimension category. By default, data is not included + /// when listing dimensions. + /// Skiptoken is only used if a previous operation returned a partial result. If a previous response + /// contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting + /// point to use for subsequent calls. + /// May be used to limit the number of results to the most recent N dimension data. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task DimensionsListViaIdentity(global::System.String viaIdentity, string Filter, string Expand, string Skiptoken, int? Top, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + var apiVersion = @"2020-06-01"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // verify that Identity format is an exact match for uri + + var _match = new global::System.Text.RegularExpressions.Regex("(?.+)/providers/Microsoft.CostManagement/dimensions$").Match(viaIdentity); + if (!_match.Success) + { + throw new global::System.Exception("Invalid identity for URI '/{scope}/providers/Microsoft.CostManagement/dimensions'"); + } + + // replace URI parameters with values from identity + var scope = _match.Groups["scope"].Value; + // construct URL + var _url = new global::System.Uri(global::System.Text.RegularExpressions.Regex.Replace( + "https://management.azure.com/" + + scope + + "/providers/Microsoft.CostManagement/dimensions" + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + + "&" + + (string.IsNullOrEmpty(Filter) ? global::System.String.Empty : "$filter=" + global::System.Uri.EscapeDataString(Filter)) + + "&" + + (string.IsNullOrEmpty(Expand) ? global::System.String.Empty : "$expand=" + global::System.Uri.EscapeDataString(Expand)) + + "&" + + (string.IsNullOrEmpty(Skiptoken) ? global::System.String.Empty : "$skiptoken=" + global::System.Uri.EscapeDataString(Skiptoken)) + + "&" + + (null == Top ? global::System.String.Empty : "$top=" + global::System.Uri.EscapeDataString(Top.ToString())) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2")); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.URLCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Get, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.RequestCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.HeaderParametersAdded, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.DimensionsList_Call(request,onOk,onDefault,eventListener,sender); + } + } + + /// Actual wire call for method. + /// the prepared HttpRequestMessage to send. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + internal async global::System.Threading.Tasks.Task DimensionsList_Call(global::System.Net.Http.HttpRequestMessage request, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + using( NoSynchronizationContext ) + { + global::System.Net.Http.HttpResponseMessage _response = null; + try + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return; } + _response = await sender.SendAsync(request, eventListener); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + var _contentType = _response.Content.Headers.ContentType?.MediaType; + + switch ( _response.StatusCode ) + { + case global::System.Net.HttpStatusCode.OK: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onOk(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.DimensionsListResult.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + default: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + } + } + finally + { + // finally statements + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Finally, request, _response); + _response?.Dispose(); + request?.Dispose(); + } + } + } + + /// + /// Validation method for method. Call this like the actual call, but you will get validation + /// events back. + /// + /// The scope associated with dimension operations. This includes '/subscriptions/{subscriptionId}/' for + /// subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for Billing Account scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, '/providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group + /// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile + /// scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// May be used to filter dimensions by properties/category, properties/usageStart, properties/usageEnd. + /// Supported operators are 'eq','lt', 'gt', 'le', 'ge'. + /// May be used to expand the properties/data within a dimension category. By default, data is not included + /// when listing dimensions. + /// Skiptoken is only used if a previous operation returned a partial result. If a previous response + /// contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting + /// point to use for subsequent calls. + /// May be used to limit the number of results to the most recent N dimension data. + /// an instance that will receive events. + /// + /// A that will be complete when handling of the response is completed. + /// + internal async global::System.Threading.Tasks.Task DimensionsList_Validate(string scope, string Filter, string Expand, string Skiptoken, int? Top, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener) + { + using( NoSynchronizationContext ) + { + await eventListener.AssertNotNull(nameof(scope),scope); + await eventListener.AssertNotNull(nameof(Filter),Filter); + await eventListener.AssertNotNull(nameof(Expand),Expand); + await eventListener.AssertNotNull(nameof(Skiptoken),Skiptoken); + await eventListener.AssertIsGreaterThanOrEqual(nameof(Top),Top,1); + await eventListener.AssertIsLessThanOrEqual(nameof(Top),Top,1000); + } + } + + /// + /// The operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain + /// the latest eTag by performing a get operation. Create operation does not require eTag. + /// + /// The scope associated with export operations. This includes '/subscriptions/{subscriptionId}/' for + /// subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for Billing Account scope and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, '/providers/Microsoft.Management/managementGroups/{managementGroupId} for Management Group + /// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile + /// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// Export Name. + /// Parameters supplied to the CreateOrUpdate Export operation. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns 201 (Created). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task ExportsCreateOrUpdate(string scope, string exportName, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport body, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onCreated, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + var apiVersion = @"2020-06-01"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // construct URL + var _url = new global::System.Uri(global::System.Text.RegularExpressions.Regex.Replace( + "https://management.azure.com/" + + (scope) + + "/providers/Microsoft.CostManagement/exports/" + + global::System.Uri.EscapeDataString(exportName) + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2")); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.URLCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Put, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.RequestCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.HeaderParametersAdded, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // set body content + request.Content = new global::System.Net.Http.StringContent(null != body ? body.ToJson(null).ToString() : @"{}", global::System.Text.Encoding.UTF8); + request.Content.Headers.ContentType = global::System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BodyContentSet, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.ExportsCreateOrUpdate_Call(request,onOk,onCreated,onDefault,eventListener,sender); + } + } + + /// + /// The operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain + /// the latest eTag by performing a get operation. Create operation does not require eTag. + /// + /// + /// Parameters supplied to the CreateOrUpdate Export operation. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns 201 (Created). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task ExportsCreateOrUpdateViaIdentity(global::System.String viaIdentity, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport body, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onCreated, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + var apiVersion = @"2020-06-01"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // verify that Identity format is an exact match for uri + + var _match = new global::System.Text.RegularExpressions.Regex("(?.+)/providers/Microsoft.CostManagement/exports/(?[^/]+)$").Match(viaIdentity); + if (!_match.Success) + { + throw new global::System.Exception("Invalid identity for URI '/{scope}/providers/Microsoft.CostManagement/exports/{exportName}'"); + } + + // replace URI parameters with values from identity + var scope = _match.Groups["scope"].Value; + var exportName = _match.Groups["exportName"].Value; + // construct URL + var _url = new global::System.Uri(global::System.Text.RegularExpressions.Regex.Replace( + "https://management.azure.com/" + + scope + + "/providers/Microsoft.CostManagement/exports/" + + exportName + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2")); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.URLCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Put, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.RequestCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.HeaderParametersAdded, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // set body content + request.Content = new global::System.Net.Http.StringContent(null != body ? body.ToJson(null).ToString() : @"{}", global::System.Text.Encoding.UTF8); + request.Content.Headers.ContentType = global::System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BodyContentSet, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.ExportsCreateOrUpdate_Call(request,onOk,onCreated,onDefault,eventListener,sender); + } + } + + /// Actual wire call for method. + /// the prepared HttpRequestMessage to send. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns 201 (Created). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + internal async global::System.Threading.Tasks.Task ExportsCreateOrUpdate_Call(global::System.Net.Http.HttpRequestMessage request, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onCreated, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + using( NoSynchronizationContext ) + { + global::System.Net.Http.HttpResponseMessage _response = null; + try + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return; } + _response = await sender.SendAsync(request, eventListener); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + var _contentType = _response.Content.Headers.ContentType?.MediaType; + + switch ( _response.StatusCode ) + { + case global::System.Net.HttpStatusCode.OK: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onOk(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.Export.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + case global::System.Net.HttpStatusCode.Created: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onCreated(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.Export.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + default: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + } + } + finally + { + // finally statements + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Finally, request, _response); + _response?.Dispose(); + request?.Dispose(); + } + } + } + + /// + /// Validation method for method. Call this like the actual call, but you will get validation + /// events back. + /// + /// The scope associated with export operations. This includes '/subscriptions/{subscriptionId}/' for + /// subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for Billing Account scope and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, '/providers/Microsoft.Management/managementGroups/{managementGroupId} for Management Group + /// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile + /// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// Export Name. + /// Parameters supplied to the CreateOrUpdate Export operation. + /// an instance that will receive events. + /// + /// A that will be complete when handling of the response is completed. + /// + internal async global::System.Threading.Tasks.Task ExportsCreateOrUpdate_Validate(string scope, string exportName, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport body, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener) + { + using( NoSynchronizationContext ) + { + await eventListener.AssertNotNull(nameof(scope),scope); + await eventListener.AssertNotNull(nameof(exportName),exportName); + await eventListener.AssertNotNull(nameof(body), body); + await eventListener.AssertObjectIsValid(nameof(body), body); + } + } + + /// The operation to delete a export. + /// The scope associated with export operations. This includes '/subscriptions/{subscriptionId}/' for + /// subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for Billing Account scope and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, '/providers/Microsoft.Management/managementGroups/{managementGroupId} for Management Group + /// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile + /// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// Export Name. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task ExportsDelete(string scope, string exportName, global::System.Func onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + var apiVersion = @"2020-06-01"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // construct URL + var _url = new global::System.Uri(global::System.Text.RegularExpressions.Regex.Replace( + "https://management.azure.com/" + + (scope) + + "/providers/Microsoft.CostManagement/exports/" + + global::System.Uri.EscapeDataString(exportName) + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2")); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.URLCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Delete, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.RequestCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.HeaderParametersAdded, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.ExportsDelete_Call(request,onOk,onDefault,eventListener,sender); + } + } + + /// The operation to delete a export. + /// + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task ExportsDeleteViaIdentity(global::System.String viaIdentity, global::System.Func onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + var apiVersion = @"2020-06-01"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // verify that Identity format is an exact match for uri + + var _match = new global::System.Text.RegularExpressions.Regex("(?.+)/providers/Microsoft.CostManagement/exports/(?[^/]+)$").Match(viaIdentity); + if (!_match.Success) + { + throw new global::System.Exception("Invalid identity for URI '/{scope}/providers/Microsoft.CostManagement/exports/{exportName}'"); + } + + // replace URI parameters with values from identity + var scope = _match.Groups["scope"].Value; + var exportName = _match.Groups["exportName"].Value; + // construct URL + var _url = new global::System.Uri(global::System.Text.RegularExpressions.Regex.Replace( + "https://management.azure.com/" + + scope + + "/providers/Microsoft.CostManagement/exports/" + + exportName + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2")); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.URLCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Delete, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.RequestCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.HeaderParametersAdded, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.ExportsDelete_Call(request,onOk,onDefault,eventListener,sender); + } + } + + /// Actual wire call for method. + /// the prepared HttpRequestMessage to send. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + internal async global::System.Threading.Tasks.Task ExportsDelete_Call(global::System.Net.Http.HttpRequestMessage request, global::System.Func onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + using( NoSynchronizationContext ) + { + global::System.Net.Http.HttpResponseMessage _response = null; + try + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return; } + _response = await sender.SendAsync(request, eventListener); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + var _contentType = _response.Content.Headers.ContentType?.MediaType; + + switch ( _response.StatusCode ) + { + case global::System.Net.HttpStatusCode.OK: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onOk(_response); + break; + } + default: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + } + } + finally + { + // finally statements + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Finally, request, _response); + _response?.Dispose(); + request?.Dispose(); + } + } + } + + /// + /// Validation method for method. Call this like the actual call, but you will get validation + /// events back. + /// + /// The scope associated with export operations. This includes '/subscriptions/{subscriptionId}/' for + /// subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for Billing Account scope and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, '/providers/Microsoft.Management/managementGroups/{managementGroupId} for Management Group + /// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile + /// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// Export Name. + /// an instance that will receive events. + /// + /// A that will be complete when handling of the response is completed. + /// + internal async global::System.Threading.Tasks.Task ExportsDelete_Validate(string scope, string exportName, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener) + { + using( NoSynchronizationContext ) + { + await eventListener.AssertNotNull(nameof(scope),scope); + await eventListener.AssertNotNull(nameof(exportName),exportName); + } + } + + /// The operation to execute an export. + /// The scope associated with export operations. This includes '/subscriptions/{subscriptionId}/' for + /// subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for Billing Account scope and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, '/providers/Microsoft.Management/managementGroups/{managementGroupId} for Management Group + /// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile + /// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// Export Name. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task ExportsExecute(string scope, string exportName, global::System.Func onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + var apiVersion = @"2020-06-01"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // construct URL + var _url = new global::System.Uri(global::System.Text.RegularExpressions.Regex.Replace( + "https://management.azure.com/" + + (scope) + + "/providers/Microsoft.CostManagement/exports/" + + global::System.Uri.EscapeDataString(exportName) + + "/run" + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2")); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.URLCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Post, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.RequestCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.HeaderParametersAdded, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.ExportsExecute_Call(request,onOk,onDefault,eventListener,sender); + } + } + + /// The operation to execute an export. + /// + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task ExportsExecuteViaIdentity(global::System.String viaIdentity, global::System.Func onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + var apiVersion = @"2020-06-01"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // verify that Identity format is an exact match for uri + + var _match = new global::System.Text.RegularExpressions.Regex("(?.+)/providers/Microsoft.CostManagement/exports/(?[^/]+)$").Match(viaIdentity); + if (!_match.Success) + { + throw new global::System.Exception("Invalid identity for URI '/{scope}/providers/Microsoft.CostManagement/exports/{exportName}/run'"); + } + + // replace URI parameters with values from identity + var scope = _match.Groups["scope"].Value; + var exportName = _match.Groups["exportName"].Value; + // construct URL + var _url = new global::System.Uri(global::System.Text.RegularExpressions.Regex.Replace( + "https://management.azure.com/" + + scope + + "/providers/Microsoft.CostManagement/exports/" + + exportName + + "/run" + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2")); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.URLCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Post, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.RequestCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.HeaderParametersAdded, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.ExportsExecute_Call(request,onOk,onDefault,eventListener,sender); + } + } + + /// Actual wire call for method. + /// the prepared HttpRequestMessage to send. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + internal async global::System.Threading.Tasks.Task ExportsExecute_Call(global::System.Net.Http.HttpRequestMessage request, global::System.Func onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + using( NoSynchronizationContext ) + { + global::System.Net.Http.HttpResponseMessage _response = null; + try + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return; } + _response = await sender.SendAsync(request, eventListener); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + var _contentType = _response.Content.Headers.ContentType?.MediaType; + + switch ( _response.StatusCode ) + { + case global::System.Net.HttpStatusCode.OK: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onOk(_response); + break; + } + default: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + } + } + finally + { + // finally statements + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Finally, request, _response); + _response?.Dispose(); + request?.Dispose(); + } + } + } + + /// + /// Validation method for method. Call this like the actual call, but you will get validation + /// events back. + /// + /// The scope associated with export operations. This includes '/subscriptions/{subscriptionId}/' for + /// subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for Billing Account scope and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, '/providers/Microsoft.Management/managementGroups/{managementGroupId} for Management Group + /// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile + /// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// Export Name. + /// an instance that will receive events. + /// + /// A that will be complete when handling of the response is completed. + /// + internal async global::System.Threading.Tasks.Task ExportsExecute_Validate(string scope, string exportName, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener) + { + using( NoSynchronizationContext ) + { + await eventListener.AssertNotNull(nameof(scope),scope); + await eventListener.AssertNotNull(nameof(exportName),exportName); + } + } + + /// The operation to get the export for the defined scope by export name. + /// The scope associated with export operations. This includes '/subscriptions/{subscriptionId}/' for + /// subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for Billing Account scope and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, '/providers/Microsoft.Management/managementGroups/{managementGroupId} for Management Group + /// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile + /// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// Export Name. + /// May be used to expand the properties within an export. Currently only 'runHistory' is supported and + /// will return information for the last 10 executions of the export. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task ExportsGet(string scope, string exportName, string Expand, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + var apiVersion = @"2020-06-01"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // construct URL + var _url = new global::System.Uri(global::System.Text.RegularExpressions.Regex.Replace( + "https://management.azure.com/" + + (scope) + + "/providers/Microsoft.CostManagement/exports/" + + global::System.Uri.EscapeDataString(exportName) + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + + "&" + + (string.IsNullOrEmpty(Expand) ? global::System.String.Empty : "$expand=" + global::System.Uri.EscapeDataString(Expand)) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2")); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.URLCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Get, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.RequestCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.HeaderParametersAdded, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.ExportsGet_Call(request,onOk,onDefault,eventListener,sender); + } + } + + /// + /// The operation to get the execution history of an export for the defined scope and export name. + /// + /// The scope associated with export operations. This includes '/subscriptions/{subscriptionId}/' for + /// subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for Billing Account scope and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, '/providers/Microsoft.Management/managementGroups/{managementGroupId} for Management Group + /// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile + /// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// Export Name. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task ExportsGetExecutionHistory(string scope, string exportName, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + var apiVersion = @"2020-06-01"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // construct URL + var _url = new global::System.Uri(global::System.Text.RegularExpressions.Regex.Replace( + "https://management.azure.com/" + + (scope) + + "/providers/Microsoft.CostManagement/exports/" + + global::System.Uri.EscapeDataString(exportName) + + "/runHistory" + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2")); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.URLCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Get, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.RequestCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.HeaderParametersAdded, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.ExportsGetExecutionHistory_Call(request,onOk,onDefault,eventListener,sender); + } + } + + /// + /// The operation to get the execution history of an export for the defined scope and export name. + /// + /// + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task ExportsGetExecutionHistoryViaIdentity(global::System.String viaIdentity, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + var apiVersion = @"2020-06-01"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // verify that Identity format is an exact match for uri + + var _match = new global::System.Text.RegularExpressions.Regex("(?.+)/providers/Microsoft.CostManagement/exports/(?[^/]+)$").Match(viaIdentity); + if (!_match.Success) + { + throw new global::System.Exception("Invalid identity for URI '/{scope}/providers/Microsoft.CostManagement/exports/{exportName}/runHistory'"); + } + + // replace URI parameters with values from identity + var scope = _match.Groups["scope"].Value; + var exportName = _match.Groups["exportName"].Value; + // construct URL + var _url = new global::System.Uri(global::System.Text.RegularExpressions.Regex.Replace( + "https://management.azure.com/" + + scope + + "/providers/Microsoft.CostManagement/exports/" + + exportName + + "/runHistory" + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2")); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.URLCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Get, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.RequestCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.HeaderParametersAdded, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.ExportsGetExecutionHistory_Call(request,onOk,onDefault,eventListener,sender); + } + } + + /// Actual wire call for method. + /// the prepared HttpRequestMessage to send. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + internal async global::System.Threading.Tasks.Task ExportsGetExecutionHistory_Call(global::System.Net.Http.HttpRequestMessage request, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + using( NoSynchronizationContext ) + { + global::System.Net.Http.HttpResponseMessage _response = null; + try + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return; } + _response = await sender.SendAsync(request, eventListener); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + var _contentType = _response.Content.Headers.ContentType?.MediaType; + + switch ( _response.StatusCode ) + { + case global::System.Net.HttpStatusCode.OK: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onOk(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportExecutionListResult.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + default: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + } + } + finally + { + // finally statements + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Finally, request, _response); + _response?.Dispose(); + request?.Dispose(); + } + } + } + + /// + /// Validation method for method. Call this like the actual call, but you will get + /// validation events back. + /// + /// The scope associated with export operations. This includes '/subscriptions/{subscriptionId}/' for + /// subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for Billing Account scope and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, '/providers/Microsoft.Management/managementGroups/{managementGroupId} for Management Group + /// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile + /// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// Export Name. + /// an instance that will receive events. + /// + /// A that will be complete when handling of the response is completed. + /// + internal async global::System.Threading.Tasks.Task ExportsGetExecutionHistory_Validate(string scope, string exportName, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener) + { + using( NoSynchronizationContext ) + { + await eventListener.AssertNotNull(nameof(scope),scope); + await eventListener.AssertNotNull(nameof(exportName),exportName); + } + } + + /// The operation to get the export for the defined scope by export name. + /// + /// May be used to expand the properties within an export. Currently only 'runHistory' is supported and + /// will return information for the last 10 executions of the export. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task ExportsGetViaIdentity(global::System.String viaIdentity, string Expand, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + var apiVersion = @"2020-06-01"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // verify that Identity format is an exact match for uri + + var _match = new global::System.Text.RegularExpressions.Regex("(?.+)/providers/Microsoft.CostManagement/exports/(?[^/]+)$").Match(viaIdentity); + if (!_match.Success) + { + throw new global::System.Exception("Invalid identity for URI '/{scope}/providers/Microsoft.CostManagement/exports/{exportName}'"); + } + + // replace URI parameters with values from identity + var scope = _match.Groups["scope"].Value; + var exportName = _match.Groups["exportName"].Value; + // construct URL + var _url = new global::System.Uri(global::System.Text.RegularExpressions.Regex.Replace( + "https://management.azure.com/" + + scope + + "/providers/Microsoft.CostManagement/exports/" + + exportName + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + + "&" + + (string.IsNullOrEmpty(Expand) ? global::System.String.Empty : "$expand=" + global::System.Uri.EscapeDataString(Expand)) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2")); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.URLCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Get, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.RequestCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.HeaderParametersAdded, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.ExportsGet_Call(request,onOk,onDefault,eventListener,sender); + } + } + + /// Actual wire call for method. + /// the prepared HttpRequestMessage to send. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + internal async global::System.Threading.Tasks.Task ExportsGet_Call(global::System.Net.Http.HttpRequestMessage request, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + using( NoSynchronizationContext ) + { + global::System.Net.Http.HttpResponseMessage _response = null; + try + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return; } + _response = await sender.SendAsync(request, eventListener); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + var _contentType = _response.Content.Headers.ContentType?.MediaType; + + switch ( _response.StatusCode ) + { + case global::System.Net.HttpStatusCode.OK: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onOk(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.Export.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + default: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + } + } + finally + { + // finally statements + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Finally, request, _response); + _response?.Dispose(); + request?.Dispose(); + } + } + } + + /// + /// Validation method for method. Call this like the actual call, but you will get validation events + /// back. + /// + /// The scope associated with export operations. This includes '/subscriptions/{subscriptionId}/' for + /// subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for Billing Account scope and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, '/providers/Microsoft.Management/managementGroups/{managementGroupId} for Management Group + /// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile + /// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// Export Name. + /// May be used to expand the properties within an export. Currently only 'runHistory' is supported and + /// will return information for the last 10 executions of the export. + /// an instance that will receive events. + /// + /// A that will be complete when handling of the response is completed. + /// + internal async global::System.Threading.Tasks.Task ExportsGet_Validate(string scope, string exportName, string Expand, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener) + { + using( NoSynchronizationContext ) + { + await eventListener.AssertNotNull(nameof(scope),scope); + await eventListener.AssertNotNull(nameof(exportName),exportName); + await eventListener.AssertNotNull(nameof(Expand),Expand); + } + } + + /// The operation to list all exports at the given scope. + /// The scope associated with export operations. This includes '/subscriptions/{subscriptionId}/' for + /// subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for Billing Account scope and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, '/providers/Microsoft.Management/managementGroups/{managementGroupId} for Management Group + /// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile + /// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// May be used to expand the properties within an export. Currently only 'runHistory' is supported and + /// will return information for the last execution of each export. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task ExportsList(string scope, string Expand, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + var apiVersion = @"2020-06-01"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // construct URL + var _url = new global::System.Uri(global::System.Text.RegularExpressions.Regex.Replace( + "https://management.azure.com/" + + (scope) + + "/providers/Microsoft.CostManagement/exports" + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + + "&" + + (string.IsNullOrEmpty(Expand) ? global::System.String.Empty : "$expand=" + global::System.Uri.EscapeDataString(Expand)) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2")); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.URLCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Get, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.RequestCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.HeaderParametersAdded, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.ExportsList_Call(request,onOk,onDefault,eventListener,sender); + } + } + + /// The operation to list all exports at the given scope. + /// + /// May be used to expand the properties within an export. Currently only 'runHistory' is supported and + /// will return information for the last execution of each export. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task ExportsListViaIdentity(global::System.String viaIdentity, string Expand, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + var apiVersion = @"2020-06-01"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // verify that Identity format is an exact match for uri + + var _match = new global::System.Text.RegularExpressions.Regex("(?.+)/providers/Microsoft.CostManagement/exports$").Match(viaIdentity); + if (!_match.Success) + { + throw new global::System.Exception("Invalid identity for URI '/{scope}/providers/Microsoft.CostManagement/exports'"); + } + + // replace URI parameters with values from identity + var scope = _match.Groups["scope"].Value; + // construct URL + var _url = new global::System.Uri(global::System.Text.RegularExpressions.Regex.Replace( + "https://management.azure.com/" + + scope + + "/providers/Microsoft.CostManagement/exports" + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + + "&" + + (string.IsNullOrEmpty(Expand) ? global::System.String.Empty : "$expand=" + global::System.Uri.EscapeDataString(Expand)) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2")); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.URLCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Get, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.RequestCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.HeaderParametersAdded, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.ExportsList_Call(request,onOk,onDefault,eventListener,sender); + } + } + + /// Actual wire call for method. + /// the prepared HttpRequestMessage to send. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + internal async global::System.Threading.Tasks.Task ExportsList_Call(global::System.Net.Http.HttpRequestMessage request, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + using( NoSynchronizationContext ) + { + global::System.Net.Http.HttpResponseMessage _response = null; + try + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return; } + _response = await sender.SendAsync(request, eventListener); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + var _contentType = _response.Content.Headers.ContentType?.MediaType; + + switch ( _response.StatusCode ) + { + case global::System.Net.HttpStatusCode.OK: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onOk(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportListResult.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + default: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + } + } + finally + { + // finally statements + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Finally, request, _response); + _response?.Dispose(); + request?.Dispose(); + } + } + } + + /// + /// Validation method for method. Call this like the actual call, but you will get validation events + /// back. + /// + /// The scope associated with export operations. This includes '/subscriptions/{subscriptionId}/' for + /// subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for Billing Account scope and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, '/providers/Microsoft.Management/managementGroups/{managementGroupId} for Management Group + /// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile + /// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// May be used to expand the properties within an export. Currently only 'runHistory' is supported and + /// will return information for the last execution of each export. + /// an instance that will receive events. + /// + /// A that will be complete when handling of the response is completed. + /// + internal async global::System.Threading.Tasks.Task ExportsList_Validate(string scope, string Expand, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener) + { + using( NoSynchronizationContext ) + { + await eventListener.AssertNotNull(nameof(scope),scope); + await eventListener.AssertNotNull(nameof(Expand),Expand); + } + } + + /// Lists the forecast charges for external cloud provider type defined. + /// May be used to filter forecasts by properties/usageDate (Utc time), properties/chargeType or properties/grain. + /// The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + /// The external cloud provider type associated with dimension/query operations. This + /// includes 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated account. + /// This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' + /// for consolidated account used with dimension/query operations. + /// Parameters supplied to the CreateOrUpdate Forecast Config operation. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task ForecastExternalCloudProviderUsage(string Filter, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExternalCloudProviderType externalCloudProviderType, string externalCloudProviderId, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinition body, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + var apiVersion = @"2020-06-01"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // construct URL + var _url = new global::System.Uri(global::System.Text.RegularExpressions.Regex.Replace( + "https://management.azure.com/providers/Microsoft.CostManagement/" + + global::System.Uri.EscapeDataString(externalCloudProviderType) + + "/" + + global::System.Uri.EscapeDataString(externalCloudProviderId) + + "/forecast" + + "?" + + (string.IsNullOrEmpty(Filter) ? global::System.String.Empty : "$filter=" + global::System.Uri.EscapeDataString(Filter)) + + "&" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2")); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.URLCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Post, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.RequestCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.HeaderParametersAdded, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // set body content + request.Content = new global::System.Net.Http.StringContent(null != body ? body.ToJson(null).ToString() : @"{}", global::System.Text.Encoding.UTF8); + request.Content.Headers.ContentType = global::System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BodyContentSet, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.ForecastExternalCloudProviderUsage_Call(request,onOk,onDefault,eventListener,sender); + } + } + + /// Lists the forecast charges for external cloud provider type defined. + /// + /// May be used to filter forecasts by properties/usageDate (Utc time), properties/chargeType or properties/grain. + /// The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + /// Parameters supplied to the CreateOrUpdate Forecast Config operation. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task ForecastExternalCloudProviderUsageViaIdentity(global::System.String viaIdentity, string Filter, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinition body, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + var apiVersion = @"2020-06-01"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // verify that Identity format is an exact match for uri + + var _match = new global::System.Text.RegularExpressions.Regex("^/providers/Microsoft.CostManagement/(?[^/]+)/(?[^/]+)$").Match(viaIdentity); + if (!_match.Success) + { + throw new global::System.Exception("Invalid identity for URI '/providers/Microsoft.CostManagement/{externalCloudProviderType}/{externalCloudProviderId}/forecast'"); + } + + // replace URI parameters with values from identity + var externalCloudProviderType = _match.Groups["externalCloudProviderType"].Value; + var externalCloudProviderId = _match.Groups["externalCloudProviderId"].Value; + // construct URL + var _url = new global::System.Uri(global::System.Text.RegularExpressions.Regex.Replace( + "https://management.azure.com/providers/Microsoft.CostManagement/" + + externalCloudProviderType + + "/" + + externalCloudProviderId + + "/forecast" + + "?" + + (string.IsNullOrEmpty(Filter) ? global::System.String.Empty : "$filter=" + global::System.Uri.EscapeDataString(Filter)) + + "&" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2")); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.URLCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Post, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.RequestCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.HeaderParametersAdded, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // set body content + request.Content = new global::System.Net.Http.StringContent(null != body ? body.ToJson(null).ToString() : @"{}", global::System.Text.Encoding.UTF8); + request.Content.Headers.ContentType = global::System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BodyContentSet, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.ForecastExternalCloudProviderUsage_Call(request,onOk,onDefault,eventListener,sender); + } + } + + /// Actual wire call for method. + /// the prepared HttpRequestMessage to send. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + internal async global::System.Threading.Tasks.Task ForecastExternalCloudProviderUsage_Call(global::System.Net.Http.HttpRequestMessage request, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + using( NoSynchronizationContext ) + { + global::System.Net.Http.HttpResponseMessage _response = null; + try + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return; } + _response = await sender.SendAsync(request, eventListener); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + var _contentType = _response.Content.Headers.ContentType?.MediaType; + + switch ( _response.StatusCode ) + { + case global::System.Net.HttpStatusCode.OK: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onOk(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryResult.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + default: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + } + } + finally + { + // finally statements + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Finally, request, _response); + _response?.Dispose(); + request?.Dispose(); + } + } + } + + /// + /// Validation method for method. Call this like the actual call, but you + /// will get validation events back. + /// + /// May be used to filter forecasts by properties/usageDate (Utc time), properties/chargeType or properties/grain. + /// The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + /// The external cloud provider type associated with dimension/query operations. This + /// includes 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated account. + /// This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' + /// for consolidated account used with dimension/query operations. + /// Parameters supplied to the CreateOrUpdate Forecast Config operation. + /// an instance that will receive events. + /// + /// A that will be complete when handling of the response is completed. + /// + internal async global::System.Threading.Tasks.Task ForecastExternalCloudProviderUsage_Validate(string Filter, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExternalCloudProviderType externalCloudProviderType, string externalCloudProviderId, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinition body, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener) + { + using( NoSynchronizationContext ) + { + await eventListener.AssertNotNull(nameof(Filter),Filter); + await eventListener.AssertNotNull(nameof(externalCloudProviderType),externalCloudProviderType); + await eventListener.AssertEnum(nameof(externalCloudProviderType),externalCloudProviderType,@"externalSubscriptions", @"externalBillingAccounts"); + await eventListener.AssertNotNull(nameof(externalCloudProviderId),externalCloudProviderId); + await eventListener.AssertNotNull(nameof(body), body); + await eventListener.AssertObjectIsValid(nameof(body), body); + } + } + + /// Lists the forecast charges for scope defined. + /// May be used to filter forecasts by properties/usageDate (Utc time), properties/chargeType or properties/grain. + /// The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + /// The scope associated with forecast operations. This includes '/subscriptions/{subscriptionId}/' for + /// subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for Billing Account scope and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, '/providers/Microsoft.Management/managementGroups/{managementGroupId} for Management Group + /// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile + /// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// Parameters supplied to the CreateOrUpdate Forecast Config operation. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task ForecastUsage(string Filter, string scope, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinition body, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + var apiVersion = @"2020-06-01"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // construct URL + var _url = new global::System.Uri(global::System.Text.RegularExpressions.Regex.Replace( + "https://management.azure.com/" + + (scope) + + "/providers/Microsoft.CostManagement/forecast" + + "?" + + (string.IsNullOrEmpty(Filter) ? global::System.String.Empty : "$filter=" + global::System.Uri.EscapeDataString(Filter)) + + "&" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2")); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.URLCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Post, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.RequestCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.HeaderParametersAdded, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // set body content + request.Content = new global::System.Net.Http.StringContent(null != body ? body.ToJson(null).ToString() : @"{}", global::System.Text.Encoding.UTF8); + request.Content.Headers.ContentType = global::System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BodyContentSet, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.ForecastUsage_Call(request,onOk,onDefault,eventListener,sender); + } + } + + /// Lists the forecast charges for scope defined. + /// + /// May be used to filter forecasts by properties/usageDate (Utc time), properties/chargeType or properties/grain. + /// The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + /// Parameters supplied to the CreateOrUpdate Forecast Config operation. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task ForecastUsageViaIdentity(global::System.String viaIdentity, string Filter, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinition body, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + var apiVersion = @"2020-06-01"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // verify that Identity format is an exact match for uri + + var _match = new global::System.Text.RegularExpressions.Regex("(?.+)/providers/Microsoft.CostManagement$").Match(viaIdentity); + if (!_match.Success) + { + throw new global::System.Exception("Invalid identity for URI '/{scope}/providers/Microsoft.CostManagement/forecast'"); + } + + // replace URI parameters with values from identity + var scope = _match.Groups["scope"].Value; + // construct URL + var _url = new global::System.Uri(global::System.Text.RegularExpressions.Regex.Replace( + "https://management.azure.com/" + + scope + + "/providers/Microsoft.CostManagement/forecast" + + "?" + + (string.IsNullOrEmpty(Filter) ? global::System.String.Empty : "$filter=" + global::System.Uri.EscapeDataString(Filter)) + + "&" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2")); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.URLCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Post, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.RequestCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.HeaderParametersAdded, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // set body content + request.Content = new global::System.Net.Http.StringContent(null != body ? body.ToJson(null).ToString() : @"{}", global::System.Text.Encoding.UTF8); + request.Content.Headers.ContentType = global::System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BodyContentSet, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.ForecastUsage_Call(request,onOk,onDefault,eventListener,sender); + } + } + + /// Actual wire call for method. + /// the prepared HttpRequestMessage to send. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + internal async global::System.Threading.Tasks.Task ForecastUsage_Call(global::System.Net.Http.HttpRequestMessage request, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + using( NoSynchronizationContext ) + { + global::System.Net.Http.HttpResponseMessage _response = null; + try + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return; } + _response = await sender.SendAsync(request, eventListener); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + var _contentType = _response.Content.Headers.ContentType?.MediaType; + + switch ( _response.StatusCode ) + { + case global::System.Net.HttpStatusCode.OK: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onOk(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryResult.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + default: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + } + } + finally + { + // finally statements + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Finally, request, _response); + _response?.Dispose(); + request?.Dispose(); + } + } + } + + /// + /// Validation method for method. Call this like the actual call, but you will get validation + /// events back. + /// + /// May be used to filter forecasts by properties/usageDate (Utc time), properties/chargeType or properties/grain. + /// The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + /// The scope associated with forecast operations. This includes '/subscriptions/{subscriptionId}/' for + /// subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for Billing Account scope and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, '/providers/Microsoft.Management/managementGroups/{managementGroupId} for Management Group + /// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile + /// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// Parameters supplied to the CreateOrUpdate Forecast Config operation. + /// an instance that will receive events. + /// + /// A that will be complete when handling of the response is completed. + /// + internal async global::System.Threading.Tasks.Task ForecastUsage_Validate(string Filter, string scope, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinition body, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener) + { + using( NoSynchronizationContext ) + { + await eventListener.AssertNotNull(nameof(Filter),Filter); + await eventListener.AssertNotNull(nameof(scope),scope); + await eventListener.AssertNotNull(nameof(body), body); + await eventListener.AssertObjectIsValid(nameof(body), body); + } + } + + /// Lists all of the available cost management REST API operations. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task OperationsList(global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + var apiVersion = @"2020-06-01"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // construct URL + var _url = new global::System.Uri(global::System.Text.RegularExpressions.Regex.Replace( + "https://management.azure.com/providers/Microsoft.CostManagement/operations" + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2")); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.URLCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Get, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.RequestCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.HeaderParametersAdded, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.OperationsList_Call(request,onOk,onDefault,eventListener,sender); + } + } + + /// Lists all of the available cost management REST API operations. + /// + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task OperationsListViaIdentity(global::System.String viaIdentity, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + var apiVersion = @"2020-06-01"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // verify that Identity format is an exact match for uri + + var _match = new global::System.Text.RegularExpressions.Regex("^/providers/Microsoft.CostManagement/operations$").Match(viaIdentity); + if (!_match.Success) + { + throw new global::System.Exception("Invalid identity for URI '/providers/Microsoft.CostManagement/operations'"); + } + + // replace URI parameters with values from identity + // construct URL + var _url = new global::System.Uri(global::System.Text.RegularExpressions.Regex.Replace( + "https://management.azure.com/providers/Microsoft.CostManagement/operations" + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2")); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.URLCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Get, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.RequestCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.HeaderParametersAdded, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.OperationsList_Call(request,onOk,onDefault,eventListener,sender); + } + } + + /// Actual wire call for method. + /// the prepared HttpRequestMessage to send. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + internal async global::System.Threading.Tasks.Task OperationsList_Call(global::System.Net.Http.HttpRequestMessage request, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + using( NoSynchronizationContext ) + { + global::System.Net.Http.HttpResponseMessage _response = null; + try + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return; } + _response = await sender.SendAsync(request, eventListener); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + var _contentType = _response.Content.Headers.ContentType?.MediaType; + + switch ( _response.StatusCode ) + { + case global::System.Net.HttpStatusCode.OK: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onOk(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.OperationListResult.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + default: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + } + } + finally + { + // finally statements + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Finally, request, _response); + _response?.Dispose(); + request?.Dispose(); + } + } + } + + /// + /// Validation method for method. Call this like the actual call, but you will get validation + /// events back. + /// + /// an instance that will receive events. + /// + /// A that will be complete when handling of the response is completed. + /// + internal async global::System.Threading.Tasks.Task OperationsList_Validate(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener) + { + using( NoSynchronizationContext ) + { + + } + } + + /// Query the usage data for scope defined. + /// The scope associated with query and export operations. This includes '/subscriptions/{subscriptionId}/' + /// for subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, '/providers/Microsoft.Management/managementGroups/{managementGroupId} for Management Group + /// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile + /// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// Parameters supplied to the CreateOrUpdate Query Config operation. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task QueryUsage(string scope, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinition body, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + var apiVersion = @"2020-06-01"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // construct URL + var _url = new global::System.Uri(global::System.Text.RegularExpressions.Regex.Replace( + "https://management.azure.com/" + + (scope) + + "/providers/Microsoft.CostManagement/query" + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2")); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.URLCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Post, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.RequestCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.HeaderParametersAdded, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // set body content + request.Content = new global::System.Net.Http.StringContent(null != body ? body.ToJson(null).ToString() : @"{}", global::System.Text.Encoding.UTF8); + request.Content.Headers.ContentType = global::System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BodyContentSet, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.QueryUsage_Call(request,onOk,onDefault,eventListener,sender); + } + } + + /// Query the usage data for external cloud provider type defined. + /// The external cloud provider type associated with dimension/query operations. This + /// includes 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated account. + /// This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' + /// for consolidated account used with dimension/query operations. + /// Parameters supplied to the CreateOrUpdate Query Config operation. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task QueryUsageByExternalCloudProviderType(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExternalCloudProviderType externalCloudProviderType, string externalCloudProviderId, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinition body, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + var apiVersion = @"2020-06-01"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // construct URL + var _url = new global::System.Uri(global::System.Text.RegularExpressions.Regex.Replace( + "https://management.azure.com/providers/Microsoft.CostManagement/" + + global::System.Uri.EscapeDataString(externalCloudProviderType) + + "/" + + global::System.Uri.EscapeDataString(externalCloudProviderId) + + "/query" + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2")); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.URLCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Post, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.RequestCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.HeaderParametersAdded, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // set body content + request.Content = new global::System.Net.Http.StringContent(null != body ? body.ToJson(null).ToString() : @"{}", global::System.Text.Encoding.UTF8); + request.Content.Headers.ContentType = global::System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BodyContentSet, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.QueryUsageByExternalCloudProviderType_Call(request,onOk,onDefault,eventListener,sender); + } + } + + /// Query the usage data for external cloud provider type defined. + /// + /// Parameters supplied to the CreateOrUpdate Query Config operation. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task QueryUsageByExternalCloudProviderTypeViaIdentity(global::System.String viaIdentity, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinition body, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + var apiVersion = @"2020-06-01"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // verify that Identity format is an exact match for uri + + var _match = new global::System.Text.RegularExpressions.Regex("^/providers/Microsoft.CostManagement/(?[^/]+)/(?[^/]+)$").Match(viaIdentity); + if (!_match.Success) + { + throw new global::System.Exception("Invalid identity for URI '/providers/Microsoft.CostManagement/{externalCloudProviderType}/{externalCloudProviderId}/query'"); + } + + // replace URI parameters with values from identity + var externalCloudProviderType = _match.Groups["externalCloudProviderType"].Value; + var externalCloudProviderId = _match.Groups["externalCloudProviderId"].Value; + // construct URL + var _url = new global::System.Uri(global::System.Text.RegularExpressions.Regex.Replace( + "https://management.azure.com/providers/Microsoft.CostManagement/" + + externalCloudProviderType + + "/" + + externalCloudProviderId + + "/query" + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2")); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.URLCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Post, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.RequestCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.HeaderParametersAdded, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // set body content + request.Content = new global::System.Net.Http.StringContent(null != body ? body.ToJson(null).ToString() : @"{}", global::System.Text.Encoding.UTF8); + request.Content.Headers.ContentType = global::System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BodyContentSet, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.QueryUsageByExternalCloudProviderType_Call(request,onOk,onDefault,eventListener,sender); + } + } + + /// + /// Actual wire call for method. + /// + /// the prepared HttpRequestMessage to send. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + internal async global::System.Threading.Tasks.Task QueryUsageByExternalCloudProviderType_Call(global::System.Net.Http.HttpRequestMessage request, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + using( NoSynchronizationContext ) + { + global::System.Net.Http.HttpResponseMessage _response = null; + try + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return; } + _response = await sender.SendAsync(request, eventListener); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + var _contentType = _response.Content.Headers.ContentType?.MediaType; + + switch ( _response.StatusCode ) + { + case global::System.Net.HttpStatusCode.OK: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onOk(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryResult.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + default: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + } + } + finally + { + // finally statements + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Finally, request, _response); + _response?.Dispose(); + request?.Dispose(); + } + } + } + + /// + /// Validation method for method. Call this like the actual call, but + /// you will get validation events back. + /// + /// The external cloud provider type associated with dimension/query operations. This + /// includes 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated account. + /// This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' + /// for consolidated account used with dimension/query operations. + /// Parameters supplied to the CreateOrUpdate Query Config operation. + /// an instance that will receive events. + /// + /// A that will be complete when handling of the response is completed. + /// + internal async global::System.Threading.Tasks.Task QueryUsageByExternalCloudProviderType_Validate(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExternalCloudProviderType externalCloudProviderType, string externalCloudProviderId, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinition body, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener) + { + using( NoSynchronizationContext ) + { + await eventListener.AssertNotNull(nameof(externalCloudProviderType),externalCloudProviderType); + await eventListener.AssertEnum(nameof(externalCloudProviderType),externalCloudProviderType,@"externalSubscriptions", @"externalBillingAccounts"); + await eventListener.AssertNotNull(nameof(externalCloudProviderId),externalCloudProviderId); + await eventListener.AssertNotNull(nameof(body), body); + await eventListener.AssertObjectIsValid(nameof(body), body); + } + } + + /// Query the usage data for scope defined. + /// + /// Parameters supplied to the CreateOrUpdate Query Config operation. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task QueryUsageViaIdentity(global::System.String viaIdentity, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinition body, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + var apiVersion = @"2020-06-01"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // verify that Identity format is an exact match for uri + + var _match = new global::System.Text.RegularExpressions.Regex("(?.+)/providers/Microsoft.CostManagement$").Match(viaIdentity); + if (!_match.Success) + { + throw new global::System.Exception("Invalid identity for URI '/{scope}/providers/Microsoft.CostManagement/query'"); + } + + // replace URI parameters with values from identity + var scope = _match.Groups["scope"].Value; + // construct URL + var _url = new global::System.Uri(global::System.Text.RegularExpressions.Regex.Replace( + "https://management.azure.com/" + + scope + + "/providers/Microsoft.CostManagement/query" + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2")); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.URLCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Post, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.RequestCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.HeaderParametersAdded, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // set body content + request.Content = new global::System.Net.Http.StringContent(null != body ? body.ToJson(null).ToString() : @"{}", global::System.Text.Encoding.UTF8); + request.Content.Headers.ContentType = global::System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BodyContentSet, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.QueryUsage_Call(request,onOk,onDefault,eventListener,sender); + } + } + + /// Actual wire call for method. + /// the prepared HttpRequestMessage to send. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + internal async global::System.Threading.Tasks.Task QueryUsage_Call(global::System.Net.Http.HttpRequestMessage request, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + using( NoSynchronizationContext ) + { + global::System.Net.Http.HttpResponseMessage _response = null; + try + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return; } + _response = await sender.SendAsync(request, eventListener); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + var _contentType = _response.Content.Headers.ContentType?.MediaType; + + switch ( _response.StatusCode ) + { + case global::System.Net.HttpStatusCode.OK: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onOk(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryResult.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + default: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + } + } + finally + { + // finally statements + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Finally, request, _response); + _response?.Dispose(); + request?.Dispose(); + } + } + } + + /// + /// Validation method for method. Call this like the actual call, but you will get validation events + /// back. + /// + /// The scope associated with query and export operations. This includes '/subscriptions/{subscriptionId}/' + /// for subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, + /// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, '/providers/Microsoft.Management/managementGroups/{managementGroupId} for Management Group + /// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile + /// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + /// for invoiceSection scope, and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + /// specific for partners. + /// Parameters supplied to the CreateOrUpdate Query Config operation. + /// an instance that will receive events. + /// + /// A that will be complete when handling of the response is completed. + /// + internal async global::System.Threading.Tasks.Task QueryUsage_Validate(string scope, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinition body, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener) + { + using( NoSynchronizationContext ) + { + await eventListener.AssertNotNull(nameof(scope),scope); + await eventListener.AssertNotNull(nameof(body), body); + await eventListener.AssertObjectIsValid(nameof(body), body); + } + } + + /// + /// The operation to create or update a view. Update operation requires latest eTag to be set in the request. You may obtain + /// the latest eTag by performing a get operation. Create operation does not require eTag. + /// + /// View name + /// Parameters supplied to the CreateOrUpdate View operation. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns 201 (Created). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task ViewsCreateOrUpdate(string viewName, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IView body, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onCreated, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + var apiVersion = @"2020-06-01"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // construct URL + var _url = new global::System.Uri(global::System.Text.RegularExpressions.Regex.Replace( + "https://management.azure.com/providers/Microsoft.CostManagement/views/" + + global::System.Uri.EscapeDataString(viewName) + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2")); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.URLCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Put, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.RequestCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.HeaderParametersAdded, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // set body content + request.Content = new global::System.Net.Http.StringContent(null != body ? body.ToJson(null).ToString() : @"{}", global::System.Text.Encoding.UTF8); + request.Content.Headers.ContentType = global::System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BodyContentSet, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.ViewsCreateOrUpdate_Call(request,onOk,onCreated,onDefault,eventListener,sender); + } + } + + /// + /// The operation to create or update a view. Update operation requires latest eTag to be set in the request. You may obtain + /// the latest eTag by performing a get operation. Create operation does not require eTag. + /// + /// The scope associated with view operations. This includes 'subscriptions/{subscriptionId}' for subscription + /// scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for External Billing Account + /// scope and 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for External Subscription + /// scope. + /// View name + /// Parameters supplied to the CreateOrUpdate View operation. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns 201 (Created). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task ViewsCreateOrUpdateByScope(string scope, string viewName, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IView body, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onCreated, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + var apiVersion = @"2020-06-01"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // construct URL + var _url = new global::System.Uri(global::System.Text.RegularExpressions.Regex.Replace( + "https://management.azure.com/" + + global::System.Uri.EscapeDataString(scope) + + "/providers/Microsoft.CostManagement/views/" + + global::System.Uri.EscapeDataString(viewName) + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2")); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.URLCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Put, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.RequestCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.HeaderParametersAdded, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // set body content + request.Content = new global::System.Net.Http.StringContent(null != body ? body.ToJson(null).ToString() : @"{}", global::System.Text.Encoding.UTF8); + request.Content.Headers.ContentType = global::System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BodyContentSet, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.ViewsCreateOrUpdateByScope_Call(request,onOk,onCreated,onDefault,eventListener,sender); + } + } + + /// + /// The operation to create or update a view. Update operation requires latest eTag to be set in the request. You may obtain + /// the latest eTag by performing a get operation. Create operation does not require eTag. + /// + /// + /// Parameters supplied to the CreateOrUpdate View operation. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns 201 (Created). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task ViewsCreateOrUpdateByScopeViaIdentity(global::System.String viaIdentity, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IView body, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onCreated, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + var apiVersion = @"2020-06-01"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // verify that Identity format is an exact match for uri + + var _match = new global::System.Text.RegularExpressions.Regex("(?.+)/providers/Microsoft.CostManagement/views/(?[^/]+)$").Match(viaIdentity); + if (!_match.Success) + { + throw new global::System.Exception("Invalid identity for URI '/{scope}/providers/Microsoft.CostManagement/views/{viewName}'"); + } + + // replace URI parameters with values from identity + var scope = _match.Groups["scope"].Value; + var viewName = _match.Groups["viewName"].Value; + // construct URL + var _url = new global::System.Uri(global::System.Text.RegularExpressions.Regex.Replace( + "https://management.azure.com/" + + scope + + "/providers/Microsoft.CostManagement/views/" + + viewName + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2")); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.URLCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Put, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.RequestCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.HeaderParametersAdded, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // set body content + request.Content = new global::System.Net.Http.StringContent(null != body ? body.ToJson(null).ToString() : @"{}", global::System.Text.Encoding.UTF8); + request.Content.Headers.ContentType = global::System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BodyContentSet, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.ViewsCreateOrUpdateByScope_Call(request,onOk,onCreated,onDefault,eventListener,sender); + } + } + + /// Actual wire call for method. + /// the prepared HttpRequestMessage to send. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns 201 (Created). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + internal async global::System.Threading.Tasks.Task ViewsCreateOrUpdateByScope_Call(global::System.Net.Http.HttpRequestMessage request, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onCreated, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + using( NoSynchronizationContext ) + { + global::System.Net.Http.HttpResponseMessage _response = null; + try + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return; } + _response = await sender.SendAsync(request, eventListener); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + var _contentType = _response.Content.Headers.ContentType?.MediaType; + + switch ( _response.StatusCode ) + { + case global::System.Net.HttpStatusCode.OK: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onOk(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.View.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + case global::System.Net.HttpStatusCode.Created: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onCreated(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.View.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + default: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + } + } + finally + { + // finally statements + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Finally, request, _response); + _response?.Dispose(); + request?.Dispose(); + } + } + } + + /// + /// Validation method for method. Call this like the actual call, but you will get + /// validation events back. + /// + /// The scope associated with view operations. This includes 'subscriptions/{subscriptionId}' for subscription + /// scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for External Billing Account + /// scope and 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for External Subscription + /// scope. + /// View name + /// Parameters supplied to the CreateOrUpdate View operation. + /// an instance that will receive events. + /// + /// A that will be complete when handling of the response is completed. + /// + internal async global::System.Threading.Tasks.Task ViewsCreateOrUpdateByScope_Validate(string scope, string viewName, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IView body, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener) + { + using( NoSynchronizationContext ) + { + await eventListener.AssertNotNull(nameof(scope),scope); + await eventListener.AssertNotNull(nameof(viewName),viewName); + await eventListener.AssertNotNull(nameof(body), body); + await eventListener.AssertObjectIsValid(nameof(body), body); + } + } + + /// + /// The operation to create or update a view. Update operation requires latest eTag to be set in the request. You may obtain + /// the latest eTag by performing a get operation. Create operation does not require eTag. + /// + /// + /// Parameters supplied to the CreateOrUpdate View operation. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns 201 (Created). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task ViewsCreateOrUpdateViaIdentity(global::System.String viaIdentity, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IView body, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onCreated, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + var apiVersion = @"2020-06-01"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // verify that Identity format is an exact match for uri + + var _match = new global::System.Text.RegularExpressions.Regex("^/providers/Microsoft.CostManagement/views/(?[^/]+)$").Match(viaIdentity); + if (!_match.Success) + { + throw new global::System.Exception("Invalid identity for URI '/providers/Microsoft.CostManagement/views/{viewName}'"); + } + + // replace URI parameters with values from identity + var viewName = _match.Groups["viewName"].Value; + // construct URL + var _url = new global::System.Uri(global::System.Text.RegularExpressions.Regex.Replace( + "https://management.azure.com/providers/Microsoft.CostManagement/views/" + + viewName + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2")); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.URLCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Put, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.RequestCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.HeaderParametersAdded, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // set body content + request.Content = new global::System.Net.Http.StringContent(null != body ? body.ToJson(null).ToString() : @"{}", global::System.Text.Encoding.UTF8); + request.Content.Headers.ContentType = global::System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BodyContentSet, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.ViewsCreateOrUpdate_Call(request,onOk,onCreated,onDefault,eventListener,sender); + } + } + + /// Actual wire call for method. + /// the prepared HttpRequestMessage to send. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns 201 (Created). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + internal async global::System.Threading.Tasks.Task ViewsCreateOrUpdate_Call(global::System.Net.Http.HttpRequestMessage request, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onCreated, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + using( NoSynchronizationContext ) + { + global::System.Net.Http.HttpResponseMessage _response = null; + try + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return; } + _response = await sender.SendAsync(request, eventListener); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + var _contentType = _response.Content.Headers.ContentType?.MediaType; + + switch ( _response.StatusCode ) + { + case global::System.Net.HttpStatusCode.OK: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onOk(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.View.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + case global::System.Net.HttpStatusCode.Created: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onCreated(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.View.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + default: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + } + } + finally + { + // finally statements + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Finally, request, _response); + _response?.Dispose(); + request?.Dispose(); + } + } + } + + /// + /// Validation method for method. Call this like the actual call, but you will get validation + /// events back. + /// + /// View name + /// Parameters supplied to the CreateOrUpdate View operation. + /// an instance that will receive events. + /// + /// A that will be complete when handling of the response is completed. + /// + internal async global::System.Threading.Tasks.Task ViewsCreateOrUpdate_Validate(string viewName, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IView body, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener) + { + using( NoSynchronizationContext ) + { + await eventListener.AssertNotNull(nameof(viewName),viewName); + await eventListener.AssertNotNull(nameof(body), body); + await eventListener.AssertObjectIsValid(nameof(body), body); + } + } + + /// The operation to delete a view. + /// View name + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns 204 (NoContent). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task ViewsDelete(string viewName, global::System.Func onOk, global::System.Func onNoContent, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + var apiVersion = @"2020-06-01"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // construct URL + var _url = new global::System.Uri(global::System.Text.RegularExpressions.Regex.Replace( + "https://management.azure.com/providers/Microsoft.CostManagement/views/" + + global::System.Uri.EscapeDataString(viewName) + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2")); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.URLCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Delete, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.RequestCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.HeaderParametersAdded, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.ViewsDelete_Call(request,onOk,onNoContent,onDefault,eventListener,sender); + } + } + + /// The operation to delete a view. + /// The scope associated with view operations. This includes 'subscriptions/{subscriptionId}' for subscription + /// scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for External Billing Account + /// scope and 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for External Subscription + /// scope. + /// View name + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns 204 (NoContent). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task ViewsDeleteByScope(string scope, string viewName, global::System.Func onOk, global::System.Func onNoContent, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + var apiVersion = @"2020-06-01"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // construct URL + var _url = new global::System.Uri(global::System.Text.RegularExpressions.Regex.Replace( + "https://management.azure.com/" + + global::System.Uri.EscapeDataString(scope) + + "/providers/Microsoft.CostManagement/views/" + + global::System.Uri.EscapeDataString(viewName) + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2")); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.URLCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Delete, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.RequestCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.HeaderParametersAdded, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.ViewsDeleteByScope_Call(request,onOk,onNoContent,onDefault,eventListener,sender); + } + } + + /// The operation to delete a view. + /// + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns 204 (NoContent). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task ViewsDeleteByScopeViaIdentity(global::System.String viaIdentity, global::System.Func onOk, global::System.Func onNoContent, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + var apiVersion = @"2020-06-01"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // verify that Identity format is an exact match for uri + + var _match = new global::System.Text.RegularExpressions.Regex("(?.+)/providers/Microsoft.CostManagement/views/(?[^/]+)$").Match(viaIdentity); + if (!_match.Success) + { + throw new global::System.Exception("Invalid identity for URI '/{scope}/providers/Microsoft.CostManagement/views/{viewName}'"); + } + + // replace URI parameters with values from identity + var scope = _match.Groups["scope"].Value; + var viewName = _match.Groups["viewName"].Value; + // construct URL + var _url = new global::System.Uri(global::System.Text.RegularExpressions.Regex.Replace( + "https://management.azure.com/" + + scope + + "/providers/Microsoft.CostManagement/views/" + + viewName + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2")); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.URLCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Delete, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.RequestCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.HeaderParametersAdded, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.ViewsDeleteByScope_Call(request,onOk,onNoContent,onDefault,eventListener,sender); + } + } + + /// Actual wire call for method. + /// the prepared HttpRequestMessage to send. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns 204 (NoContent). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + internal async global::System.Threading.Tasks.Task ViewsDeleteByScope_Call(global::System.Net.Http.HttpRequestMessage request, global::System.Func onOk, global::System.Func onNoContent, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + using( NoSynchronizationContext ) + { + global::System.Net.Http.HttpResponseMessage _response = null; + try + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return; } + _response = await sender.SendAsync(request, eventListener); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + var _contentType = _response.Content.Headers.ContentType?.MediaType; + + switch ( _response.StatusCode ) + { + case global::System.Net.HttpStatusCode.OK: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onOk(_response); + break; + } + case global::System.Net.HttpStatusCode.NoContent: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onNoContent(_response); + break; + } + default: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + } + } + finally + { + // finally statements + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Finally, request, _response); + _response?.Dispose(); + request?.Dispose(); + } + } + } + + /// + /// Validation method for method. Call this like the actual call, but you will get validation + /// events back. + /// + /// The scope associated with view operations. This includes 'subscriptions/{subscriptionId}' for subscription + /// scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for External Billing Account + /// scope and 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for External Subscription + /// scope. + /// View name + /// an instance that will receive events. + /// + /// A that will be complete when handling of the response is completed. + /// + internal async global::System.Threading.Tasks.Task ViewsDeleteByScope_Validate(string scope, string viewName, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener) + { + using( NoSynchronizationContext ) + { + await eventListener.AssertNotNull(nameof(scope),scope); + await eventListener.AssertNotNull(nameof(viewName),viewName); + } + } + + /// The operation to delete a view. + /// + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns 204 (NoContent). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task ViewsDeleteViaIdentity(global::System.String viaIdentity, global::System.Func onOk, global::System.Func onNoContent, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + var apiVersion = @"2020-06-01"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // verify that Identity format is an exact match for uri + + var _match = new global::System.Text.RegularExpressions.Regex("^/providers/Microsoft.CostManagement/views/(?[^/]+)$").Match(viaIdentity); + if (!_match.Success) + { + throw new global::System.Exception("Invalid identity for URI '/providers/Microsoft.CostManagement/views/{viewName}'"); + } + + // replace URI parameters with values from identity + var viewName = _match.Groups["viewName"].Value; + // construct URL + var _url = new global::System.Uri(global::System.Text.RegularExpressions.Regex.Replace( + "https://management.azure.com/providers/Microsoft.CostManagement/views/" + + viewName + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2")); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.URLCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Delete, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.RequestCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.HeaderParametersAdded, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.ViewsDelete_Call(request,onOk,onNoContent,onDefault,eventListener,sender); + } + } + + /// Actual wire call for method. + /// the prepared HttpRequestMessage to send. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns 204 (NoContent). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + internal async global::System.Threading.Tasks.Task ViewsDelete_Call(global::System.Net.Http.HttpRequestMessage request, global::System.Func onOk, global::System.Func onNoContent, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + using( NoSynchronizationContext ) + { + global::System.Net.Http.HttpResponseMessage _response = null; + try + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return; } + _response = await sender.SendAsync(request, eventListener); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + var _contentType = _response.Content.Headers.ContentType?.MediaType; + + switch ( _response.StatusCode ) + { + case global::System.Net.HttpStatusCode.OK: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onOk(_response); + break; + } + case global::System.Net.HttpStatusCode.NoContent: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onNoContent(_response); + break; + } + default: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + } + } + finally + { + // finally statements + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Finally, request, _response); + _response?.Dispose(); + request?.Dispose(); + } + } + } + + /// + /// Validation method for method. Call this like the actual call, but you will get validation events + /// back. + /// + /// View name + /// an instance that will receive events. + /// + /// A that will be complete when handling of the response is completed. + /// + internal async global::System.Threading.Tasks.Task ViewsDelete_Validate(string viewName, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener) + { + using( NoSynchronizationContext ) + { + await eventListener.AssertNotNull(nameof(viewName),viewName); + } + } + + /// Gets the view by view name. + /// View name + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task ViewsGet(string viewName, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + var apiVersion = @"2020-06-01"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // construct URL + var _url = new global::System.Uri(global::System.Text.RegularExpressions.Regex.Replace( + "https://management.azure.com/providers/Microsoft.CostManagement/views/" + + global::System.Uri.EscapeDataString(viewName) + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2")); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.URLCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Get, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.RequestCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.HeaderParametersAdded, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.ViewsGet_Call(request,onOk,onDefault,eventListener,sender); + } + } + + /// Gets the view for the defined scope by view name. + /// The scope associated with view operations. This includes 'subscriptions/{subscriptionId}' for subscription + /// scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for External Billing Account + /// scope and 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for External Subscription + /// scope. + /// View name + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task ViewsGetByScope(string scope, string viewName, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + var apiVersion = @"2020-06-01"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // construct URL + var _url = new global::System.Uri(global::System.Text.RegularExpressions.Regex.Replace( + "https://management.azure.com/" + + global::System.Uri.EscapeDataString(scope) + + "/providers/Microsoft.CostManagement/views/" + + global::System.Uri.EscapeDataString(viewName) + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2")); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.URLCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Get, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.RequestCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.HeaderParametersAdded, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.ViewsGetByScope_Call(request,onOk,onDefault,eventListener,sender); + } + } + + /// Gets the view for the defined scope by view name. + /// + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task ViewsGetByScopeViaIdentity(global::System.String viaIdentity, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + var apiVersion = @"2020-06-01"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // verify that Identity format is an exact match for uri + + var _match = new global::System.Text.RegularExpressions.Regex("(?.+)/providers/Microsoft.CostManagement/views/(?[^/]+)$").Match(viaIdentity); + if (!_match.Success) + { + throw new global::System.Exception("Invalid identity for URI '/{scope}/providers/Microsoft.CostManagement/views/{viewName}'"); + } + + // replace URI parameters with values from identity + var scope = _match.Groups["scope"].Value; + var viewName = _match.Groups["viewName"].Value; + // construct URL + var _url = new global::System.Uri(global::System.Text.RegularExpressions.Regex.Replace( + "https://management.azure.com/" + + scope + + "/providers/Microsoft.CostManagement/views/" + + viewName + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2")); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.URLCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Get, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.RequestCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.HeaderParametersAdded, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.ViewsGetByScope_Call(request,onOk,onDefault,eventListener,sender); + } + } + + /// Actual wire call for method. + /// the prepared HttpRequestMessage to send. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + internal async global::System.Threading.Tasks.Task ViewsGetByScope_Call(global::System.Net.Http.HttpRequestMessage request, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + using( NoSynchronizationContext ) + { + global::System.Net.Http.HttpResponseMessage _response = null; + try + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return; } + _response = await sender.SendAsync(request, eventListener); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + var _contentType = _response.Content.Headers.ContentType?.MediaType; + + switch ( _response.StatusCode ) + { + case global::System.Net.HttpStatusCode.OK: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onOk(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.View.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + default: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + } + } + finally + { + // finally statements + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Finally, request, _response); + _response?.Dispose(); + request?.Dispose(); + } + } + } + + /// + /// Validation method for method. Call this like the actual call, but you will get validation + /// events back. + /// + /// The scope associated with view operations. This includes 'subscriptions/{subscriptionId}' for subscription + /// scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for External Billing Account + /// scope and 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for External Subscription + /// scope. + /// View name + /// an instance that will receive events. + /// + /// A that will be complete when handling of the response is completed. + /// + internal async global::System.Threading.Tasks.Task ViewsGetByScope_Validate(string scope, string viewName, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener) + { + using( NoSynchronizationContext ) + { + await eventListener.AssertNotNull(nameof(scope),scope); + await eventListener.AssertNotNull(nameof(viewName),viewName); + } + } + + /// Gets the view by view name. + /// + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task ViewsGetViaIdentity(global::System.String viaIdentity, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + var apiVersion = @"2020-06-01"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // verify that Identity format is an exact match for uri + + var _match = new global::System.Text.RegularExpressions.Regex("^/providers/Microsoft.CostManagement/views/(?[^/]+)$").Match(viaIdentity); + if (!_match.Success) + { + throw new global::System.Exception("Invalid identity for URI '/providers/Microsoft.CostManagement/views/{viewName}'"); + } + + // replace URI parameters with values from identity + var viewName = _match.Groups["viewName"].Value; + // construct URL + var _url = new global::System.Uri(global::System.Text.RegularExpressions.Regex.Replace( + "https://management.azure.com/providers/Microsoft.CostManagement/views/" + + viewName + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2")); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.URLCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Get, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.RequestCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.HeaderParametersAdded, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.ViewsGet_Call(request,onOk,onDefault,eventListener,sender); + } + } + + /// Actual wire call for method. + /// the prepared HttpRequestMessage to send. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + internal async global::System.Threading.Tasks.Task ViewsGet_Call(global::System.Net.Http.HttpRequestMessage request, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + using( NoSynchronizationContext ) + { + global::System.Net.Http.HttpResponseMessage _response = null; + try + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return; } + _response = await sender.SendAsync(request, eventListener); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + var _contentType = _response.Content.Headers.ContentType?.MediaType; + + switch ( _response.StatusCode ) + { + case global::System.Net.HttpStatusCode.OK: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onOk(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.View.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + default: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + } + } + finally + { + // finally statements + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Finally, request, _response); + _response?.Dispose(); + request?.Dispose(); + } + } + } + + /// + /// Validation method for method. Call this like the actual call, but you will get validation events + /// back. + /// + /// View name + /// an instance that will receive events. + /// + /// A that will be complete when handling of the response is completed. + /// + internal async global::System.Threading.Tasks.Task ViewsGet_Validate(string viewName, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener) + { + using( NoSynchronizationContext ) + { + await eventListener.AssertNotNull(nameof(viewName),viewName); + } + } + + /// Lists all views by tenant and object. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task ViewsList(global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + var apiVersion = @"2020-06-01"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // construct URL + var _url = new global::System.Uri(global::System.Text.RegularExpressions.Regex.Replace( + "https://management.azure.com/providers/Microsoft.CostManagement/views" + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2")); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.URLCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Get, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.RequestCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.HeaderParametersAdded, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.ViewsList_Call(request,onOk,onDefault,eventListener,sender); + } + } + + /// Lists all views at the given scope. + /// The scope associated with view operations. This includes 'subscriptions/{subscriptionId}' for subscription + /// scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for External Billing Account + /// scope and 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for External Subscription + /// scope. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task ViewsListByScope(string scope, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + var apiVersion = @"2020-06-01"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // construct URL + var _url = new global::System.Uri(global::System.Text.RegularExpressions.Regex.Replace( + "https://management.azure.com/" + + global::System.Uri.EscapeDataString(scope) + + "/providers/Microsoft.CostManagement/views" + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2")); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.URLCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Get, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.RequestCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.HeaderParametersAdded, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.ViewsListByScope_Call(request,onOk,onDefault,eventListener,sender); + } + } + + /// Lists all views at the given scope. + /// + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task ViewsListByScopeViaIdentity(global::System.String viaIdentity, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + var apiVersion = @"2020-06-01"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // verify that Identity format is an exact match for uri + + var _match = new global::System.Text.RegularExpressions.Regex("(?.+)/providers/Microsoft.CostManagement/views$").Match(viaIdentity); + if (!_match.Success) + { + throw new global::System.Exception("Invalid identity for URI '/{scope}/providers/Microsoft.CostManagement/views'"); + } + + // replace URI parameters with values from identity + var scope = _match.Groups["scope"].Value; + // construct URL + var _url = new global::System.Uri(global::System.Text.RegularExpressions.Regex.Replace( + "https://management.azure.com/" + + scope + + "/providers/Microsoft.CostManagement/views" + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2")); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.URLCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Get, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.RequestCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.HeaderParametersAdded, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.ViewsListByScope_Call(request,onOk,onDefault,eventListener,sender); + } + } + + /// Actual wire call for method. + /// the prepared HttpRequestMessage to send. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + internal async global::System.Threading.Tasks.Task ViewsListByScope_Call(global::System.Net.Http.HttpRequestMessage request, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + using( NoSynchronizationContext ) + { + global::System.Net.Http.HttpResponseMessage _response = null; + try + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return; } + _response = await sender.SendAsync(request, eventListener); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + var _contentType = _response.Content.Headers.ContentType?.MediaType; + + switch ( _response.StatusCode ) + { + case global::System.Net.HttpStatusCode.OK: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onOk(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ViewListResult.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + default: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + } + } + finally + { + // finally statements + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Finally, request, _response); + _response?.Dispose(); + request?.Dispose(); + } + } + } + + /// + /// Validation method for method. Call this like the actual call, but you will get validation + /// events back. + /// + /// The scope associated with view operations. This includes 'subscriptions/{subscriptionId}' for subscription + /// scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + /// for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for External Billing Account + /// scope and 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for External Subscription + /// scope. + /// an instance that will receive events. + /// + /// A that will be complete when handling of the response is completed. + /// + internal async global::System.Threading.Tasks.Task ViewsListByScope_Validate(string scope, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener) + { + using( NoSynchronizationContext ) + { + await eventListener.AssertNotNull(nameof(scope),scope); + } + } + + /// Lists all views by tenant and object. + /// + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task ViewsListViaIdentity(global::System.String viaIdentity, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + var apiVersion = @"2020-06-01"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // verify that Identity format is an exact match for uri + + var _match = new global::System.Text.RegularExpressions.Regex("^/providers/Microsoft.CostManagement/views$").Match(viaIdentity); + if (!_match.Success) + { + throw new global::System.Exception("Invalid identity for URI '/providers/Microsoft.CostManagement/views'"); + } + + // replace URI parameters with values from identity + // construct URL + var _url = new global::System.Uri(global::System.Text.RegularExpressions.Regex.Replace( + "https://management.azure.com/providers/Microsoft.CostManagement/views" + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2")); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.URLCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Get, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.RequestCreated, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.HeaderParametersAdded, _url); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.ViewsList_Call(request,onOk,onDefault,eventListener,sender); + } + } + + /// Actual wire call for method. + /// the prepared HttpRequestMessage to send. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + internal async global::System.Threading.Tasks.Task ViewsList_Call(global::System.Net.Http.HttpRequestMessage request, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.ISendAsync sender) + { + using( NoSynchronizationContext ) + { + global::System.Net.Http.HttpResponseMessage _response = null; + try + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return; } + _response = await sender.SendAsync(request, eventListener); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + var _contentType = _response.Content.Headers.ContentType?.MediaType; + + switch ( _response.StatusCode ) + { + case global::System.Net.HttpStatusCode.OK: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onOk(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ViewListResult.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + default: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + } + } + finally + { + // finally statements + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Finally, request, _response); + _response?.Dispose(); + request?.Dispose(); + } + } + } + + /// + /// Validation method for method. Call this like the actual call, but you will get validation events + /// back. + /// + /// an instance that will receive events. + /// + /// A that will be complete when handling of the response is completed. + /// + internal async global::System.Threading.Tasks.Task ViewsList_Validate(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener) + { + using( NoSynchronizationContext ) + { + + } + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/Alert.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/Alert.PowerShell.cs new file mode 100644 index 000000000000..a4fc9183a968 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/Alert.PowerShell.cs @@ -0,0 +1,199 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// An individual alert. + [System.ComponentModel.TypeConverter(typeof(AlertTypeConverter))] + public partial class Alert + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal Alert(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).Property = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertProperties) content.GetValueForProperty("Property",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).Property, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.AlertPropertiesTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Name, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Type = (string) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Type, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Id = (string) content.GetValueForProperty("Id",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Id, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Tag = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceTags) content.GetValueForProperty("Tag",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Tag, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ResourceTagsTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).ModificationTime = (string) content.GetValueForProperty("ModificationTime",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).ModificationTime, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).Definition = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDefinition) content.GetValueForProperty("Definition",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).Definition, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.AlertPropertiesDefinitionTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).CloseTime = (string) content.GetValueForProperty("CloseTime",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).CloseTime, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).CostEntityId = (string) content.GetValueForProperty("CostEntityId",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).CostEntityId, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).CreationTime = (string) content.GetValueForProperty("CreationTime",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).CreationTime, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).Description = (string) content.GetValueForProperty("Description",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).Description, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).Source = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertSource?) content.GetValueForProperty("Source",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).Source, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertSource.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).Status = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertStatus?) content.GetValueForProperty("Status",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).Status, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertStatus.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).StatusModificationTime = (string) content.GetValueForProperty("StatusModificationTime",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).StatusModificationTime, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).StatusModificationUserName = (string) content.GetValueForProperty("StatusModificationUserName",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).StatusModificationUserName, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).Detail = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetails) content.GetValueForProperty("Detail",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).Detail, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.AlertPropertiesDetailsTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailOperator = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertOperator?) content.GetValueForProperty("DetailOperator",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailOperator, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertOperator.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DefinitionType = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertType?) content.GetValueForProperty("DefinitionType",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DefinitionType, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DefinitionCriterion = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria?) content.GetValueForProperty("DefinitionCriterion",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DefinitionCriterion, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailAmount = (decimal?) content.GetValueForProperty("DetailAmount",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailAmount, (__y)=> (decimal) global::System.Convert.ChangeType(__y, typeof(decimal))); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailUnit = (string) content.GetValueForProperty("DetailUnit",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailUnit, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailContactGroup = (string[]) content.GetValueForProperty("DetailContactGroup",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailContactGroup, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailContactRole = (string[]) content.GetValueForProperty("DetailContactRole",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailContactRole, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailCurrentSpend = (decimal?) content.GetValueForProperty("DetailCurrentSpend",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailCurrentSpend, (__y)=> (decimal) global::System.Convert.ChangeType(__y, typeof(decimal))); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailMeterFilter = (string[]) content.GetValueForProperty("DetailMeterFilter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailMeterFilter, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DefinitionCategory = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCategory?) content.GetValueForProperty("DefinitionCategory",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DefinitionCategory, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCategory.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailOverridingAlert = (string) content.GetValueForProperty("DetailOverridingAlert",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailOverridingAlert, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailPeriodStartDate = (string) content.GetValueForProperty("DetailPeriodStartDate",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailPeriodStartDate, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailResourceFilter = (string[]) content.GetValueForProperty("DetailResourceFilter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailResourceFilter, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailResourceGroupFilter = (string[]) content.GetValueForProperty("DetailResourceGroupFilter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailResourceGroupFilter, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailTagFilter = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsTagFilter) content.GetValueForProperty("DetailTagFilter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailTagFilter, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.AlertPropertiesDetailsTagFilterTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailThreshold = (decimal?) content.GetValueForProperty("DetailThreshold",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailThreshold, (__y)=> (decimal) global::System.Convert.ChangeType(__y, typeof(decimal))); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailTimeGrainType = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertTimeGrainType?) content.GetValueForProperty("DetailTimeGrainType",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailTimeGrainType, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertTimeGrainType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailTriggeredBy = (string) content.GetValueForProperty("DetailTriggeredBy",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailTriggeredBy, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailContactEmail = (string[]) content.GetValueForProperty("DetailContactEmail",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailContactEmail, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal Alert(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).Property = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertProperties) content.GetValueForProperty("Property",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).Property, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.AlertPropertiesTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Name, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Type = (string) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Type, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Id = (string) content.GetValueForProperty("Id",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Id, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Tag = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceTags) content.GetValueForProperty("Tag",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Tag, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ResourceTagsTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).ModificationTime = (string) content.GetValueForProperty("ModificationTime",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).ModificationTime, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).Definition = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDefinition) content.GetValueForProperty("Definition",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).Definition, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.AlertPropertiesDefinitionTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).CloseTime = (string) content.GetValueForProperty("CloseTime",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).CloseTime, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).CostEntityId = (string) content.GetValueForProperty("CostEntityId",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).CostEntityId, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).CreationTime = (string) content.GetValueForProperty("CreationTime",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).CreationTime, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).Description = (string) content.GetValueForProperty("Description",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).Description, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).Source = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertSource?) content.GetValueForProperty("Source",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).Source, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertSource.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).Status = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertStatus?) content.GetValueForProperty("Status",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).Status, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertStatus.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).StatusModificationTime = (string) content.GetValueForProperty("StatusModificationTime",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).StatusModificationTime, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).StatusModificationUserName = (string) content.GetValueForProperty("StatusModificationUserName",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).StatusModificationUserName, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).Detail = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetails) content.GetValueForProperty("Detail",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).Detail, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.AlertPropertiesDetailsTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailOperator = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertOperator?) content.GetValueForProperty("DetailOperator",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailOperator, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertOperator.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DefinitionType = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertType?) content.GetValueForProperty("DefinitionType",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DefinitionType, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DefinitionCriterion = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria?) content.GetValueForProperty("DefinitionCriterion",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DefinitionCriterion, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailAmount = (decimal?) content.GetValueForProperty("DetailAmount",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailAmount, (__y)=> (decimal) global::System.Convert.ChangeType(__y, typeof(decimal))); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailUnit = (string) content.GetValueForProperty("DetailUnit",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailUnit, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailContactGroup = (string[]) content.GetValueForProperty("DetailContactGroup",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailContactGroup, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailContactRole = (string[]) content.GetValueForProperty("DetailContactRole",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailContactRole, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailCurrentSpend = (decimal?) content.GetValueForProperty("DetailCurrentSpend",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailCurrentSpend, (__y)=> (decimal) global::System.Convert.ChangeType(__y, typeof(decimal))); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailMeterFilter = (string[]) content.GetValueForProperty("DetailMeterFilter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailMeterFilter, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DefinitionCategory = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCategory?) content.GetValueForProperty("DefinitionCategory",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DefinitionCategory, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCategory.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailOverridingAlert = (string) content.GetValueForProperty("DetailOverridingAlert",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailOverridingAlert, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailPeriodStartDate = (string) content.GetValueForProperty("DetailPeriodStartDate",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailPeriodStartDate, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailResourceFilter = (string[]) content.GetValueForProperty("DetailResourceFilter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailResourceFilter, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailResourceGroupFilter = (string[]) content.GetValueForProperty("DetailResourceGroupFilter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailResourceGroupFilter, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailTagFilter = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsTagFilter) content.GetValueForProperty("DetailTagFilter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailTagFilter, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.AlertPropertiesDetailsTagFilterTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailThreshold = (decimal?) content.GetValueForProperty("DetailThreshold",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailThreshold, (__y)=> (decimal) global::System.Convert.ChangeType(__y, typeof(decimal))); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailTimeGrainType = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertTimeGrainType?) content.GetValueForProperty("DetailTimeGrainType",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailTimeGrainType, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertTimeGrainType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailTriggeredBy = (string) content.GetValueForProperty("DetailTriggeredBy",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailTriggeredBy, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailContactEmail = (string[]) content.GetValueForProperty("DetailContactEmail",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal)this).DetailContactEmail, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + AfterDeserializePSObject(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlert DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new Alert(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlert DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new Alert(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlert FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// An individual alert. + [System.ComponentModel.TypeConverter(typeof(AlertTypeConverter))] + public partial interface IAlert + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/Alert.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/Alert.TypeConverter.cs new file mode 100644 index 000000000000..ca3f796af1cd --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/Alert.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class AlertTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlert ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlert).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return Alert.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return Alert.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return Alert.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/Alert.cs b/src/CostManagement/generated/api/Models/Api20200601/Alert.cs new file mode 100644 index 000000000000..9000a4ee56a5 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/Alert.cs @@ -0,0 +1,489 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// An individual alert. + public partial class Alert : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlert, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IValidates + { + /// + /// Backing field for Inherited model + /// + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResource __resource = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.Resource(); + + /// dateTime in which alert was closed + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string CloseTime { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).CloseTime; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).CloseTime = value; } + + /// related budget + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string CostEntityId { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).CostEntityId; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).CostEntityId = value; } + + /// dateTime in which alert was created + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string CreationTime { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).CreationTime; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).CreationTime = value; } + + /// Alert category + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCategory? DefinitionCategory { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DefinitionCategory; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DefinitionCategory = value; } + + /// Criteria that triggered alert + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria? DefinitionCriterion { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DefinitionCriterion; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DefinitionCriterion = value; } + + /// type of alert + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertType? DefinitionType { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DefinitionType; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DefinitionType = value; } + + /// Alert description + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string Description { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).Description; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).Description = value; } + + /// budget threshold amount + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public decimal? DetailAmount { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailAmount; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailAmount = value; } + + /// list of emails to contact + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string[] DetailContactEmail { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailContactEmail; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailContactEmail = value; } + + /// list of action groups to broadcast to + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string[] DetailContactGroup { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailContactGroup; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailContactGroup = value; } + + /// list of contact roles + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string[] DetailContactRole { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailContactRole; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailContactRole = value; } + + /// current spend + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public decimal? DetailCurrentSpend { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailCurrentSpend; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailCurrentSpend = value; } + + /// array of meters to filter by + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string[] DetailMeterFilter { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailMeterFilter; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailMeterFilter = value; } + + /// operator used to compare currentSpend with amount + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertOperator? DetailOperator { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailOperator; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailOperator = value; } + + /// overriding alert + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string DetailOverridingAlert { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailOverridingAlert; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailOverridingAlert = value; } + + /// datetime of periodStartDate + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string DetailPeriodStartDate { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailPeriodStartDate; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailPeriodStartDate = value; } + + /// array of resources to filter by + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string[] DetailResourceFilter { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailResourceFilter; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailResourceFilter = value; } + + /// array of resourceGroups to filter by + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string[] DetailResourceGroupFilter { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailResourceGroupFilter; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailResourceGroupFilter = value; } + + /// tags to filter by + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsTagFilter DetailTagFilter { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailTagFilter; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailTagFilter = value; } + + /// notification threshold percentage as a decimal which activated this alert + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public decimal? DetailThreshold { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailThreshold; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailThreshold = value; } + + /// Type of timegrain cadence + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertTimeGrainType? DetailTimeGrainType { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailTimeGrainType; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailTimeGrainType = value; } + + /// notificationId that triggered this alert + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string DetailTriggeredBy { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailTriggeredBy; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailTriggeredBy = value; } + + /// unit of currency being used + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string DetailUnit { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailUnit; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailUnit = value; } + + /// Resource Id. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inherited)] + public string Id { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)__resource).Id; } + + /// Internal Acessors for Definition + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDefinition Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal.Definition { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).Definition; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).Definition = value; } + + /// Internal Acessors for Detail + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetails Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal.Detail { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).Detail; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).Detail = value; } + + /// Internal Acessors for Property + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertProperties Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertInternal.Property { get => (this._property = this._property ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.AlertProperties()); set { {_property = value;} } } + + /// Internal Acessors for Id + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal.Id { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)__resource).Id; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)__resource).Id = value; } + + /// Internal Acessors for Name + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal.Name { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)__resource).Name; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)__resource).Name = value; } + + /// Internal Acessors for Tag + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceTags Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal.Tag { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)__resource).Tag; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)__resource).Tag = value; } + + /// Internal Acessors for Type + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal.Type { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)__resource).Type; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)__resource).Type = value; } + + /// dateTime in which alert was last modified + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string ModificationTime { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).ModificationTime; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).ModificationTime = value; } + + /// Resource name. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inherited)] + public string Name { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)__resource).Name; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertProperties _property; + + /// Alert properties + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + internal Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertProperties Property { get => (this._property = this._property ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.AlertProperties()); set => this._property = value; } + + /// Source of alert + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertSource? Source { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).Source; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).Source = value; } + + /// alert status + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertStatus? Status { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).Status; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).Status = value; } + + /// dateTime in which the alert status was last modified + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string StatusModificationTime { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).StatusModificationTime; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).StatusModificationTime = value; } + + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string StatusModificationUserName { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).StatusModificationUserName; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).StatusModificationUserName = value; } + + /// Resource tags. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inherited)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceTags Tag { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)__resource).Tag; } + + /// Resource type. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inherited)] + public string Type { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)__resource).Type; } + + /// Creates an new instance. + public Alert() + { + + } + + /// Validates that this object meets the validation criteria. + /// an instance that will receive validation + /// events. + /// + /// A < see cref = "global::System.Threading.Tasks.Task" /> that will be complete when validation is completed. + /// + public async global::System.Threading.Tasks.Task Validate(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener) + { + await eventListener.AssertNotNull(nameof(__resource), __resource); + await eventListener.AssertObjectIsValid(nameof(__resource), __resource); + } + } + /// An individual alert. + public partial interface IAlert : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResource + { + /// dateTime in which alert was closed + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"dateTime in which alert was closed", + SerializedName = @"closeTime", + PossibleTypes = new [] { typeof(string) })] + string CloseTime { get; set; } + /// related budget + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"related budget", + SerializedName = @"costEntityId", + PossibleTypes = new [] { typeof(string) })] + string CostEntityId { get; set; } + /// dateTime in which alert was created + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"dateTime in which alert was created", + SerializedName = @"creationTime", + PossibleTypes = new [] { typeof(string) })] + string CreationTime { get; set; } + /// Alert category + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Alert category", + SerializedName = @"category", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCategory) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCategory? DefinitionCategory { get; set; } + /// Criteria that triggered alert + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Criteria that triggered alert", + SerializedName = @"criteria", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria? DefinitionCriterion { get; set; } + /// type of alert + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"type of alert", + SerializedName = @"type", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertType? DefinitionType { get; set; } + /// Alert description + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Alert description", + SerializedName = @"description", + PossibleTypes = new [] { typeof(string) })] + string Description { get; set; } + /// budget threshold amount + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"budget threshold amount", + SerializedName = @"amount", + PossibleTypes = new [] { typeof(decimal) })] + decimal? DetailAmount { get; set; } + /// list of emails to contact + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"list of emails to contact", + SerializedName = @"contactEmails", + PossibleTypes = new [] { typeof(string) })] + string[] DetailContactEmail { get; set; } + /// list of action groups to broadcast to + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"list of action groups to broadcast to", + SerializedName = @"contactGroups", + PossibleTypes = new [] { typeof(string) })] + string[] DetailContactGroup { get; set; } + /// list of contact roles + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"list of contact roles", + SerializedName = @"contactRoles", + PossibleTypes = new [] { typeof(string) })] + string[] DetailContactRole { get; set; } + /// current spend + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"current spend", + SerializedName = @"currentSpend", + PossibleTypes = new [] { typeof(decimal) })] + decimal? DetailCurrentSpend { get; set; } + /// array of meters to filter by + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"array of meters to filter by", + SerializedName = @"meterFilter", + PossibleTypes = new [] { typeof(string) })] + string[] DetailMeterFilter { get; set; } + /// operator used to compare currentSpend with amount + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"operator used to compare currentSpend with amount", + SerializedName = @"operator", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertOperator) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertOperator? DetailOperator { get; set; } + /// overriding alert + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"overriding alert", + SerializedName = @"overridingAlert", + PossibleTypes = new [] { typeof(string) })] + string DetailOverridingAlert { get; set; } + /// datetime of periodStartDate + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"datetime of periodStartDate", + SerializedName = @"periodStartDate", + PossibleTypes = new [] { typeof(string) })] + string DetailPeriodStartDate { get; set; } + /// array of resources to filter by + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"array of resources to filter by", + SerializedName = @"resourceFilter", + PossibleTypes = new [] { typeof(string) })] + string[] DetailResourceFilter { get; set; } + /// array of resourceGroups to filter by + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"array of resourceGroups to filter by", + SerializedName = @"resourceGroupFilter", + PossibleTypes = new [] { typeof(string) })] + string[] DetailResourceGroupFilter { get; set; } + /// tags to filter by + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"tags to filter by", + SerializedName = @"tagFilter", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsTagFilter) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsTagFilter DetailTagFilter { get; set; } + /// notification threshold percentage as a decimal which activated this alert + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"notification threshold percentage as a decimal which activated this alert", + SerializedName = @"threshold", + PossibleTypes = new [] { typeof(decimal) })] + decimal? DetailThreshold { get; set; } + /// Type of timegrain cadence + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Type of timegrain cadence", + SerializedName = @"timeGrainType", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertTimeGrainType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertTimeGrainType? DetailTimeGrainType { get; set; } + /// notificationId that triggered this alert + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"notificationId that triggered this alert", + SerializedName = @"triggeredBy", + PossibleTypes = new [] { typeof(string) })] + string DetailTriggeredBy { get; set; } + /// unit of currency being used + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"unit of currency being used", + SerializedName = @"unit", + PossibleTypes = new [] { typeof(string) })] + string DetailUnit { get; set; } + /// dateTime in which alert was last modified + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"dateTime in which alert was last modified", + SerializedName = @"modificationTime", + PossibleTypes = new [] { typeof(string) })] + string ModificationTime { get; set; } + /// Source of alert + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Source of alert", + SerializedName = @"source", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertSource) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertSource? Source { get; set; } + /// alert status + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"alert status", + SerializedName = @"status", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertStatus) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertStatus? Status { get; set; } + /// dateTime in which the alert status was last modified + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"dateTime in which the alert status was last modified", + SerializedName = @"statusModificationTime", + PossibleTypes = new [] { typeof(string) })] + string StatusModificationTime { get; set; } + + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"", + SerializedName = @"statusModificationUserName", + PossibleTypes = new [] { typeof(string) })] + string StatusModificationUserName { get; set; } + + } + /// An individual alert. + public partial interface IAlertInternal : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal + { + /// dateTime in which alert was closed + string CloseTime { get; set; } + /// related budget + string CostEntityId { get; set; } + /// dateTime in which alert was created + string CreationTime { get; set; } + /// defines the type of alert + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDefinition Definition { get; set; } + /// Alert category + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCategory? DefinitionCategory { get; set; } + /// Criteria that triggered alert + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria? DefinitionCriterion { get; set; } + /// type of alert + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertType? DefinitionType { get; set; } + /// Alert description + string Description { get; set; } + /// Alert details + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetails Detail { get; set; } + /// budget threshold amount + decimal? DetailAmount { get; set; } + /// list of emails to contact + string[] DetailContactEmail { get; set; } + /// list of action groups to broadcast to + string[] DetailContactGroup { get; set; } + /// list of contact roles + string[] DetailContactRole { get; set; } + /// current spend + decimal? DetailCurrentSpend { get; set; } + /// array of meters to filter by + string[] DetailMeterFilter { get; set; } + /// operator used to compare currentSpend with amount + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertOperator? DetailOperator { get; set; } + /// overriding alert + string DetailOverridingAlert { get; set; } + /// datetime of periodStartDate + string DetailPeriodStartDate { get; set; } + /// array of resources to filter by + string[] DetailResourceFilter { get; set; } + /// array of resourceGroups to filter by + string[] DetailResourceGroupFilter { get; set; } + /// tags to filter by + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsTagFilter DetailTagFilter { get; set; } + /// notification threshold percentage as a decimal which activated this alert + decimal? DetailThreshold { get; set; } + /// Type of timegrain cadence + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertTimeGrainType? DetailTimeGrainType { get; set; } + /// notificationId that triggered this alert + string DetailTriggeredBy { get; set; } + /// unit of currency being used + string DetailUnit { get; set; } + /// dateTime in which alert was last modified + string ModificationTime { get; set; } + /// Alert properties + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertProperties Property { get; set; } + /// Source of alert + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertSource? Source { get; set; } + /// alert status + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertStatus? Status { get; set; } + /// dateTime in which the alert status was last modified + string StatusModificationTime { get; set; } + + string StatusModificationUserName { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/Alert.json.cs b/src/CostManagement/generated/api/Models/Api20200601/Alert.json.cs new file mode 100644 index 000000000000..40ff542edbb6 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/Alert.json.cs @@ -0,0 +1,103 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// An individual alert. + public partial class Alert + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal Alert(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + __resource = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.Resource(json); + {_property = If( json?.PropertyT("properties"), out var __jsonProperties) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.AlertProperties.FromJson(__jsonProperties) : Property;} + AfterFromJson(json); + } + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlert. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlert. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlert FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new Alert(json) : null; + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + __resource?.ToJson(container, serializationMode); + AddIf( null != this._property ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._property.ToJson(null,serializationMode) : null, "properties" ,container.Add ); + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/AlertProperties.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/AlertProperties.PowerShell.cs new file mode 100644 index 000000000000..79f5262df72a --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/AlertProperties.PowerShell.cs @@ -0,0 +1,187 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + [System.ComponentModel.TypeConverter(typeof(AlertPropertiesTypeConverter))] + public partial class AlertProperties + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal AlertProperties(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).Definition = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDefinition) content.GetValueForProperty("Definition",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).Definition, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.AlertPropertiesDefinitionTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).Detail = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetails) content.GetValueForProperty("Detail",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).Detail, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.AlertPropertiesDetailsTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).Description = (string) content.GetValueForProperty("Description",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).Description, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).CloseTime = (string) content.GetValueForProperty("CloseTime",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).CloseTime, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).CostEntityId = (string) content.GetValueForProperty("CostEntityId",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).CostEntityId, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).CreationTime = (string) content.GetValueForProperty("CreationTime",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).CreationTime, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).ModificationTime = (string) content.GetValueForProperty("ModificationTime",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).ModificationTime, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).Source = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertSource?) content.GetValueForProperty("Source",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).Source, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertSource.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).Status = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertStatus?) content.GetValueForProperty("Status",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).Status, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertStatus.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).StatusModificationTime = (string) content.GetValueForProperty("StatusModificationTime",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).StatusModificationTime, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).StatusModificationUserName = (string) content.GetValueForProperty("StatusModificationUserName",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).StatusModificationUserName, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailOperator = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertOperator?) content.GetValueForProperty("DetailOperator",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailOperator, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertOperator.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DefinitionType = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertType?) content.GetValueForProperty("DefinitionType",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DefinitionType, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DefinitionCriterion = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria?) content.GetValueForProperty("DefinitionCriterion",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DefinitionCriterion, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailAmount = (decimal?) content.GetValueForProperty("DetailAmount",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailAmount, (__y)=> (decimal) global::System.Convert.ChangeType(__y, typeof(decimal))); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailContactEmail = (string[]) content.GetValueForProperty("DetailContactEmail",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailContactEmail, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailContactGroup = (string[]) content.GetValueForProperty("DetailContactGroup",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailContactGroup, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailContactRole = (string[]) content.GetValueForProperty("DetailContactRole",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailContactRole, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailCurrentSpend = (decimal?) content.GetValueForProperty("DetailCurrentSpend",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailCurrentSpend, (__y)=> (decimal) global::System.Convert.ChangeType(__y, typeof(decimal))); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailMeterFilter = (string[]) content.GetValueForProperty("DetailMeterFilter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailMeterFilter, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DefinitionCategory = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCategory?) content.GetValueForProperty("DefinitionCategory",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DefinitionCategory, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCategory.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailOverridingAlert = (string) content.GetValueForProperty("DetailOverridingAlert",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailOverridingAlert, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailPeriodStartDate = (string) content.GetValueForProperty("DetailPeriodStartDate",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailPeriodStartDate, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailResourceFilter = (string[]) content.GetValueForProperty("DetailResourceFilter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailResourceFilter, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailResourceGroupFilter = (string[]) content.GetValueForProperty("DetailResourceGroupFilter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailResourceGroupFilter, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailTagFilter = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsTagFilter) content.GetValueForProperty("DetailTagFilter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailTagFilter, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.AlertPropertiesDetailsTagFilterTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailThreshold = (decimal?) content.GetValueForProperty("DetailThreshold",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailThreshold, (__y)=> (decimal) global::System.Convert.ChangeType(__y, typeof(decimal))); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailTimeGrainType = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertTimeGrainType?) content.GetValueForProperty("DetailTimeGrainType",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailTimeGrainType, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertTimeGrainType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailTriggeredBy = (string) content.GetValueForProperty("DetailTriggeredBy",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailTriggeredBy, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailUnit = (string) content.GetValueForProperty("DetailUnit",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailUnit, global::System.Convert.ToString); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal AlertProperties(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).Definition = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDefinition) content.GetValueForProperty("Definition",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).Definition, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.AlertPropertiesDefinitionTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).Detail = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetails) content.GetValueForProperty("Detail",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).Detail, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.AlertPropertiesDetailsTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).Description = (string) content.GetValueForProperty("Description",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).Description, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).CloseTime = (string) content.GetValueForProperty("CloseTime",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).CloseTime, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).CostEntityId = (string) content.GetValueForProperty("CostEntityId",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).CostEntityId, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).CreationTime = (string) content.GetValueForProperty("CreationTime",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).CreationTime, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).ModificationTime = (string) content.GetValueForProperty("ModificationTime",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).ModificationTime, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).Source = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertSource?) content.GetValueForProperty("Source",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).Source, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertSource.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).Status = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertStatus?) content.GetValueForProperty("Status",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).Status, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertStatus.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).StatusModificationTime = (string) content.GetValueForProperty("StatusModificationTime",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).StatusModificationTime, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).StatusModificationUserName = (string) content.GetValueForProperty("StatusModificationUserName",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).StatusModificationUserName, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailOperator = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertOperator?) content.GetValueForProperty("DetailOperator",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailOperator, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertOperator.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DefinitionType = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertType?) content.GetValueForProperty("DefinitionType",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DefinitionType, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DefinitionCriterion = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria?) content.GetValueForProperty("DefinitionCriterion",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DefinitionCriterion, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailAmount = (decimal?) content.GetValueForProperty("DetailAmount",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailAmount, (__y)=> (decimal) global::System.Convert.ChangeType(__y, typeof(decimal))); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailContactEmail = (string[]) content.GetValueForProperty("DetailContactEmail",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailContactEmail, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailContactGroup = (string[]) content.GetValueForProperty("DetailContactGroup",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailContactGroup, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailContactRole = (string[]) content.GetValueForProperty("DetailContactRole",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailContactRole, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailCurrentSpend = (decimal?) content.GetValueForProperty("DetailCurrentSpend",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailCurrentSpend, (__y)=> (decimal) global::System.Convert.ChangeType(__y, typeof(decimal))); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailMeterFilter = (string[]) content.GetValueForProperty("DetailMeterFilter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailMeterFilter, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DefinitionCategory = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCategory?) content.GetValueForProperty("DefinitionCategory",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DefinitionCategory, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCategory.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailOverridingAlert = (string) content.GetValueForProperty("DetailOverridingAlert",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailOverridingAlert, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailPeriodStartDate = (string) content.GetValueForProperty("DetailPeriodStartDate",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailPeriodStartDate, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailResourceFilter = (string[]) content.GetValueForProperty("DetailResourceFilter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailResourceFilter, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailResourceGroupFilter = (string[]) content.GetValueForProperty("DetailResourceGroupFilter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailResourceGroupFilter, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailTagFilter = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsTagFilter) content.GetValueForProperty("DetailTagFilter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailTagFilter, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.AlertPropertiesDetailsTagFilterTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailThreshold = (decimal?) content.GetValueForProperty("DetailThreshold",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailThreshold, (__y)=> (decimal) global::System.Convert.ChangeType(__y, typeof(decimal))); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailTimeGrainType = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertTimeGrainType?) content.GetValueForProperty("DetailTimeGrainType",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailTimeGrainType, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertTimeGrainType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailTriggeredBy = (string) content.GetValueForProperty("DetailTriggeredBy",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailTriggeredBy, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailUnit = (string) content.GetValueForProperty("DetailUnit",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)this).DetailUnit, global::System.Convert.ToString); + AfterDeserializePSObject(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertProperties DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new AlertProperties(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertProperties DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new AlertProperties(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertProperties FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + [System.ComponentModel.TypeConverter(typeof(AlertPropertiesTypeConverter))] + public partial interface IAlertProperties + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/AlertProperties.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/AlertProperties.TypeConverter.cs new file mode 100644 index 000000000000..d7989c6fc6bb --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/AlertProperties.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class AlertPropertiesTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertProperties ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertProperties).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return AlertProperties.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return AlertProperties.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return AlertProperties.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/AlertProperties.cs b/src/CostManagement/generated/api/Models/Api20200601/AlertProperties.cs new file mode 100644 index 000000000000..345d342eccd3 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/AlertProperties.cs @@ -0,0 +1,468 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + public partial class AlertProperties : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertProperties, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal + { + + /// Backing field for property. + private string _closeTime; + + /// dateTime in which alert was closed + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string CloseTime { get => this._closeTime; set => this._closeTime = value; } + + /// Backing field for property. + private string _costEntityId; + + /// related budget + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string CostEntityId { get => this._costEntityId; set => this._costEntityId = value; } + + /// Backing field for property. + private string _creationTime; + + /// dateTime in which alert was created + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string CreationTime { get => this._creationTime; set => this._creationTime = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDefinition _definition; + + /// defines the type of alert + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + internal Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDefinition Definition { get => (this._definition = this._definition ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.AlertPropertiesDefinition()); set => this._definition = value; } + + /// Alert category + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCategory? DefinitionCategory { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDefinitionInternal)Definition).Category; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDefinitionInternal)Definition).Category = value; } + + /// Criteria that triggered alert + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria? DefinitionCriterion { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDefinitionInternal)Definition).Criterion; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDefinitionInternal)Definition).Criterion = value; } + + /// type of alert + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertType? DefinitionType { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDefinitionInternal)Definition).Type; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDefinitionInternal)Definition).Type = value; } + + /// Backing field for property. + private string _description; + + /// Alert description + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string Description { get => this._description; set => this._description = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetails _detail; + + /// Alert details + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + internal Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetails Detail { get => (this._detail = this._detail ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.AlertPropertiesDetails()); set => this._detail = value; } + + /// budget threshold amount + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public decimal? DetailAmount { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)Detail).Amount; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)Detail).Amount = value; } + + /// list of emails to contact + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string[] DetailContactEmail { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)Detail).ContactEmail; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)Detail).ContactEmail = value; } + + /// list of action groups to broadcast to + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string[] DetailContactGroup { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)Detail).ContactGroup; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)Detail).ContactGroup = value; } + + /// list of contact roles + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string[] DetailContactRole { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)Detail).ContactRole; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)Detail).ContactRole = value; } + + /// current spend + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public decimal? DetailCurrentSpend { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)Detail).CurrentSpend; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)Detail).CurrentSpend = value; } + + /// array of meters to filter by + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string[] DetailMeterFilter { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)Detail).MeterFilter; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)Detail).MeterFilter = value; } + + /// operator used to compare currentSpend with amount + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertOperator? DetailOperator { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)Detail).Operator; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)Detail).Operator = value; } + + /// overriding alert + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string DetailOverridingAlert { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)Detail).OverridingAlert; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)Detail).OverridingAlert = value; } + + /// datetime of periodStartDate + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string DetailPeriodStartDate { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)Detail).PeriodStartDate; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)Detail).PeriodStartDate = value; } + + /// array of resources to filter by + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string[] DetailResourceFilter { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)Detail).ResourceFilter; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)Detail).ResourceFilter = value; } + + /// array of resourceGroups to filter by + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string[] DetailResourceGroupFilter { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)Detail).ResourceGroupFilter; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)Detail).ResourceGroupFilter = value; } + + /// tags to filter by + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsTagFilter DetailTagFilter { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)Detail).TagFilter; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)Detail).TagFilter = value; } + + /// notification threshold percentage as a decimal which activated this alert + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public decimal? DetailThreshold { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)Detail).Threshold; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)Detail).Threshold = value; } + + /// Type of timegrain cadence + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertTimeGrainType? DetailTimeGrainType { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)Detail).TimeGrainType; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)Detail).TimeGrainType = value; } + + /// notificationId that triggered this alert + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string DetailTriggeredBy { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)Detail).TriggeredBy; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)Detail).TriggeredBy = value; } + + /// unit of currency being used + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string DetailUnit { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)Detail).Unit; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)Detail).Unit = value; } + + /// Internal Acessors for Definition + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDefinition Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal.Definition { get => (this._definition = this._definition ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.AlertPropertiesDefinition()); set { {_definition = value;} } } + + /// Internal Acessors for Detail + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetails Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal.Detail { get => (this._detail = this._detail ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.AlertPropertiesDetails()); set { {_detail = value;} } } + + /// Backing field for property. + private string _modificationTime; + + /// dateTime in which alert was last modified + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string ModificationTime { get => this._modificationTime; set => this._modificationTime = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertSource? _source; + + /// Source of alert + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertSource? Source { get => this._source; set => this._source = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertStatus? _status; + + /// alert status + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertStatus? Status { get => this._status; set => this._status = value; } + + /// Backing field for property. + private string _statusModificationTime; + + /// dateTime in which the alert status was last modified + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string StatusModificationTime { get => this._statusModificationTime; set => this._statusModificationTime = value; } + + /// Backing field for property. + private string _statusModificationUserName; + + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string StatusModificationUserName { get => this._statusModificationUserName; set => this._statusModificationUserName = value; } + + /// Creates an new instance. + public AlertProperties() + { + + } + } + public partial interface IAlertProperties : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// dateTime in which alert was closed + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"dateTime in which alert was closed", + SerializedName = @"closeTime", + PossibleTypes = new [] { typeof(string) })] + string CloseTime { get; set; } + /// related budget + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"related budget", + SerializedName = @"costEntityId", + PossibleTypes = new [] { typeof(string) })] + string CostEntityId { get; set; } + /// dateTime in which alert was created + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"dateTime in which alert was created", + SerializedName = @"creationTime", + PossibleTypes = new [] { typeof(string) })] + string CreationTime { get; set; } + /// Alert category + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Alert category", + SerializedName = @"category", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCategory) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCategory? DefinitionCategory { get; set; } + /// Criteria that triggered alert + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Criteria that triggered alert", + SerializedName = @"criteria", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria? DefinitionCriterion { get; set; } + /// type of alert + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"type of alert", + SerializedName = @"type", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertType? DefinitionType { get; set; } + /// Alert description + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Alert description", + SerializedName = @"description", + PossibleTypes = new [] { typeof(string) })] + string Description { get; set; } + /// budget threshold amount + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"budget threshold amount", + SerializedName = @"amount", + PossibleTypes = new [] { typeof(decimal) })] + decimal? DetailAmount { get; set; } + /// list of emails to contact + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"list of emails to contact", + SerializedName = @"contactEmails", + PossibleTypes = new [] { typeof(string) })] + string[] DetailContactEmail { get; set; } + /// list of action groups to broadcast to + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"list of action groups to broadcast to", + SerializedName = @"contactGroups", + PossibleTypes = new [] { typeof(string) })] + string[] DetailContactGroup { get; set; } + /// list of contact roles + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"list of contact roles", + SerializedName = @"contactRoles", + PossibleTypes = new [] { typeof(string) })] + string[] DetailContactRole { get; set; } + /// current spend + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"current spend", + SerializedName = @"currentSpend", + PossibleTypes = new [] { typeof(decimal) })] + decimal? DetailCurrentSpend { get; set; } + /// array of meters to filter by + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"array of meters to filter by", + SerializedName = @"meterFilter", + PossibleTypes = new [] { typeof(string) })] + string[] DetailMeterFilter { get; set; } + /// operator used to compare currentSpend with amount + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"operator used to compare currentSpend with amount", + SerializedName = @"operator", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertOperator) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertOperator? DetailOperator { get; set; } + /// overriding alert + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"overriding alert", + SerializedName = @"overridingAlert", + PossibleTypes = new [] { typeof(string) })] + string DetailOverridingAlert { get; set; } + /// datetime of periodStartDate + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"datetime of periodStartDate", + SerializedName = @"periodStartDate", + PossibleTypes = new [] { typeof(string) })] + string DetailPeriodStartDate { get; set; } + /// array of resources to filter by + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"array of resources to filter by", + SerializedName = @"resourceFilter", + PossibleTypes = new [] { typeof(string) })] + string[] DetailResourceFilter { get; set; } + /// array of resourceGroups to filter by + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"array of resourceGroups to filter by", + SerializedName = @"resourceGroupFilter", + PossibleTypes = new [] { typeof(string) })] + string[] DetailResourceGroupFilter { get; set; } + /// tags to filter by + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"tags to filter by", + SerializedName = @"tagFilter", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsTagFilter) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsTagFilter DetailTagFilter { get; set; } + /// notification threshold percentage as a decimal which activated this alert + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"notification threshold percentage as a decimal which activated this alert", + SerializedName = @"threshold", + PossibleTypes = new [] { typeof(decimal) })] + decimal? DetailThreshold { get; set; } + /// Type of timegrain cadence + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Type of timegrain cadence", + SerializedName = @"timeGrainType", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertTimeGrainType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertTimeGrainType? DetailTimeGrainType { get; set; } + /// notificationId that triggered this alert + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"notificationId that triggered this alert", + SerializedName = @"triggeredBy", + PossibleTypes = new [] { typeof(string) })] + string DetailTriggeredBy { get; set; } + /// unit of currency being used + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"unit of currency being used", + SerializedName = @"unit", + PossibleTypes = new [] { typeof(string) })] + string DetailUnit { get; set; } + /// dateTime in which alert was last modified + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"dateTime in which alert was last modified", + SerializedName = @"modificationTime", + PossibleTypes = new [] { typeof(string) })] + string ModificationTime { get; set; } + /// Source of alert + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Source of alert", + SerializedName = @"source", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertSource) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertSource? Source { get; set; } + /// alert status + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"alert status", + SerializedName = @"status", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertStatus) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertStatus? Status { get; set; } + /// dateTime in which the alert status was last modified + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"dateTime in which the alert status was last modified", + SerializedName = @"statusModificationTime", + PossibleTypes = new [] { typeof(string) })] + string StatusModificationTime { get; set; } + + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"", + SerializedName = @"statusModificationUserName", + PossibleTypes = new [] { typeof(string) })] + string StatusModificationUserName { get; set; } + + } + public partial interface IAlertPropertiesInternal + + { + /// dateTime in which alert was closed + string CloseTime { get; set; } + /// related budget + string CostEntityId { get; set; } + /// dateTime in which alert was created + string CreationTime { get; set; } + /// defines the type of alert + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDefinition Definition { get; set; } + /// Alert category + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCategory? DefinitionCategory { get; set; } + /// Criteria that triggered alert + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria? DefinitionCriterion { get; set; } + /// type of alert + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertType? DefinitionType { get; set; } + /// Alert description + string Description { get; set; } + /// Alert details + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetails Detail { get; set; } + /// budget threshold amount + decimal? DetailAmount { get; set; } + /// list of emails to contact + string[] DetailContactEmail { get; set; } + /// list of action groups to broadcast to + string[] DetailContactGroup { get; set; } + /// list of contact roles + string[] DetailContactRole { get; set; } + /// current spend + decimal? DetailCurrentSpend { get; set; } + /// array of meters to filter by + string[] DetailMeterFilter { get; set; } + /// operator used to compare currentSpend with amount + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertOperator? DetailOperator { get; set; } + /// overriding alert + string DetailOverridingAlert { get; set; } + /// datetime of periodStartDate + string DetailPeriodStartDate { get; set; } + /// array of resources to filter by + string[] DetailResourceFilter { get; set; } + /// array of resourceGroups to filter by + string[] DetailResourceGroupFilter { get; set; } + /// tags to filter by + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsTagFilter DetailTagFilter { get; set; } + /// notification threshold percentage as a decimal which activated this alert + decimal? DetailThreshold { get; set; } + /// Type of timegrain cadence + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertTimeGrainType? DetailTimeGrainType { get; set; } + /// notificationId that triggered this alert + string DetailTriggeredBy { get; set; } + /// unit of currency being used + string DetailUnit { get; set; } + /// dateTime in which alert was last modified + string ModificationTime { get; set; } + /// Source of alert + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertSource? Source { get; set; } + /// alert status + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertStatus? Status { get; set; } + /// dateTime in which the alert status was last modified + string StatusModificationTime { get; set; } + + string StatusModificationUserName { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/AlertProperties.json.cs b/src/CostManagement/generated/api/Models/Api20200601/AlertProperties.json.cs new file mode 100644 index 000000000000..01ec5e37957a --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/AlertProperties.json.cs @@ -0,0 +1,120 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + public partial class AlertProperties + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal AlertProperties(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_definition = If( json?.PropertyT("definition"), out var __jsonDefinition) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.AlertPropertiesDefinition.FromJson(__jsonDefinition) : Definition;} + {_detail = If( json?.PropertyT("details"), out var __jsonDetails) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.AlertPropertiesDetails.FromJson(__jsonDetails) : Detail;} + {_description = If( json?.PropertyT("description"), out var __jsonDescription) ? (string)__jsonDescription : (string)Description;} + {_closeTime = If( json?.PropertyT("closeTime"), out var __jsonCloseTime) ? (string)__jsonCloseTime : (string)CloseTime;} + {_costEntityId = If( json?.PropertyT("costEntityId"), out var __jsonCostEntityId) ? (string)__jsonCostEntityId : (string)CostEntityId;} + {_creationTime = If( json?.PropertyT("creationTime"), out var __jsonCreationTime) ? (string)__jsonCreationTime : (string)CreationTime;} + {_modificationTime = If( json?.PropertyT("modificationTime"), out var __jsonModificationTime) ? (string)__jsonModificationTime : (string)ModificationTime;} + {_source = If( json?.PropertyT("source"), out var __jsonSource) ? (string)__jsonSource : (string)Source;} + {_status = If( json?.PropertyT("status"), out var __jsonStatus) ? (string)__jsonStatus : (string)Status;} + {_statusModificationTime = If( json?.PropertyT("statusModificationTime"), out var __jsonStatusModificationTime) ? (string)__jsonStatusModificationTime : (string)StatusModificationTime;} + {_statusModificationUserName = If( json?.PropertyT("statusModificationUserName"), out var __jsonStatusModificationUserName) ? (string)__jsonStatusModificationUserName : (string)StatusModificationUserName;} + AfterFromJson(json); + } + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertProperties. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertProperties. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertProperties FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new AlertProperties(json) : null; + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + AddIf( null != this._definition ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._definition.ToJson(null,serializationMode) : null, "definition" ,container.Add ); + AddIf( null != this._detail ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._detail.ToJson(null,serializationMode) : null, "details" ,container.Add ); + AddIf( null != (((object)this._description)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._description.ToString()) : null, "description" ,container.Add ); + AddIf( null != (((object)this._closeTime)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._closeTime.ToString()) : null, "closeTime" ,container.Add ); + AddIf( null != (((object)this._costEntityId)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._costEntityId.ToString()) : null, "costEntityId" ,container.Add ); + AddIf( null != (((object)this._creationTime)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._creationTime.ToString()) : null, "creationTime" ,container.Add ); + AddIf( null != (((object)this._modificationTime)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._modificationTime.ToString()) : null, "modificationTime" ,container.Add ); + AddIf( null != (((object)this._source)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._source.ToString()) : null, "source" ,container.Add ); + AddIf( null != (((object)this._status)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._status.ToString()) : null, "status" ,container.Add ); + AddIf( null != (((object)this._statusModificationTime)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._statusModificationTime.ToString()) : null, "statusModificationTime" ,container.Add ); + AddIf( null != (((object)this._statusModificationUserName)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._statusModificationUserName.ToString()) : null, "statusModificationUserName" ,container.Add ); + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/AlertPropertiesDefinition.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/AlertPropertiesDefinition.PowerShell.cs new file mode 100644 index 000000000000..00e49a6ca104 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/AlertPropertiesDefinition.PowerShell.cs @@ -0,0 +1,137 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// defines the type of alert + [System.ComponentModel.TypeConverter(typeof(AlertPropertiesDefinitionTypeConverter))] + public partial class AlertPropertiesDefinition + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal AlertPropertiesDefinition(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDefinitionInternal)this).Type = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertType?) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDefinitionInternal)this).Type, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDefinitionInternal)this).Category = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCategory?) content.GetValueForProperty("Category",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDefinitionInternal)this).Category, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCategory.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDefinitionInternal)this).Criterion = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria?) content.GetValueForProperty("Criterion",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDefinitionInternal)this).Criterion, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria.CreateFrom); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal AlertPropertiesDefinition(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDefinitionInternal)this).Type = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertType?) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDefinitionInternal)this).Type, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDefinitionInternal)this).Category = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCategory?) content.GetValueForProperty("Category",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDefinitionInternal)this).Category, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCategory.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDefinitionInternal)this).Criterion = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria?) content.GetValueForProperty("Criterion",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDefinitionInternal)this).Criterion, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria.CreateFrom); + AfterDeserializePSObject(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDefinition DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new AlertPropertiesDefinition(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDefinition DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new AlertPropertiesDefinition(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDefinition FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// defines the type of alert + [System.ComponentModel.TypeConverter(typeof(AlertPropertiesDefinitionTypeConverter))] + public partial interface IAlertPropertiesDefinition + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/AlertPropertiesDefinition.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/AlertPropertiesDefinition.TypeConverter.cs new file mode 100644 index 000000000000..6dc3e1f089d2 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/AlertPropertiesDefinition.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class AlertPropertiesDefinitionTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDefinition ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDefinition).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return AlertPropertiesDefinition.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return AlertPropertiesDefinition.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return AlertPropertiesDefinition.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/AlertPropertiesDefinition.cs b/src/CostManagement/generated/api/Models/Api20200601/AlertPropertiesDefinition.cs new file mode 100644 index 000000000000..d256488ae949 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/AlertPropertiesDefinition.cs @@ -0,0 +1,80 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// defines the type of alert + public partial class AlertPropertiesDefinition : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDefinition, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDefinitionInternal + { + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCategory? _category; + + /// Alert category + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCategory? Category { get => this._category; set => this._category = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria? _criterion; + + /// Criteria that triggered alert + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria? Criterion { get => this._criterion; set => this._criterion = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertType? _type; + + /// type of alert + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertType? Type { get => this._type; set => this._type = value; } + + /// Creates an new instance. + public AlertPropertiesDefinition() + { + + } + } + /// defines the type of alert + public partial interface IAlertPropertiesDefinition : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// Alert category + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Alert category", + SerializedName = @"category", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCategory) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCategory? Category { get; set; } + /// Criteria that triggered alert + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Criteria that triggered alert", + SerializedName = @"criteria", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria? Criterion { get; set; } + /// type of alert + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"type of alert", + SerializedName = @"type", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertType? Type { get; set; } + + } + /// defines the type of alert + public partial interface IAlertPropertiesDefinitionInternal + + { + /// Alert category + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCategory? Category { get; set; } + /// Criteria that triggered alert + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria? Criterion { get; set; } + /// type of alert + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertType? Type { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/AlertPropertiesDefinition.json.cs b/src/CostManagement/generated/api/Models/Api20200601/AlertPropertiesDefinition.json.cs new file mode 100644 index 000000000000..f5b24f5c9e76 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/AlertPropertiesDefinition.json.cs @@ -0,0 +1,105 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// defines the type of alert + public partial class AlertPropertiesDefinition + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal AlertPropertiesDefinition(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_type = If( json?.PropertyT("type"), out var __jsonType) ? (string)__jsonType : (string)Type;} + {_category = If( json?.PropertyT("category"), out var __jsonCategory) ? (string)__jsonCategory : (string)Category;} + {_criterion = If( json?.PropertyT("criteria"), out var __jsonCriteria) ? (string)__jsonCriteria : (string)Criterion;} + AfterFromJson(json); + } + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDefinition. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDefinition. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDefinition FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new AlertPropertiesDefinition(json) : null; + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + AddIf( null != (((object)this._type)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._type.ToString()) : null, "type" ,container.Add ); + AddIf( null != (((object)this._category)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._category.ToString()) : null, "category" ,container.Add ); + AddIf( null != (((object)this._criterion)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._criterion.ToString()) : null, "criteria" ,container.Add ); + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/AlertPropertiesDetails.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/AlertPropertiesDetails.PowerShell.cs new file mode 100644 index 000000000000..7789165faa62 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/AlertPropertiesDetails.PowerShell.cs @@ -0,0 +1,163 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// Alert details + [System.ComponentModel.TypeConverter(typeof(AlertPropertiesDetailsTypeConverter))] + public partial class AlertPropertiesDetails + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal AlertPropertiesDetails(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).Amount = (decimal?) content.GetValueForProperty("Amount",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).Amount, (__y)=> (decimal) global::System.Convert.ChangeType(__y, typeof(decimal))); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).ContactEmail = (string[]) content.GetValueForProperty("ContactEmail",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).ContactEmail, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).ContactGroup = (string[]) content.GetValueForProperty("ContactGroup",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).ContactGroup, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).ContactRole = (string[]) content.GetValueForProperty("ContactRole",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).ContactRole, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).CurrentSpend = (decimal?) content.GetValueForProperty("CurrentSpend",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).CurrentSpend, (__y)=> (decimal) global::System.Convert.ChangeType(__y, typeof(decimal))); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).MeterFilter = (string[]) content.GetValueForProperty("MeterFilter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).MeterFilter, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).Operator = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertOperator?) content.GetValueForProperty("Operator",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).Operator, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertOperator.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).OverridingAlert = (string) content.GetValueForProperty("OverridingAlert",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).OverridingAlert, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).PeriodStartDate = (string) content.GetValueForProperty("PeriodStartDate",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).PeriodStartDate, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).ResourceFilter = (string[]) content.GetValueForProperty("ResourceFilter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).ResourceFilter, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).ResourceGroupFilter = (string[]) content.GetValueForProperty("ResourceGroupFilter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).ResourceGroupFilter, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).TagFilter = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsTagFilter) content.GetValueForProperty("TagFilter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).TagFilter, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.AlertPropertiesDetailsTagFilterTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).Threshold = (decimal?) content.GetValueForProperty("Threshold",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).Threshold, (__y)=> (decimal) global::System.Convert.ChangeType(__y, typeof(decimal))); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).TimeGrainType = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertTimeGrainType?) content.GetValueForProperty("TimeGrainType",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).TimeGrainType, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertTimeGrainType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).TriggeredBy = (string) content.GetValueForProperty("TriggeredBy",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).TriggeredBy, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).Unit = (string) content.GetValueForProperty("Unit",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).Unit, global::System.Convert.ToString); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal AlertPropertiesDetails(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).Amount = (decimal?) content.GetValueForProperty("Amount",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).Amount, (__y)=> (decimal) global::System.Convert.ChangeType(__y, typeof(decimal))); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).ContactEmail = (string[]) content.GetValueForProperty("ContactEmail",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).ContactEmail, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).ContactGroup = (string[]) content.GetValueForProperty("ContactGroup",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).ContactGroup, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).ContactRole = (string[]) content.GetValueForProperty("ContactRole",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).ContactRole, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).CurrentSpend = (decimal?) content.GetValueForProperty("CurrentSpend",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).CurrentSpend, (__y)=> (decimal) global::System.Convert.ChangeType(__y, typeof(decimal))); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).MeterFilter = (string[]) content.GetValueForProperty("MeterFilter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).MeterFilter, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).Operator = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertOperator?) content.GetValueForProperty("Operator",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).Operator, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertOperator.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).OverridingAlert = (string) content.GetValueForProperty("OverridingAlert",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).OverridingAlert, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).PeriodStartDate = (string) content.GetValueForProperty("PeriodStartDate",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).PeriodStartDate, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).ResourceFilter = (string[]) content.GetValueForProperty("ResourceFilter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).ResourceFilter, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).ResourceGroupFilter = (string[]) content.GetValueForProperty("ResourceGroupFilter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).ResourceGroupFilter, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).TagFilter = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsTagFilter) content.GetValueForProperty("TagFilter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).TagFilter, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.AlertPropertiesDetailsTagFilterTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).Threshold = (decimal?) content.GetValueForProperty("Threshold",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).Threshold, (__y)=> (decimal) global::System.Convert.ChangeType(__y, typeof(decimal))); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).TimeGrainType = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertTimeGrainType?) content.GetValueForProperty("TimeGrainType",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).TimeGrainType, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertTimeGrainType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).TriggeredBy = (string) content.GetValueForProperty("TriggeredBy",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).TriggeredBy, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).Unit = (string) content.GetValueForProperty("Unit",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal)this).Unit, global::System.Convert.ToString); + AfterDeserializePSObject(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetails DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new AlertPropertiesDetails(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetails DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new AlertPropertiesDetails(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetails FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// Alert details + [System.ComponentModel.TypeConverter(typeof(AlertPropertiesDetailsTypeConverter))] + public partial interface IAlertPropertiesDetails + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/AlertPropertiesDetails.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/AlertPropertiesDetails.TypeConverter.cs new file mode 100644 index 000000000000..e8350c9c3376 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/AlertPropertiesDetails.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class AlertPropertiesDetailsTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetails ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetails).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return AlertPropertiesDetails.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return AlertPropertiesDetails.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return AlertPropertiesDetails.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/AlertPropertiesDetails.cs b/src/CostManagement/generated/api/Models/Api20200601/AlertPropertiesDetails.cs new file mode 100644 index 000000000000..71be0bfb10b7 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/AlertPropertiesDetails.cs @@ -0,0 +1,301 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// Alert details + public partial class AlertPropertiesDetails : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetails, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsInternal + { + + /// Backing field for property. + private decimal? _amount; + + /// budget threshold amount + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public decimal? Amount { get => this._amount; set => this._amount = value; } + + /// Backing field for property. + private string[] _contactEmail; + + /// list of emails to contact + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string[] ContactEmail { get => this._contactEmail; set => this._contactEmail = value; } + + /// Backing field for property. + private string[] _contactGroup; + + /// list of action groups to broadcast to + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string[] ContactGroup { get => this._contactGroup; set => this._contactGroup = value; } + + /// Backing field for property. + private string[] _contactRole; + + /// list of contact roles + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string[] ContactRole { get => this._contactRole; set => this._contactRole = value; } + + /// Backing field for property. + private decimal? _currentSpend; + + /// current spend + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public decimal? CurrentSpend { get => this._currentSpend; set => this._currentSpend = value; } + + /// Backing field for property. + private string[] _meterFilter; + + /// array of meters to filter by + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string[] MeterFilter { get => this._meterFilter; set => this._meterFilter = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertOperator? _operator; + + /// operator used to compare currentSpend with amount + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertOperator? Operator { get => this._operator; set => this._operator = value; } + + /// Backing field for property. + private string _overridingAlert; + + /// overriding alert + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string OverridingAlert { get => this._overridingAlert; set => this._overridingAlert = value; } + + /// Backing field for property. + private string _periodStartDate; + + /// datetime of periodStartDate + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string PeriodStartDate { get => this._periodStartDate; set => this._periodStartDate = value; } + + /// Backing field for property. + private string[] _resourceFilter; + + /// array of resources to filter by + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string[] ResourceFilter { get => this._resourceFilter; set => this._resourceFilter = value; } + + /// Backing field for property. + private string[] _resourceGroupFilter; + + /// array of resourceGroups to filter by + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string[] ResourceGroupFilter { get => this._resourceGroupFilter; set => this._resourceGroupFilter = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsTagFilter _tagFilter; + + /// tags to filter by + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsTagFilter TagFilter { get => (this._tagFilter = this._tagFilter ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.AlertPropertiesDetailsTagFilter()); set => this._tagFilter = value; } + + /// Backing field for property. + private decimal? _threshold; + + /// notification threshold percentage as a decimal which activated this alert + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public decimal? Threshold { get => this._threshold; set => this._threshold = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertTimeGrainType? _timeGrainType; + + /// Type of timegrain cadence + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertTimeGrainType? TimeGrainType { get => this._timeGrainType; set => this._timeGrainType = value; } + + /// Backing field for property. + private string _triggeredBy; + + /// notificationId that triggered this alert + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string TriggeredBy { get => this._triggeredBy; set => this._triggeredBy = value; } + + /// Backing field for property. + private string _unit; + + /// unit of currency being used + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string Unit { get => this._unit; set => this._unit = value; } + + /// Creates an new instance. + public AlertPropertiesDetails() + { + + } + } + /// Alert details + public partial interface IAlertPropertiesDetails : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// budget threshold amount + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"budget threshold amount", + SerializedName = @"amount", + PossibleTypes = new [] { typeof(decimal) })] + decimal? Amount { get; set; } + /// list of emails to contact + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"list of emails to contact", + SerializedName = @"contactEmails", + PossibleTypes = new [] { typeof(string) })] + string[] ContactEmail { get; set; } + /// list of action groups to broadcast to + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"list of action groups to broadcast to", + SerializedName = @"contactGroups", + PossibleTypes = new [] { typeof(string) })] + string[] ContactGroup { get; set; } + /// list of contact roles + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"list of contact roles", + SerializedName = @"contactRoles", + PossibleTypes = new [] { typeof(string) })] + string[] ContactRole { get; set; } + /// current spend + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"current spend", + SerializedName = @"currentSpend", + PossibleTypes = new [] { typeof(decimal) })] + decimal? CurrentSpend { get; set; } + /// array of meters to filter by + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"array of meters to filter by", + SerializedName = @"meterFilter", + PossibleTypes = new [] { typeof(string) })] + string[] MeterFilter { get; set; } + /// operator used to compare currentSpend with amount + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"operator used to compare currentSpend with amount", + SerializedName = @"operator", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertOperator) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertOperator? Operator { get; set; } + /// overriding alert + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"overriding alert", + SerializedName = @"overridingAlert", + PossibleTypes = new [] { typeof(string) })] + string OverridingAlert { get; set; } + /// datetime of periodStartDate + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"datetime of periodStartDate", + SerializedName = @"periodStartDate", + PossibleTypes = new [] { typeof(string) })] + string PeriodStartDate { get; set; } + /// array of resources to filter by + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"array of resources to filter by", + SerializedName = @"resourceFilter", + PossibleTypes = new [] { typeof(string) })] + string[] ResourceFilter { get; set; } + /// array of resourceGroups to filter by + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"array of resourceGroups to filter by", + SerializedName = @"resourceGroupFilter", + PossibleTypes = new [] { typeof(string) })] + string[] ResourceGroupFilter { get; set; } + /// tags to filter by + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"tags to filter by", + SerializedName = @"tagFilter", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsTagFilter) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsTagFilter TagFilter { get; set; } + /// notification threshold percentage as a decimal which activated this alert + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"notification threshold percentage as a decimal which activated this alert", + SerializedName = @"threshold", + PossibleTypes = new [] { typeof(decimal) })] + decimal? Threshold { get; set; } + /// Type of timegrain cadence + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Type of timegrain cadence", + SerializedName = @"timeGrainType", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertTimeGrainType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertTimeGrainType? TimeGrainType { get; set; } + /// notificationId that triggered this alert + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"notificationId that triggered this alert", + SerializedName = @"triggeredBy", + PossibleTypes = new [] { typeof(string) })] + string TriggeredBy { get; set; } + /// unit of currency being used + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"unit of currency being used", + SerializedName = @"unit", + PossibleTypes = new [] { typeof(string) })] + string Unit { get; set; } + + } + /// Alert details + public partial interface IAlertPropertiesDetailsInternal + + { + /// budget threshold amount + decimal? Amount { get; set; } + /// list of emails to contact + string[] ContactEmail { get; set; } + /// list of action groups to broadcast to + string[] ContactGroup { get; set; } + /// list of contact roles + string[] ContactRole { get; set; } + /// current spend + decimal? CurrentSpend { get; set; } + /// array of meters to filter by + string[] MeterFilter { get; set; } + /// operator used to compare currentSpend with amount + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertOperator? Operator { get; set; } + /// overriding alert + string OverridingAlert { get; set; } + /// datetime of periodStartDate + string PeriodStartDate { get; set; } + /// array of resources to filter by + string[] ResourceFilter { get; set; } + /// array of resourceGroups to filter by + string[] ResourceGroupFilter { get; set; } + /// tags to filter by + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsTagFilter TagFilter { get; set; } + /// notification threshold percentage as a decimal which activated this alert + decimal? Threshold { get; set; } + /// Type of timegrain cadence + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertTimeGrainType? TimeGrainType { get; set; } + /// notificationId that triggered this alert + string TriggeredBy { get; set; } + /// unit of currency being used + string Unit { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/AlertPropertiesDetails.json.cs b/src/CostManagement/generated/api/Models/Api20200601/AlertPropertiesDetails.json.cs new file mode 100644 index 000000000000..16adc3c268e7 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/AlertPropertiesDetails.json.cs @@ -0,0 +1,179 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// Alert details + public partial class AlertPropertiesDetails + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal AlertPropertiesDetails(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_amount = If( json?.PropertyT("amount"), out var __jsonAmount) ? (decimal?)__jsonAmount : Amount;} + {_contactEmail = If( json?.PropertyT("contactEmails"), out var __jsonContactEmails) ? If( __jsonContactEmails as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonArray, out var __v) ? new global::System.Func(()=> global::System.Linq.Enumerable.ToArray(global::System.Linq.Enumerable.Select(__v, (__u)=>(string) (__u is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString __t ? (string)(__t.ToString()) : null)) ))() : null : ContactEmail;} + {_contactGroup = If( json?.PropertyT("contactGroups"), out var __jsonContactGroups) ? If( __jsonContactGroups as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonArray, out var __q) ? new global::System.Func(()=> global::System.Linq.Enumerable.ToArray(global::System.Linq.Enumerable.Select(__q, (__p)=>(string) (__p is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString __o ? (string)(__o.ToString()) : null)) ))() : null : ContactGroup;} + {_contactRole = If( json?.PropertyT("contactRoles"), out var __jsonContactRoles) ? If( __jsonContactRoles as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonArray, out var __l) ? new global::System.Func(()=> global::System.Linq.Enumerable.ToArray(global::System.Linq.Enumerable.Select(__l, (__k)=>(string) (__k is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString __j ? (string)(__j.ToString()) : null)) ))() : null : ContactRole;} + {_currentSpend = If( json?.PropertyT("currentSpend"), out var __jsonCurrentSpend) ? (decimal?)__jsonCurrentSpend : CurrentSpend;} + {_meterFilter = If( json?.PropertyT("meterFilter"), out var __jsonMeterFilter) ? If( __jsonMeterFilter as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonArray, out var __g) ? new global::System.Func(()=> global::System.Linq.Enumerable.ToArray(global::System.Linq.Enumerable.Select(__g, (__f)=>(string) (__f is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString __e ? (string)(__e.ToString()) : null)) ))() : null : MeterFilter;} + {_operator = If( json?.PropertyT("operator"), out var __jsonOperator) ? (string)__jsonOperator : (string)Operator;} + {_overridingAlert = If( json?.PropertyT("overridingAlert"), out var __jsonOverridingAlert) ? (string)__jsonOverridingAlert : (string)OverridingAlert;} + {_periodStartDate = If( json?.PropertyT("periodStartDate"), out var __jsonPeriodStartDate) ? (string)__jsonPeriodStartDate : (string)PeriodStartDate;} + {_resourceFilter = If( json?.PropertyT("resourceFilter"), out var __jsonResourceFilter) ? If( __jsonResourceFilter as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonArray, out var __b) ? new global::System.Func(()=> global::System.Linq.Enumerable.ToArray(global::System.Linq.Enumerable.Select(__b, (__a)=>(string) (__a is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString ___z ? (string)(___z.ToString()) : null)) ))() : null : ResourceFilter;} + {_resourceGroupFilter = If( json?.PropertyT("resourceGroupFilter"), out var __jsonResourceGroupFilter) ? If( __jsonResourceGroupFilter as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonArray, out var ___w) ? new global::System.Func(()=> global::System.Linq.Enumerable.ToArray(global::System.Linq.Enumerable.Select(___w, (___v)=>(string) (___v is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString ___u ? (string)(___u.ToString()) : null)) ))() : null : ResourceGroupFilter;} + {_tagFilter = If( json?.PropertyT("tagFilter"), out var __jsonTagFilter) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.AlertPropertiesDetailsTagFilter.FromJson(__jsonTagFilter) : TagFilter;} + {_threshold = If( json?.PropertyT("threshold"), out var __jsonThreshold) ? (decimal?)__jsonThreshold : Threshold;} + {_timeGrainType = If( json?.PropertyT("timeGrainType"), out var __jsonTimeGrainType) ? (string)__jsonTimeGrainType : (string)TimeGrainType;} + {_triggeredBy = If( json?.PropertyT("triggeredBy"), out var __jsonTriggeredBy) ? (string)__jsonTriggeredBy : (string)TriggeredBy;} + {_unit = If( json?.PropertyT("unit"), out var __jsonUnit) ? (string)__jsonUnit : (string)Unit;} + AfterFromJson(json); + } + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetails. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetails. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetails FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new AlertPropertiesDetails(json) : null; + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + AddIf( null != this._amount ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode)new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNumber((decimal)this._amount) : null, "amount" ,container.Add ); + if (null != this._contactEmail) + { + var __w = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.XNodeArray(); + foreach( var __x in this._contactEmail ) + { + AddIf(null != (((object)__x)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(__x.ToString()) : null ,__w.Add); + } + container.Add("contactEmails",__w); + } + if (null != this._contactGroup) + { + var __r = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.XNodeArray(); + foreach( var __s in this._contactGroup ) + { + AddIf(null != (((object)__s)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(__s.ToString()) : null ,__r.Add); + } + container.Add("contactGroups",__r); + } + if (null != this._contactRole) + { + var __m = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.XNodeArray(); + foreach( var __n in this._contactRole ) + { + AddIf(null != (((object)__n)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(__n.ToString()) : null ,__m.Add); + } + container.Add("contactRoles",__m); + } + AddIf( null != this._currentSpend ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode)new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNumber((decimal)this._currentSpend) : null, "currentSpend" ,container.Add ); + if (null != this._meterFilter) + { + var __h = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.XNodeArray(); + foreach( var __i in this._meterFilter ) + { + AddIf(null != (((object)__i)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(__i.ToString()) : null ,__h.Add); + } + container.Add("meterFilter",__h); + } + AddIf( null != (((object)this._operator)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._operator.ToString()) : null, "operator" ,container.Add ); + AddIf( null != (((object)this._overridingAlert)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._overridingAlert.ToString()) : null, "overridingAlert" ,container.Add ); + AddIf( null != (((object)this._periodStartDate)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._periodStartDate.ToString()) : null, "periodStartDate" ,container.Add ); + if (null != this._resourceFilter) + { + var __c = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.XNodeArray(); + foreach( var __d in this._resourceFilter ) + { + AddIf(null != (((object)__d)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(__d.ToString()) : null ,__c.Add); + } + container.Add("resourceFilter",__c); + } + if (null != this._resourceGroupFilter) + { + var ___x = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.XNodeArray(); + foreach( var ___y in this._resourceGroupFilter ) + { + AddIf(null != (((object)___y)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(___y.ToString()) : null ,___x.Add); + } + container.Add("resourceGroupFilter",___x); + } + AddIf( null != this._tagFilter ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._tagFilter.ToJson(null,serializationMode) : null, "tagFilter" ,container.Add ); + AddIf( null != this._threshold ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode)new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNumber((decimal)this._threshold) : null, "threshold" ,container.Add ); + AddIf( null != (((object)this._timeGrainType)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._timeGrainType.ToString()) : null, "timeGrainType" ,container.Add ); + AddIf( null != (((object)this._triggeredBy)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._triggeredBy.ToString()) : null, "triggeredBy" ,container.Add ); + AddIf( null != (((object)this._unit)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._unit.ToString()) : null, "unit" ,container.Add ); + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/AlertPropertiesDetailsTagFilter.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/AlertPropertiesDetailsTagFilter.PowerShell.cs new file mode 100644 index 000000000000..eaead2b24f16 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/AlertPropertiesDetailsTagFilter.PowerShell.cs @@ -0,0 +1,131 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// tags to filter by + [System.ComponentModel.TypeConverter(typeof(AlertPropertiesDetailsTagFilterTypeConverter))] + public partial class AlertPropertiesDetailsTagFilter + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal AlertPropertiesDetailsTagFilter(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal AlertPropertiesDetailsTagFilter(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + AfterDeserializePSObject(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsTagFilter DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new AlertPropertiesDetailsTagFilter(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsTagFilter DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new AlertPropertiesDetailsTagFilter(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsTagFilter FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// tags to filter by + [System.ComponentModel.TypeConverter(typeof(AlertPropertiesDetailsTagFilterTypeConverter))] + public partial interface IAlertPropertiesDetailsTagFilter + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/AlertPropertiesDetailsTagFilter.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/AlertPropertiesDetailsTagFilter.TypeConverter.cs new file mode 100644 index 000000000000..c1af6046e54b --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/AlertPropertiesDetailsTagFilter.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class AlertPropertiesDetailsTagFilterTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsTagFilter ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsTagFilter).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return AlertPropertiesDetailsTagFilter.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return AlertPropertiesDetailsTagFilter.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return AlertPropertiesDetailsTagFilter.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/AlertPropertiesDetailsTagFilter.cs b/src/CostManagement/generated/api/Models/Api20200601/AlertPropertiesDetailsTagFilter.cs new file mode 100644 index 000000000000..17afadbf6059 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/AlertPropertiesDetailsTagFilter.cs @@ -0,0 +1,29 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// tags to filter by + public partial class AlertPropertiesDetailsTagFilter : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsTagFilter, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsTagFilterInternal + { + + /// Creates an new instance. + public AlertPropertiesDetailsTagFilter() + { + + } + } + /// tags to filter by + public partial interface IAlertPropertiesDetailsTagFilter : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + + } + /// tags to filter by + public partial interface IAlertPropertiesDetailsTagFilterInternal + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/AlertPropertiesDetailsTagFilter.json.cs b/src/CostManagement/generated/api/Models/Api20200601/AlertPropertiesDetailsTagFilter.json.cs new file mode 100644 index 000000000000..6fe9ac5a76fe --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/AlertPropertiesDetailsTagFilter.json.cs @@ -0,0 +1,99 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// tags to filter by + public partial class AlertPropertiesDetailsTagFilter + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal AlertPropertiesDetailsTagFilter(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + AfterFromJson(json); + } + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsTagFilter. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsTagFilter. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsTagFilter FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new AlertPropertiesDetailsTagFilter(json) : null; + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/AlertsResult.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/AlertsResult.PowerShell.cs new file mode 100644 index 000000000000..b7ca4e7e7727 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/AlertsResult.PowerShell.cs @@ -0,0 +1,133 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// Result of alerts. + [System.ComponentModel.TypeConverter(typeof(AlertsResultTypeConverter))] + public partial class AlertsResult + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal AlertsResult(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertsResultInternal)this).NextLink = (string) content.GetValueForProperty("NextLink",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertsResultInternal)this).NextLink, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertsResultInternal)this).Value = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlert[]) content.GetValueForProperty("Value",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertsResultInternal)this).Value, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.AlertTypeConverter.ConvertFrom)); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal AlertsResult(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertsResultInternal)this).NextLink = (string) content.GetValueForProperty("NextLink",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertsResultInternal)this).NextLink, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertsResultInternal)this).Value = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlert[]) content.GetValueForProperty("Value",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertsResultInternal)this).Value, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.AlertTypeConverter.ConvertFrom)); + AfterDeserializePSObject(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertsResult DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new AlertsResult(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertsResult DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new AlertsResult(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertsResult FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// Result of alerts. + [System.ComponentModel.TypeConverter(typeof(AlertsResultTypeConverter))] + public partial interface IAlertsResult + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/AlertsResult.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/AlertsResult.TypeConverter.cs new file mode 100644 index 000000000000..2e2212b98696 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/AlertsResult.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class AlertsResultTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertsResult ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertsResult).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return AlertsResult.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return AlertsResult.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return AlertsResult.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/AlertsResult.cs b/src/CostManagement/generated/api/Models/Api20200601/AlertsResult.cs new file mode 100644 index 000000000000..5b3eac45aeb9 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/AlertsResult.cs @@ -0,0 +1,69 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// Result of alerts. + public partial class AlertsResult : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertsResult, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertsResultInternal + { + + /// Internal Acessors for NextLink + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertsResultInternal.NextLink { get => this._nextLink; set { {_nextLink = value;} } } + + /// Internal Acessors for Value + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlert[] Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertsResultInternal.Value { get => this._value; set { {_value = value;} } } + + /// Backing field for property. + private string _nextLink; + + /// URL to get the next set of alerts results if there are any. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string NextLink { get => this._nextLink; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlert[] _value; + + /// List of alerts. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlert[] Value { get => this._value; } + + /// Creates an new instance. + public AlertsResult() + { + + } + } + /// Result of alerts. + public partial interface IAlertsResult : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// URL to get the next set of alerts results if there are any. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"URL to get the next set of alerts results if there are any.", + SerializedName = @"nextLink", + PossibleTypes = new [] { typeof(string) })] + string NextLink { get; } + /// List of alerts. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"List of alerts.", + SerializedName = @"value", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlert) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlert[] Value { get; } + + } + /// Result of alerts. + public partial interface IAlertsResultInternal + + { + /// URL to get the next set of alerts results if there are any. + string NextLink { get; set; } + /// List of alerts. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlert[] Value { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/AlertsResult.json.cs b/src/CostManagement/generated/api/Models/Api20200601/AlertsResult.json.cs new file mode 100644 index 000000000000..b8a5b1b760eb --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/AlertsResult.json.cs @@ -0,0 +1,117 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// Result of alerts. + public partial class AlertsResult + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal AlertsResult(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_nextLink = If( json?.PropertyT("nextLink"), out var __jsonNextLink) ? (string)__jsonNextLink : (string)NextLink;} + {_value = If( json?.PropertyT("value"), out var __jsonValue) ? If( __jsonValue as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonArray, out var __v) ? new global::System.Func(()=> global::System.Linq.Enumerable.ToArray(global::System.Linq.Enumerable.Select(__v, (__u)=>(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlert) (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.Alert.FromJson(__u) )) ))() : null : Value;} + AfterFromJson(json); + } + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertsResult. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertsResult. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertsResult FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new AlertsResult(json) : null; + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeReadOnly)) + { + AddIf( null != (((object)this._nextLink)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._nextLink.ToString()) : null, "nextLink" ,container.Add ); + } + if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeReadOnly)) + { + if (null != this._value) + { + var __w = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.XNodeArray(); + foreach( var __x in this._value ) + { + AddIf(__x?.ToJson(null, serializationMode) ,__w.Add); + } + container.Add("value",__w); + } + } + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/CommonExportProperties.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/CommonExportProperties.PowerShell.cs new file mode 100644 index 000000000000..4975f6da417f --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/CommonExportProperties.PowerShell.cs @@ -0,0 +1,169 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// The common properties of the export. + [System.ComponentModel.TypeConverter(typeof(CommonExportPropertiesTypeConverter))] + public partial class CommonExportProperties + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal CommonExportProperties(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).Definition = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinition) content.GetValueForProperty("Definition",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).Definition, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDefinitionTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DeliveryInfo = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfo) content.GetValueForProperty("DeliveryInfo",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DeliveryInfo, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDeliveryInfoTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).RunHistory = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionListResult) content.GetValueForProperty("RunHistory",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).RunHistory, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportExecutionListResultTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).Format = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType?) content.GetValueForProperty("Format",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).Format, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).NextRunTimeEstimate = (global::System.DateTime?) content.GetValueForProperty("NextRunTimeEstimate",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).NextRunTimeEstimate, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DefinitionDataSet = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDataset) content.GetValueForProperty("DefinitionDataSet",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DefinitionDataSet, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDatasetTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).RunHistoryValue = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution[]) content.GetValueForProperty("RunHistoryValue",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).RunHistoryValue, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportExecutionTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DefinitionType = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType) content.GetValueForProperty("DefinitionType",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DefinitionType, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DefinitionTimeframe = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType) content.GetValueForProperty("DefinitionTimeframe",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DefinitionTimeframe, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DeliveryInfoDestination = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestination) content.GetValueForProperty("DeliveryInfoDestination",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DeliveryInfoDestination, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDeliveryDestinationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DefinitionTimePeriod = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportTimePeriod) content.GetValueForProperty("DefinitionTimePeriod",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DefinitionTimePeriod, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportTimePeriodTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).TimePeriodFrom = (global::System.DateTime) content.GetValueForProperty("TimePeriodFrom",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).TimePeriodFrom, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DataSetGranularity = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType?) content.GetValueForProperty("DataSetGranularity",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DataSetGranularity, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DataSetConfiguration = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetConfiguration) content.GetValueForProperty("DataSetConfiguration",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DataSetConfiguration, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDatasetConfigurationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DestinationContainer = (string) content.GetValueForProperty("DestinationContainer",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DestinationContainer, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DestinationResourceId = (string) content.GetValueForProperty("DestinationResourceId",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DestinationResourceId, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DestinationRootFolderPath = (string) content.GetValueForProperty("DestinationRootFolderPath",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DestinationRootFolderPath, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).TimePeriodTo = (global::System.DateTime) content.GetValueForProperty("TimePeriodTo",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).TimePeriodTo, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).ConfigurationColumn = (string[]) content.GetValueForProperty("ConfigurationColumn",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).ConfigurationColumn, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal CommonExportProperties(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).Definition = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinition) content.GetValueForProperty("Definition",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).Definition, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDefinitionTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DeliveryInfo = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfo) content.GetValueForProperty("DeliveryInfo",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DeliveryInfo, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDeliveryInfoTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).RunHistory = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionListResult) content.GetValueForProperty("RunHistory",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).RunHistory, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportExecutionListResultTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).Format = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType?) content.GetValueForProperty("Format",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).Format, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).NextRunTimeEstimate = (global::System.DateTime?) content.GetValueForProperty("NextRunTimeEstimate",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).NextRunTimeEstimate, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DefinitionDataSet = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDataset) content.GetValueForProperty("DefinitionDataSet",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DefinitionDataSet, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDatasetTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).RunHistoryValue = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution[]) content.GetValueForProperty("RunHistoryValue",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).RunHistoryValue, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportExecutionTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DefinitionType = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType) content.GetValueForProperty("DefinitionType",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DefinitionType, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DefinitionTimeframe = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType) content.GetValueForProperty("DefinitionTimeframe",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DefinitionTimeframe, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DeliveryInfoDestination = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestination) content.GetValueForProperty("DeliveryInfoDestination",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DeliveryInfoDestination, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDeliveryDestinationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DefinitionTimePeriod = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportTimePeriod) content.GetValueForProperty("DefinitionTimePeriod",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DefinitionTimePeriod, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportTimePeriodTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).TimePeriodFrom = (global::System.DateTime) content.GetValueForProperty("TimePeriodFrom",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).TimePeriodFrom, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DataSetGranularity = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType?) content.GetValueForProperty("DataSetGranularity",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DataSetGranularity, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DataSetConfiguration = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetConfiguration) content.GetValueForProperty("DataSetConfiguration",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DataSetConfiguration, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDatasetConfigurationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DestinationContainer = (string) content.GetValueForProperty("DestinationContainer",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DestinationContainer, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DestinationResourceId = (string) content.GetValueForProperty("DestinationResourceId",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DestinationResourceId, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DestinationRootFolderPath = (string) content.GetValueForProperty("DestinationRootFolderPath",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DestinationRootFolderPath, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).TimePeriodTo = (global::System.DateTime) content.GetValueForProperty("TimePeriodTo",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).TimePeriodTo, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).ConfigurationColumn = (string[]) content.GetValueForProperty("ConfigurationColumn",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).ConfigurationColumn, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + AfterDeserializePSObject(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportProperties DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new CommonExportProperties(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportProperties DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new CommonExportProperties(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportProperties FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// The common properties of the export. + [System.ComponentModel.TypeConverter(typeof(CommonExportPropertiesTypeConverter))] + public partial interface ICommonExportProperties + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/CommonExportProperties.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/CommonExportProperties.TypeConverter.cs new file mode 100644 index 000000000000..fee5f3273103 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/CommonExportProperties.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class CommonExportPropertiesTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportProperties ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportProperties).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return CommonExportProperties.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return CommonExportProperties.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return CommonExportProperties.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/CommonExportProperties.cs b/src/CostManagement/generated/api/Models/Api20200601/CommonExportProperties.cs new file mode 100644 index 000000000000..c2391f7622a3 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/CommonExportProperties.cs @@ -0,0 +1,295 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The common properties of the export. + public partial class CommonExportProperties : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportProperties, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal + { + + /// + /// Array of column names to be included in the export. If not provided then the export will include all available columns. + /// The available columns can vary by customer channel (see examples). + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string[] ConfigurationColumn { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)Definition).ConfigurationColumn; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)Definition).ConfigurationColumn = value; } + + /// The granularity of rows in the export. Currently only 'Daily' is supported. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType? DataSetGranularity { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)Definition).DataSetGranularity; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)Definition).DataSetGranularity = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinition _definition; + + /// Has the definition for the export. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + internal Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinition Definition { get => (this._definition = this._definition ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDefinition()); set => this._definition = value; } + + /// + /// The time frame for pulling data for the export. If custom, then a specific time period must be provided. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType DefinitionTimeframe { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)Definition).Timeframe; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)Definition).Timeframe = value; } + + /// + /// The type of the export. Note that 'Usage' is equivalent to 'ActualCost' and is applicable to exports that do not yet provide + /// data for charges or amortization for service reservations. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType DefinitionType { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)Definition).Type; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)Definition).Type = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfo _deliveryInfo; + + /// Has delivery information for the export. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + internal Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfo DeliveryInfo { get => (this._deliveryInfo = this._deliveryInfo ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDeliveryInfo()); set => this._deliveryInfo = value; } + + /// The name of the container where exports will be uploaded. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string DestinationContainer { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfoInternal)DeliveryInfo).DestinationContainer; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfoInternal)DeliveryInfo).DestinationContainer = value; } + + /// The resource id of the storage account where exports will be delivered. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string DestinationResourceId { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfoInternal)DeliveryInfo).DestinationResourceId; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfoInternal)DeliveryInfo).DestinationResourceId = value; } + + /// The name of the directory where exports will be uploaded. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string DestinationRootFolderPath { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfoInternal)DeliveryInfo).DestinationRootFolderPath; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfoInternal)DeliveryInfo).DestinationRootFolderPath = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType? _format; + + /// The format of the export being delivered. Currently only 'Csv' is supported. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType? Format { get => this._format; set => this._format = value; } + + /// Internal Acessors for DataSetConfiguration + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetConfiguration Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal.DataSetConfiguration { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)Definition).DataSetConfiguration; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)Definition).DataSetConfiguration = value; } + + /// Internal Acessors for Definition + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinition Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal.Definition { get => (this._definition = this._definition ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDefinition()); set { {_definition = value;} } } + + /// Internal Acessors for DefinitionDataSet + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDataset Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal.DefinitionDataSet { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)Definition).DataSet; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)Definition).DataSet = value; } + + /// Internal Acessors for DefinitionTimePeriod + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportTimePeriod Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal.DefinitionTimePeriod { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)Definition).TimePeriod; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)Definition).TimePeriod = value; } + + /// Internal Acessors for DeliveryInfo + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfo Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal.DeliveryInfo { get => (this._deliveryInfo = this._deliveryInfo ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDeliveryInfo()); set { {_deliveryInfo = value;} } } + + /// Internal Acessors for DeliveryInfoDestination + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestination Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal.DeliveryInfoDestination { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfoInternal)DeliveryInfo).Destination; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfoInternal)DeliveryInfo).Destination = value; } + + /// Internal Acessors for NextRunTimeEstimate + global::System.DateTime? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal.NextRunTimeEstimate { get => this._nextRunTimeEstimate; set { {_nextRunTimeEstimate = value;} } } + + /// Internal Acessors for RunHistory + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionListResult Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal.RunHistory { get => (this._runHistory = this._runHistory ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportExecutionListResult()); set { {_runHistory = value;} } } + + /// Internal Acessors for RunHistoryValue + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution[] Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal.RunHistoryValue { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionListResultInternal)RunHistory).Value; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionListResultInternal)RunHistory).Value = value; } + + /// Backing field for property. + private global::System.DateTime? _nextRunTimeEstimate; + + /// + /// If the export has an active schedule, provides an estimate of the next execution time. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public global::System.DateTime? NextRunTimeEstimate { get => this._nextRunTimeEstimate; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionListResult _runHistory; + + /// If requested, has the most recent execution history for the export. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + internal Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionListResult RunHistory { get => (this._runHistory = this._runHistory ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportExecutionListResult()); set => this._runHistory = value; } + + /// A list of export executions. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution[] RunHistoryValue { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionListResultInternal)RunHistory).Value; } + + /// The start date for export data. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public global::System.DateTime TimePeriodFrom { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)Definition).TimePeriodFrom; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)Definition).TimePeriodFrom = value; } + + /// The end date for export data. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public global::System.DateTime TimePeriodTo { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)Definition).TimePeriodTo; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)Definition).TimePeriodTo = value; } + + /// Creates an new instance. + public CommonExportProperties() + { + + } + } + /// The common properties of the export. + public partial interface ICommonExportProperties : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// + /// Array of column names to be included in the export. If not provided then the export will include all available columns. + /// The available columns can vary by customer channel (see examples). + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Array of column names to be included in the export. If not provided then the export will include all available columns. The available columns can vary by customer channel (see examples).", + SerializedName = @"columns", + PossibleTypes = new [] { typeof(string) })] + string[] ConfigurationColumn { get; set; } + /// The granularity of rows in the export. Currently only 'Daily' is supported. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The granularity of rows in the export. Currently only 'Daily' is supported.", + SerializedName = @"granularity", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType? DataSetGranularity { get; set; } + /// + /// The time frame for pulling data for the export. If custom, then a specific time period must be provided. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The time frame for pulling data for the export. If custom, then a specific time period must be provided.", + SerializedName = @"timeframe", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType DefinitionTimeframe { get; set; } + /// + /// The type of the export. Note that 'Usage' is equivalent to 'ActualCost' and is applicable to exports that do not yet provide + /// data for charges or amortization for service reservations. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The type of the export. Note that 'Usage' is equivalent to 'ActualCost' and is applicable to exports that do not yet provide data for charges or amortization for service reservations.", + SerializedName = @"type", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType DefinitionType { get; set; } + /// The name of the container where exports will be uploaded. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The name of the container where exports will be uploaded.", + SerializedName = @"container", + PossibleTypes = new [] { typeof(string) })] + string DestinationContainer { get; set; } + /// The resource id of the storage account where exports will be delivered. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The resource id of the storage account where exports will be delivered.", + SerializedName = @"resourceId", + PossibleTypes = new [] { typeof(string) })] + string DestinationResourceId { get; set; } + /// The name of the directory where exports will be uploaded. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The name of the directory where exports will be uploaded.", + SerializedName = @"rootFolderPath", + PossibleTypes = new [] { typeof(string) })] + string DestinationRootFolderPath { get; set; } + /// The format of the export being delivered. Currently only 'Csv' is supported. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The format of the export being delivered. Currently only 'Csv' is supported.", + SerializedName = @"format", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType? Format { get; set; } + /// + /// If the export has an active schedule, provides an estimate of the next execution time. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"If the export has an active schedule, provides an estimate of the next execution time.", + SerializedName = @"nextRunTimeEstimate", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime? NextRunTimeEstimate { get; } + /// A list of export executions. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"A list of export executions.", + SerializedName = @"value", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution[] RunHistoryValue { get; } + /// The start date for export data. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The start date for export data.", + SerializedName = @"from", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime TimePeriodFrom { get; set; } + /// The end date for export data. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The end date for export data.", + SerializedName = @"to", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime TimePeriodTo { get; set; } + + } + /// The common properties of the export. + public partial interface ICommonExportPropertiesInternal + + { + /// + /// Array of column names to be included in the export. If not provided then the export will include all available columns. + /// The available columns can vary by customer channel (see examples). + /// + string[] ConfigurationColumn { get; set; } + /// The export dataset configuration. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetConfiguration DataSetConfiguration { get; set; } + /// The granularity of rows in the export. Currently only 'Daily' is supported. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType? DataSetGranularity { get; set; } + /// Has the definition for the export. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinition Definition { get; set; } + /// The definition for data in the export. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDataset DefinitionDataSet { get; set; } + /// Has time period for pulling data for the export. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportTimePeriod DefinitionTimePeriod { get; set; } + /// + /// The time frame for pulling data for the export. If custom, then a specific time period must be provided. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType DefinitionTimeframe { get; set; } + /// + /// The type of the export. Note that 'Usage' is equivalent to 'ActualCost' and is applicable to exports that do not yet provide + /// data for charges or amortization for service reservations. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType DefinitionType { get; set; } + /// Has delivery information for the export. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfo DeliveryInfo { get; set; } + /// Has destination for the export being delivered. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestination DeliveryInfoDestination { get; set; } + /// The name of the container where exports will be uploaded. + string DestinationContainer { get; set; } + /// The resource id of the storage account where exports will be delivered. + string DestinationResourceId { get; set; } + /// The name of the directory where exports will be uploaded. + string DestinationRootFolderPath { get; set; } + /// The format of the export being delivered. Currently only 'Csv' is supported. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType? Format { get; set; } + /// + /// If the export has an active schedule, provides an estimate of the next execution time. + /// + global::System.DateTime? NextRunTimeEstimate { get; set; } + /// If requested, has the most recent execution history for the export. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionListResult RunHistory { get; set; } + /// A list of export executions. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution[] RunHistoryValue { get; set; } + /// The start date for export data. + global::System.DateTime TimePeriodFrom { get; set; } + /// The end date for export data. + global::System.DateTime TimePeriodTo { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/CommonExportProperties.json.cs b/src/CostManagement/generated/api/Models/Api20200601/CommonExportProperties.json.cs new file mode 100644 index 000000000000..80c0a91447a4 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/CommonExportProperties.json.cs @@ -0,0 +1,112 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The common properties of the export. + public partial class CommonExportProperties + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal CommonExportProperties(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_definition = If( json?.PropertyT("definition"), out var __jsonDefinition) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDefinition.FromJson(__jsonDefinition) : Definition;} + {_deliveryInfo = If( json?.PropertyT("deliveryInfo"), out var __jsonDeliveryInfo) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDeliveryInfo.FromJson(__jsonDeliveryInfo) : DeliveryInfo;} + {_runHistory = If( json?.PropertyT("runHistory"), out var __jsonRunHistory) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportExecutionListResult.FromJson(__jsonRunHistory) : RunHistory;} + {_format = If( json?.PropertyT("format"), out var __jsonFormat) ? (string)__jsonFormat : (string)Format;} + {_nextRunTimeEstimate = If( json?.PropertyT("nextRunTimeEstimate"), out var __jsonNextRunTimeEstimate) ? global::System.DateTime.TryParse((string)__jsonNextRunTimeEstimate, global::System.Globalization.CultureInfo.InvariantCulture, global::System.Globalization.DateTimeStyles.AdjustToUniversal, out var __jsonNextRunTimeEstimateValue) ? __jsonNextRunTimeEstimateValue : NextRunTimeEstimate : NextRunTimeEstimate;} + AfterFromJson(json); + } + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportProperties. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportProperties. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportProperties FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new CommonExportProperties(json) : null; + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + AddIf( null != this._definition ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._definition.ToJson(null,serializationMode) : null, "definition" ,container.Add ); + AddIf( null != this._deliveryInfo ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._deliveryInfo.ToJson(null,serializationMode) : null, "deliveryInfo" ,container.Add ); + AddIf( null != this._runHistory ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._runHistory.ToJson(null,serializationMode) : null, "runHistory" ,container.Add ); + AddIf( null != (((object)this._format)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._format.ToString()) : null, "format" ,container.Add ); + if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeReadOnly)) + { + AddIf( null != this._nextRunTimeEstimate ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._nextRunTimeEstimate?.ToString(@"yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK",global::System.Globalization.CultureInfo.InvariantCulture)) : null, "nextRunTimeEstimate" ,container.Add ); + } + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/Dimension.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/Dimension.PowerShell.cs new file mode 100644 index 000000000000..153666be3c1b --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/Dimension.PowerShell.cs @@ -0,0 +1,155 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + [System.ComponentModel.TypeConverter(typeof(DimensionTypeConverter))] + public partial class Dimension + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimension DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new Dimension(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimension DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new Dimension(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal Dimension(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionInternal)this).Property = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionProperties) content.GetValueForProperty("Property",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionInternal)this).Property, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.DimensionPropertiesTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Name, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Type = (string) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Type, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Id = (string) content.GetValueForProperty("Id",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Id, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Tag = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceTags) content.GetValueForProperty("Tag",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Tag, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ResourceTagsTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionInternal)this).Description = (string) content.GetValueForProperty("Description",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionInternal)this).Description, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionInternal)this).Category = (string) content.GetValueForProperty("Category",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionInternal)this).Category, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionInternal)this).Data = (string[]) content.GetValueForProperty("Data",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionInternal)this).Data, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionInternal)this).FilterEnabled = (bool?) content.GetValueForProperty("FilterEnabled",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionInternal)this).FilterEnabled, (__y)=> (bool) global::System.Convert.ChangeType(__y, typeof(bool))); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionInternal)this).GroupingEnabled = (bool?) content.GetValueForProperty("GroupingEnabled",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionInternal)this).GroupingEnabled, (__y)=> (bool) global::System.Convert.ChangeType(__y, typeof(bool))); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionInternal)this).NextLink = (string) content.GetValueForProperty("NextLink",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionInternal)this).NextLink, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionInternal)this).Total = (int?) content.GetValueForProperty("Total",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionInternal)this).Total, (__y)=> (int) global::System.Convert.ChangeType(__y, typeof(int))); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionInternal)this).UsageEnd = (global::System.DateTime?) content.GetValueForProperty("UsageEnd",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionInternal)this).UsageEnd, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionInternal)this).UsageStart = (global::System.DateTime?) content.GetValueForProperty("UsageStart",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionInternal)this).UsageStart, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal Dimension(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionInternal)this).Property = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionProperties) content.GetValueForProperty("Property",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionInternal)this).Property, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.DimensionPropertiesTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Name, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Type = (string) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Type, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Id = (string) content.GetValueForProperty("Id",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Id, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Tag = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceTags) content.GetValueForProperty("Tag",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Tag, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ResourceTagsTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionInternal)this).Description = (string) content.GetValueForProperty("Description",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionInternal)this).Description, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionInternal)this).Category = (string) content.GetValueForProperty("Category",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionInternal)this).Category, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionInternal)this).Data = (string[]) content.GetValueForProperty("Data",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionInternal)this).Data, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionInternal)this).FilterEnabled = (bool?) content.GetValueForProperty("FilterEnabled",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionInternal)this).FilterEnabled, (__y)=> (bool) global::System.Convert.ChangeType(__y, typeof(bool))); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionInternal)this).GroupingEnabled = (bool?) content.GetValueForProperty("GroupingEnabled",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionInternal)this).GroupingEnabled, (__y)=> (bool) global::System.Convert.ChangeType(__y, typeof(bool))); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionInternal)this).NextLink = (string) content.GetValueForProperty("NextLink",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionInternal)this).NextLink, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionInternal)this).Total = (int?) content.GetValueForProperty("Total",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionInternal)this).Total, (__y)=> (int) global::System.Convert.ChangeType(__y, typeof(int))); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionInternal)this).UsageEnd = (global::System.DateTime?) content.GetValueForProperty("UsageEnd",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionInternal)this).UsageEnd, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionInternal)this).UsageStart = (global::System.DateTime?) content.GetValueForProperty("UsageStart",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionInternal)this).UsageStart, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + AfterDeserializePSObject(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimension FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + [System.ComponentModel.TypeConverter(typeof(DimensionTypeConverter))] + public partial interface IDimension + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/Dimension.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/Dimension.TypeConverter.cs new file mode 100644 index 000000000000..48aef6ddfd80 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/Dimension.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class DimensionTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimension ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimension).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return Dimension.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return Dimension.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return Dimension.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/Dimension.cs b/src/CostManagement/generated/api/Models/Api20200601/Dimension.cs new file mode 100644 index 000000000000..4e1b8aef0b66 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/Dimension.cs @@ -0,0 +1,234 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + public partial class Dimension : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimension, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionInternal, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IValidates + { + /// + /// Backing field for Inherited model + /// + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResource __resource = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.Resource(); + + /// Dimension category. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string Category { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)Property).Category; } + + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string[] Data { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)Property).Data; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)Property).Data = value; } + + /// Dimension description. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string Description { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)Property).Description; } + + /// Filter enabled. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public bool? FilterEnabled { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)Property).FilterEnabled; } + + /// Grouping enabled. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public bool? GroupingEnabled { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)Property).GroupingEnabled; } + + /// Resource Id. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inherited)] + public string Id { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)__resource).Id; } + + /// Internal Acessors for Category + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionInternal.Category { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)Property).Category; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)Property).Category = value; } + + /// Internal Acessors for Description + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionInternal.Description { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)Property).Description; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)Property).Description = value; } + + /// Internal Acessors for FilterEnabled + bool? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionInternal.FilterEnabled { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)Property).FilterEnabled; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)Property).FilterEnabled = value; } + + /// Internal Acessors for GroupingEnabled + bool? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionInternal.GroupingEnabled { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)Property).GroupingEnabled; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)Property).GroupingEnabled = value; } + + /// Internal Acessors for NextLink + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionInternal.NextLink { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)Property).NextLink; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)Property).NextLink = value; } + + /// Internal Acessors for Property + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionProperties Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionInternal.Property { get => (this._property = this._property ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.DimensionProperties()); set { {_property = value;} } } + + /// Internal Acessors for Total + int? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionInternal.Total { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)Property).Total; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)Property).Total = value; } + + /// Internal Acessors for UsageEnd + global::System.DateTime? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionInternal.UsageEnd { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)Property).UsageEnd; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)Property).UsageEnd = value; } + + /// Internal Acessors for UsageStart + global::System.DateTime? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionInternal.UsageStart { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)Property).UsageStart; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)Property).UsageStart = value; } + + /// Internal Acessors for Id + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal.Id { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)__resource).Id; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)__resource).Id = value; } + + /// Internal Acessors for Name + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal.Name { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)__resource).Name; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)__resource).Name = value; } + + /// Internal Acessors for Tag + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceTags Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal.Tag { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)__resource).Tag; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)__resource).Tag = value; } + + /// Internal Acessors for Type + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal.Type { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)__resource).Type; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)__resource).Type = value; } + + /// Resource name. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inherited)] + public string Name { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)__resource).Name; } + + /// The link (url) to the next page of results. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string NextLink { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)Property).NextLink; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionProperties _property; + + /// Dimension properties + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + internal Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionProperties Property { get => (this._property = this._property ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.DimensionProperties()); set => this._property = value; } + + /// Resource tags. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inherited)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceTags Tag { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)__resource).Tag; } + + /// Total number of data for the dimension. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public int? Total { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)Property).Total; } + + /// Resource type. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inherited)] + public string Type { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)__resource).Type; } + + /// Usage end. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public global::System.DateTime? UsageEnd { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)Property).UsageEnd; } + + /// Usage start. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public global::System.DateTime? UsageStart { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)Property).UsageStart; } + + /// Creates an new instance. + public Dimension() + { + + } + + /// Validates that this object meets the validation criteria. + /// an instance that will receive validation + /// events. + /// + /// A < see cref = "global::System.Threading.Tasks.Task" /> that will be complete when validation is completed. + /// + public async global::System.Threading.Tasks.Task Validate(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener) + { + await eventListener.AssertNotNull(nameof(__resource), __resource); + await eventListener.AssertObjectIsValid(nameof(__resource), __resource); + } + } + public partial interface IDimension : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResource + { + /// Dimension category. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"Dimension category.", + SerializedName = @"category", + PossibleTypes = new [] { typeof(string) })] + string Category { get; } + + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"", + SerializedName = @"data", + PossibleTypes = new [] { typeof(string) })] + string[] Data { get; set; } + /// Dimension description. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"Dimension description.", + SerializedName = @"description", + PossibleTypes = new [] { typeof(string) })] + string Description { get; } + /// Filter enabled. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"Filter enabled.", + SerializedName = @"filterEnabled", + PossibleTypes = new [] { typeof(bool) })] + bool? FilterEnabled { get; } + /// Grouping enabled. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"Grouping enabled.", + SerializedName = @"groupingEnabled", + PossibleTypes = new [] { typeof(bool) })] + bool? GroupingEnabled { get; } + /// The link (url) to the next page of results. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"The link (url) to the next page of results.", + SerializedName = @"nextLink", + PossibleTypes = new [] { typeof(string) })] + string NextLink { get; } + /// Total number of data for the dimension. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"Total number of data for the dimension.", + SerializedName = @"total", + PossibleTypes = new [] { typeof(int) })] + int? Total { get; } + /// Usage end. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"Usage end.", + SerializedName = @"usageEnd", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime? UsageEnd { get; } + /// Usage start. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"Usage start.", + SerializedName = @"usageStart", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime? UsageStart { get; } + + } + public partial interface IDimensionInternal : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal + { + /// Dimension category. + string Category { get; set; } + + string[] Data { get; set; } + /// Dimension description. + string Description { get; set; } + /// Filter enabled. + bool? FilterEnabled { get; set; } + /// Grouping enabled. + bool? GroupingEnabled { get; set; } + /// The link (url) to the next page of results. + string NextLink { get; set; } + /// Dimension properties + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionProperties Property { get; set; } + /// Total number of data for the dimension. + int? Total { get; set; } + /// Usage end. + global::System.DateTime? UsageEnd { get; set; } + /// Usage start. + global::System.DateTime? UsageStart { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/Dimension.json.cs b/src/CostManagement/generated/api/Models/Api20200601/Dimension.json.cs new file mode 100644 index 000000000000..cf4e5d3a6118 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/Dimension.json.cs @@ -0,0 +1,102 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + public partial class Dimension + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal Dimension(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + __resource = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.Resource(json); + {_property = If( json?.PropertyT("properties"), out var __jsonProperties) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.DimensionProperties.FromJson(__jsonProperties) : Property;} + AfterFromJson(json); + } + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimension. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimension. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimension FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new Dimension(json) : null; + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + __resource?.ToJson(container, serializationMode); + AddIf( null != this._property ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._property.ToJson(null,serializationMode) : null, "properties" ,container.Add ); + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/DimensionProperties.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/DimensionProperties.PowerShell.cs new file mode 100644 index 000000000000..88181c9ae8da --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/DimensionProperties.PowerShell.cs @@ -0,0 +1,145 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + [System.ComponentModel.TypeConverter(typeof(DimensionPropertiesTypeConverter))] + public partial class DimensionProperties + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionProperties DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new DimensionProperties(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionProperties DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new DimensionProperties(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal DimensionProperties(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)this).Description = (string) content.GetValueForProperty("Description",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)this).Description, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)this).Category = (string) content.GetValueForProperty("Category",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)this).Category, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)this).Data = (string[]) content.GetValueForProperty("Data",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)this).Data, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)this).FilterEnabled = (bool?) content.GetValueForProperty("FilterEnabled",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)this).FilterEnabled, (__y)=> (bool) global::System.Convert.ChangeType(__y, typeof(bool))); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)this).GroupingEnabled = (bool?) content.GetValueForProperty("GroupingEnabled",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)this).GroupingEnabled, (__y)=> (bool) global::System.Convert.ChangeType(__y, typeof(bool))); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)this).NextLink = (string) content.GetValueForProperty("NextLink",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)this).NextLink, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)this).Total = (int?) content.GetValueForProperty("Total",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)this).Total, (__y)=> (int) global::System.Convert.ChangeType(__y, typeof(int))); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)this).UsageEnd = (global::System.DateTime?) content.GetValueForProperty("UsageEnd",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)this).UsageEnd, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)this).UsageStart = (global::System.DateTime?) content.GetValueForProperty("UsageStart",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)this).UsageStart, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal DimensionProperties(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)this).Description = (string) content.GetValueForProperty("Description",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)this).Description, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)this).Category = (string) content.GetValueForProperty("Category",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)this).Category, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)this).Data = (string[]) content.GetValueForProperty("Data",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)this).Data, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)this).FilterEnabled = (bool?) content.GetValueForProperty("FilterEnabled",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)this).FilterEnabled, (__y)=> (bool) global::System.Convert.ChangeType(__y, typeof(bool))); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)this).GroupingEnabled = (bool?) content.GetValueForProperty("GroupingEnabled",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)this).GroupingEnabled, (__y)=> (bool) global::System.Convert.ChangeType(__y, typeof(bool))); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)this).NextLink = (string) content.GetValueForProperty("NextLink",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)this).NextLink, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)this).Total = (int?) content.GetValueForProperty("Total",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)this).Total, (__y)=> (int) global::System.Convert.ChangeType(__y, typeof(int))); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)this).UsageEnd = (global::System.DateTime?) content.GetValueForProperty("UsageEnd",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)this).UsageEnd, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)this).UsageStart = (global::System.DateTime?) content.GetValueForProperty("UsageStart",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal)this).UsageStart, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + AfterDeserializePSObject(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionProperties FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + [System.ComponentModel.TypeConverter(typeof(DimensionPropertiesTypeConverter))] + public partial interface IDimensionProperties + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/DimensionProperties.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/DimensionProperties.TypeConverter.cs new file mode 100644 index 000000000000..9a43ea118bbc --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/DimensionProperties.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class DimensionPropertiesTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionProperties ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionProperties).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return DimensionProperties.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return DimensionProperties.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return DimensionProperties.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/DimensionProperties.cs b/src/CostManagement/generated/api/Models/Api20200601/DimensionProperties.cs new file mode 100644 index 000000000000..dbb60b8ca09d --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/DimensionProperties.cs @@ -0,0 +1,202 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + public partial class DimensionProperties : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionProperties, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal + { + + /// Backing field for property. + private string _category; + + /// Dimension category. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string Category { get => this._category; } + + /// Backing field for property. + private string[] _data; + + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string[] Data { get => this._data; set => this._data = value; } + + /// Backing field for property. + private string _description; + + /// Dimension description. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string Description { get => this._description; } + + /// Backing field for property. + private bool? _filterEnabled; + + /// Filter enabled. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public bool? FilterEnabled { get => this._filterEnabled; } + + /// Backing field for property. + private bool? _groupingEnabled; + + /// Grouping enabled. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public bool? GroupingEnabled { get => this._groupingEnabled; } + + /// Internal Acessors for Category + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal.Category { get => this._category; set { {_category = value;} } } + + /// Internal Acessors for Description + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal.Description { get => this._description; set { {_description = value;} } } + + /// Internal Acessors for FilterEnabled + bool? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal.FilterEnabled { get => this._filterEnabled; set { {_filterEnabled = value;} } } + + /// Internal Acessors for GroupingEnabled + bool? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal.GroupingEnabled { get => this._groupingEnabled; set { {_groupingEnabled = value;} } } + + /// Internal Acessors for NextLink + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal.NextLink { get => this._nextLink; set { {_nextLink = value;} } } + + /// Internal Acessors for Total + int? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal.Total { get => this._total; set { {_total = value;} } } + + /// Internal Acessors for UsageEnd + global::System.DateTime? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal.UsageEnd { get => this._usageEnd; set { {_usageEnd = value;} } } + + /// Internal Acessors for UsageStart + global::System.DateTime? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionPropertiesInternal.UsageStart { get => this._usageStart; set { {_usageStart = value;} } } + + /// Backing field for property. + private string _nextLink; + + /// The link (url) to the next page of results. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string NextLink { get => this._nextLink; } + + /// Backing field for property. + private int? _total; + + /// Total number of data for the dimension. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public int? Total { get => this._total; } + + /// Backing field for property. + private global::System.DateTime? _usageEnd; + + /// Usage end. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public global::System.DateTime? UsageEnd { get => this._usageEnd; } + + /// Backing field for property. + private global::System.DateTime? _usageStart; + + /// Usage start. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public global::System.DateTime? UsageStart { get => this._usageStart; } + + /// Creates an new instance. + public DimensionProperties() + { + + } + } + public partial interface IDimensionProperties : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// Dimension category. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"Dimension category.", + SerializedName = @"category", + PossibleTypes = new [] { typeof(string) })] + string Category { get; } + + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"", + SerializedName = @"data", + PossibleTypes = new [] { typeof(string) })] + string[] Data { get; set; } + /// Dimension description. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"Dimension description.", + SerializedName = @"description", + PossibleTypes = new [] { typeof(string) })] + string Description { get; } + /// Filter enabled. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"Filter enabled.", + SerializedName = @"filterEnabled", + PossibleTypes = new [] { typeof(bool) })] + bool? FilterEnabled { get; } + /// Grouping enabled. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"Grouping enabled.", + SerializedName = @"groupingEnabled", + PossibleTypes = new [] { typeof(bool) })] + bool? GroupingEnabled { get; } + /// The link (url) to the next page of results. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"The link (url) to the next page of results.", + SerializedName = @"nextLink", + PossibleTypes = new [] { typeof(string) })] + string NextLink { get; } + /// Total number of data for the dimension. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"Total number of data for the dimension.", + SerializedName = @"total", + PossibleTypes = new [] { typeof(int) })] + int? Total { get; } + /// Usage end. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"Usage end.", + SerializedName = @"usageEnd", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime? UsageEnd { get; } + /// Usage start. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"Usage start.", + SerializedName = @"usageStart", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime? UsageStart { get; } + + } + public partial interface IDimensionPropertiesInternal + + { + /// Dimension category. + string Category { get; set; } + + string[] Data { get; set; } + /// Dimension description. + string Description { get; set; } + /// Filter enabled. + bool? FilterEnabled { get; set; } + /// Grouping enabled. + bool? GroupingEnabled { get; set; } + /// The link (url) to the next page of results. + string NextLink { get; set; } + /// Total number of data for the dimension. + int? Total { get; set; } + /// Usage end. + global::System.DateTime? UsageEnd { get; set; } + /// Usage start. + global::System.DateTime? UsageStart { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/DimensionProperties.json.cs b/src/CostManagement/generated/api/Models/Api20200601/DimensionProperties.json.cs new file mode 100644 index 000000000000..c9bb49215bcb --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/DimensionProperties.json.cs @@ -0,0 +1,148 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + public partial class DimensionProperties + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal DimensionProperties(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_description = If( json?.PropertyT("description"), out var __jsonDescription) ? (string)__jsonDescription : (string)Description;} + {_category = If( json?.PropertyT("category"), out var __jsonCategory) ? (string)__jsonCategory : (string)Category;} + {_data = If( json?.PropertyT("data"), out var __jsonData) ? If( __jsonData as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonArray, out var __v) ? new global::System.Func(()=> global::System.Linq.Enumerable.ToArray(global::System.Linq.Enumerable.Select(__v, (__u)=>(string) (__u is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString __t ? (string)(__t.ToString()) : null)) ))() : null : Data;} + {_filterEnabled = If( json?.PropertyT("filterEnabled"), out var __jsonFilterEnabled) ? (bool?)__jsonFilterEnabled : FilterEnabled;} + {_groupingEnabled = If( json?.PropertyT("groupingEnabled"), out var __jsonGroupingEnabled) ? (bool?)__jsonGroupingEnabled : GroupingEnabled;} + {_nextLink = If( json?.PropertyT("nextLink"), out var __jsonNextLink) ? (string)__jsonNextLink : (string)NextLink;} + {_total = If( json?.PropertyT("total"), out var __jsonTotal) ? (int?)__jsonTotal : Total;} + {_usageEnd = If( json?.PropertyT("usageEnd"), out var __jsonUsageEnd) ? global::System.DateTime.TryParse((string)__jsonUsageEnd, global::System.Globalization.CultureInfo.InvariantCulture, global::System.Globalization.DateTimeStyles.AdjustToUniversal, out var __jsonUsageEndValue) ? __jsonUsageEndValue : UsageEnd : UsageEnd;} + {_usageStart = If( json?.PropertyT("usageStart"), out var __jsonUsageStart) ? global::System.DateTime.TryParse((string)__jsonUsageStart, global::System.Globalization.CultureInfo.InvariantCulture, global::System.Globalization.DateTimeStyles.AdjustToUniversal, out var __jsonUsageStartValue) ? __jsonUsageStartValue : UsageStart : UsageStart;} + AfterFromJson(json); + } + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionProperties. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionProperties. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionProperties FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new DimensionProperties(json) : null; + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeReadOnly)) + { + AddIf( null != (((object)this._description)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._description.ToString()) : null, "description" ,container.Add ); + } + if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeReadOnly)) + { + AddIf( null != (((object)this._category)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._category.ToString()) : null, "category" ,container.Add ); + } + if (null != this._data) + { + var __w = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.XNodeArray(); + foreach( var __x in this._data ) + { + AddIf(null != (((object)__x)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(__x.ToString()) : null ,__w.Add); + } + container.Add("data",__w); + } + if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeReadOnly)) + { + AddIf( null != this._filterEnabled ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode)new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonBoolean((bool)this._filterEnabled) : null, "filterEnabled" ,container.Add ); + } + if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeReadOnly)) + { + AddIf( null != this._groupingEnabled ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode)new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonBoolean((bool)this._groupingEnabled) : null, "groupingEnabled" ,container.Add ); + } + if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeReadOnly)) + { + AddIf( null != (((object)this._nextLink)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._nextLink.ToString()) : null, "nextLink" ,container.Add ); + } + if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeReadOnly)) + { + AddIf( null != this._total ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode)new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNumber((int)this._total) : null, "total" ,container.Add ); + } + if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeReadOnly)) + { + AddIf( null != this._usageEnd ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._usageEnd?.ToString(@"yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK",global::System.Globalization.CultureInfo.InvariantCulture)) : null, "usageEnd" ,container.Add ); + } + if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeReadOnly)) + { + AddIf( null != this._usageStart ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._usageStart?.ToString(@"yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK",global::System.Globalization.CultureInfo.InvariantCulture)) : null, "usageStart" ,container.Add ); + } + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/DimensionsListResult.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/DimensionsListResult.PowerShell.cs new file mode 100644 index 000000000000..87ee216e2a10 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/DimensionsListResult.PowerShell.cs @@ -0,0 +1,133 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// Result of listing dimensions. It contains a list of available dimensions. + [System.ComponentModel.TypeConverter(typeof(DimensionsListResultTypeConverter))] + public partial class DimensionsListResult + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionsListResult DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new DimensionsListResult(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionsListResult DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new DimensionsListResult(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal DimensionsListResult(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionsListResultInternal)this).Value = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimension[]) content.GetValueForProperty("Value",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionsListResultInternal)this).Value, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.DimensionTypeConverter.ConvertFrom)); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal DimensionsListResult(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionsListResultInternal)this).Value = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimension[]) content.GetValueForProperty("Value",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionsListResultInternal)this).Value, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.DimensionTypeConverter.ConvertFrom)); + AfterDeserializePSObject(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionsListResult FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// Result of listing dimensions. It contains a list of available dimensions. + [System.ComponentModel.TypeConverter(typeof(DimensionsListResultTypeConverter))] + public partial interface IDimensionsListResult + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/DimensionsListResult.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/DimensionsListResult.TypeConverter.cs new file mode 100644 index 000000000000..3bffa6d709fa --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/DimensionsListResult.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class DimensionsListResultTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionsListResult ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionsListResult).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return DimensionsListResult.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return DimensionsListResult.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return DimensionsListResult.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/DimensionsListResult.cs b/src/CostManagement/generated/api/Models/Api20200601/DimensionsListResult.cs new file mode 100644 index 000000000000..f4b7f94012af --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/DimensionsListResult.cs @@ -0,0 +1,49 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// Result of listing dimensions. It contains a list of available dimensions. + public partial class DimensionsListResult : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionsListResult, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionsListResultInternal + { + + /// Internal Acessors for Value + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimension[] Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionsListResultInternal.Value { get => this._value; set { {_value = value;} } } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimension[] _value; + + /// The list of dimensions. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimension[] Value { get => this._value; } + + /// Creates an new instance. + public DimensionsListResult() + { + + } + } + /// Result of listing dimensions. It contains a list of available dimensions. + public partial interface IDimensionsListResult : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// The list of dimensions. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"The list of dimensions.", + SerializedName = @"value", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimension) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimension[] Value { get; } + + } + /// Result of listing dimensions. It contains a list of available dimensions. + public partial interface IDimensionsListResultInternal + + { + /// The list of dimensions. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimension[] Value { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/DimensionsListResult.json.cs b/src/CostManagement/generated/api/Models/Api20200601/DimensionsListResult.json.cs new file mode 100644 index 000000000000..eeea5e870f55 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/DimensionsListResult.json.cs @@ -0,0 +1,112 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// Result of listing dimensions. It contains a list of available dimensions. + public partial class DimensionsListResult + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal DimensionsListResult(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_value = If( json?.PropertyT("value"), out var __jsonValue) ? If( __jsonValue as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonArray, out var __v) ? new global::System.Func(()=> global::System.Linq.Enumerable.ToArray(global::System.Linq.Enumerable.Select(__v, (__u)=>(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimension) (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.Dimension.FromJson(__u) )) ))() : null : Value;} + AfterFromJson(json); + } + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionsListResult. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionsListResult. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDimensionsListResult FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new DimensionsListResult(json) : null; + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeReadOnly)) + { + if (null != this._value) + { + var __w = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.XNodeArray(); + foreach( var __x in this._value ) + { + AddIf(__x?.ToJson(null, serializationMode) ,__w.Add); + } + container.Add("value",__w); + } + } + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/DismissAlertPayload.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/DismissAlertPayload.PowerShell.cs new file mode 100644 index 000000000000..c7bb34fffcd6 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/DismissAlertPayload.PowerShell.cs @@ -0,0 +1,191 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// The request payload to update an alert + [System.ComponentModel.TypeConverter(typeof(DismissAlertPayloadTypeConverter))] + public partial class DismissAlertPayload + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayload DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new DismissAlertPayload(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayload DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new DismissAlertPayload(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal DismissAlertPayload(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).Property = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertProperties) content.GetValueForProperty("Property",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).Property, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.AlertPropertiesTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).ModificationTime = (string) content.GetValueForProperty("ModificationTime",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).ModificationTime, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).Definition = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDefinition) content.GetValueForProperty("Definition",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).Definition, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.AlertPropertiesDefinitionTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).CloseTime = (string) content.GetValueForProperty("CloseTime",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).CloseTime, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).CostEntityId = (string) content.GetValueForProperty("CostEntityId",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).CostEntityId, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).CreationTime = (string) content.GetValueForProperty("CreationTime",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).CreationTime, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).Description = (string) content.GetValueForProperty("Description",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).Description, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).Source = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertSource?) content.GetValueForProperty("Source",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).Source, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertSource.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).Status = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertStatus?) content.GetValueForProperty("Status",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).Status, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertStatus.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).StatusModificationTime = (string) content.GetValueForProperty("StatusModificationTime",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).StatusModificationTime, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).StatusModificationUserName = (string) content.GetValueForProperty("StatusModificationUserName",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).StatusModificationUserName, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).Detail = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetails) content.GetValueForProperty("Detail",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).Detail, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.AlertPropertiesDetailsTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailOperator = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertOperator?) content.GetValueForProperty("DetailOperator",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailOperator, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertOperator.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DefinitionType = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertType?) content.GetValueForProperty("DefinitionType",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DefinitionType, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DefinitionCriterion = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria?) content.GetValueForProperty("DefinitionCriterion",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DefinitionCriterion, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailAmount = (decimal?) content.GetValueForProperty("DetailAmount",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailAmount, (__y)=> (decimal) global::System.Convert.ChangeType(__y, typeof(decimal))); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailUnit = (string) content.GetValueForProperty("DetailUnit",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailUnit, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailContactGroup = (string[]) content.GetValueForProperty("DetailContactGroup",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailContactGroup, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailContactRole = (string[]) content.GetValueForProperty("DetailContactRole",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailContactRole, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailCurrentSpend = (decimal?) content.GetValueForProperty("DetailCurrentSpend",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailCurrentSpend, (__y)=> (decimal) global::System.Convert.ChangeType(__y, typeof(decimal))); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailMeterFilter = (string[]) content.GetValueForProperty("DetailMeterFilter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailMeterFilter, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DefinitionCategory = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCategory?) content.GetValueForProperty("DefinitionCategory",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DefinitionCategory, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCategory.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailOverridingAlert = (string) content.GetValueForProperty("DetailOverridingAlert",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailOverridingAlert, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailPeriodStartDate = (string) content.GetValueForProperty("DetailPeriodStartDate",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailPeriodStartDate, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailResourceFilter = (string[]) content.GetValueForProperty("DetailResourceFilter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailResourceFilter, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailResourceGroupFilter = (string[]) content.GetValueForProperty("DetailResourceGroupFilter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailResourceGroupFilter, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailTagFilter = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsTagFilter) content.GetValueForProperty("DetailTagFilter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailTagFilter, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.AlertPropertiesDetailsTagFilterTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailThreshold = (decimal?) content.GetValueForProperty("DetailThreshold",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailThreshold, (__y)=> (decimal) global::System.Convert.ChangeType(__y, typeof(decimal))); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailTimeGrainType = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertTimeGrainType?) content.GetValueForProperty("DetailTimeGrainType",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailTimeGrainType, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertTimeGrainType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailTriggeredBy = (string) content.GetValueForProperty("DetailTriggeredBy",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailTriggeredBy, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailContactEmail = (string[]) content.GetValueForProperty("DetailContactEmail",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailContactEmail, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal DismissAlertPayload(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).Property = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertProperties) content.GetValueForProperty("Property",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).Property, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.AlertPropertiesTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).ModificationTime = (string) content.GetValueForProperty("ModificationTime",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).ModificationTime, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).Definition = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDefinition) content.GetValueForProperty("Definition",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).Definition, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.AlertPropertiesDefinitionTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).CloseTime = (string) content.GetValueForProperty("CloseTime",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).CloseTime, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).CostEntityId = (string) content.GetValueForProperty("CostEntityId",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).CostEntityId, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).CreationTime = (string) content.GetValueForProperty("CreationTime",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).CreationTime, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).Description = (string) content.GetValueForProperty("Description",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).Description, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).Source = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertSource?) content.GetValueForProperty("Source",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).Source, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertSource.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).Status = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertStatus?) content.GetValueForProperty("Status",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).Status, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertStatus.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).StatusModificationTime = (string) content.GetValueForProperty("StatusModificationTime",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).StatusModificationTime, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).StatusModificationUserName = (string) content.GetValueForProperty("StatusModificationUserName",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).StatusModificationUserName, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).Detail = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetails) content.GetValueForProperty("Detail",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).Detail, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.AlertPropertiesDetailsTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailOperator = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertOperator?) content.GetValueForProperty("DetailOperator",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailOperator, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertOperator.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DefinitionType = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertType?) content.GetValueForProperty("DefinitionType",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DefinitionType, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DefinitionCriterion = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria?) content.GetValueForProperty("DefinitionCriterion",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DefinitionCriterion, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailAmount = (decimal?) content.GetValueForProperty("DetailAmount",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailAmount, (__y)=> (decimal) global::System.Convert.ChangeType(__y, typeof(decimal))); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailUnit = (string) content.GetValueForProperty("DetailUnit",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailUnit, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailContactGroup = (string[]) content.GetValueForProperty("DetailContactGroup",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailContactGroup, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailContactRole = (string[]) content.GetValueForProperty("DetailContactRole",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailContactRole, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailCurrentSpend = (decimal?) content.GetValueForProperty("DetailCurrentSpend",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailCurrentSpend, (__y)=> (decimal) global::System.Convert.ChangeType(__y, typeof(decimal))); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailMeterFilter = (string[]) content.GetValueForProperty("DetailMeterFilter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailMeterFilter, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DefinitionCategory = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCategory?) content.GetValueForProperty("DefinitionCategory",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DefinitionCategory, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCategory.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailOverridingAlert = (string) content.GetValueForProperty("DetailOverridingAlert",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailOverridingAlert, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailPeriodStartDate = (string) content.GetValueForProperty("DetailPeriodStartDate",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailPeriodStartDate, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailResourceFilter = (string[]) content.GetValueForProperty("DetailResourceFilter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailResourceFilter, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailResourceGroupFilter = (string[]) content.GetValueForProperty("DetailResourceGroupFilter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailResourceGroupFilter, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailTagFilter = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsTagFilter) content.GetValueForProperty("DetailTagFilter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailTagFilter, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.AlertPropertiesDetailsTagFilterTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailThreshold = (decimal?) content.GetValueForProperty("DetailThreshold",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailThreshold, (__y)=> (decimal) global::System.Convert.ChangeType(__y, typeof(decimal))); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailTimeGrainType = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertTimeGrainType?) content.GetValueForProperty("DetailTimeGrainType",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailTimeGrainType, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertTimeGrainType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailTriggeredBy = (string) content.GetValueForProperty("DetailTriggeredBy",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailTriggeredBy, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailContactEmail = (string[]) content.GetValueForProperty("DetailContactEmail",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal)this).DetailContactEmail, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + AfterDeserializePSObject(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayload FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// The request payload to update an alert + [System.ComponentModel.TypeConverter(typeof(DismissAlertPayloadTypeConverter))] + public partial interface IDismissAlertPayload + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/DismissAlertPayload.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/DismissAlertPayload.TypeConverter.cs new file mode 100644 index 000000000000..a1c70f53f144 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/DismissAlertPayload.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class DismissAlertPayloadTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayload ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayload).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return DismissAlertPayload.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return DismissAlertPayload.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return DismissAlertPayload.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/DismissAlertPayload.cs b/src/CostManagement/generated/api/Models/Api20200601/DismissAlertPayload.cs new file mode 100644 index 000000000000..e70f8d8dac09 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/DismissAlertPayload.cs @@ -0,0 +1,442 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The request payload to update an alert + public partial class DismissAlertPayload : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayload, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal + { + + /// dateTime in which alert was closed + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string CloseTime { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).CloseTime; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).CloseTime = value; } + + /// related budget + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string CostEntityId { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).CostEntityId; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).CostEntityId = value; } + + /// dateTime in which alert was created + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string CreationTime { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).CreationTime; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).CreationTime = value; } + + /// Alert category + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCategory? DefinitionCategory { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DefinitionCategory; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DefinitionCategory = value; } + + /// Criteria that triggered alert + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria? DefinitionCriterion { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DefinitionCriterion; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DefinitionCriterion = value; } + + /// type of alert + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertType? DefinitionType { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DefinitionType; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DefinitionType = value; } + + /// Alert description + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string Description { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).Description; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).Description = value; } + + /// budget threshold amount + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public decimal? DetailAmount { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailAmount; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailAmount = value; } + + /// list of emails to contact + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string[] DetailContactEmail { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailContactEmail; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailContactEmail = value; } + + /// list of action groups to broadcast to + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string[] DetailContactGroup { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailContactGroup; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailContactGroup = value; } + + /// list of contact roles + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string[] DetailContactRole { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailContactRole; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailContactRole = value; } + + /// current spend + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public decimal? DetailCurrentSpend { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailCurrentSpend; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailCurrentSpend = value; } + + /// array of meters to filter by + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string[] DetailMeterFilter { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailMeterFilter; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailMeterFilter = value; } + + /// operator used to compare currentSpend with amount + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertOperator? DetailOperator { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailOperator; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailOperator = value; } + + /// overriding alert + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string DetailOverridingAlert { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailOverridingAlert; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailOverridingAlert = value; } + + /// datetime of periodStartDate + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string DetailPeriodStartDate { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailPeriodStartDate; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailPeriodStartDate = value; } + + /// array of resources to filter by + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string[] DetailResourceFilter { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailResourceFilter; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailResourceFilter = value; } + + /// array of resourceGroups to filter by + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string[] DetailResourceGroupFilter { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailResourceGroupFilter; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailResourceGroupFilter = value; } + + /// tags to filter by + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsTagFilter DetailTagFilter { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailTagFilter; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailTagFilter = value; } + + /// notification threshold percentage as a decimal which activated this alert + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public decimal? DetailThreshold { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailThreshold; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailThreshold = value; } + + /// Type of timegrain cadence + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertTimeGrainType? DetailTimeGrainType { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailTimeGrainType; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailTimeGrainType = value; } + + /// notificationId that triggered this alert + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string DetailTriggeredBy { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailTriggeredBy; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailTriggeredBy = value; } + + /// unit of currency being used + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string DetailUnit { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailUnit; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).DetailUnit = value; } + + /// Internal Acessors for Definition + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDefinition Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal.Definition { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).Definition; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).Definition = value; } + + /// Internal Acessors for Detail + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetails Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal.Detail { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).Detail; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).Detail = value; } + + /// Internal Acessors for Property + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertProperties Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayloadInternal.Property { get => (this._property = this._property ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.AlertProperties()); set { {_property = value;} } } + + /// dateTime in which alert was last modified + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string ModificationTime { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).ModificationTime; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).ModificationTime = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertProperties _property; + + /// Alert properties + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + internal Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertProperties Property { get => (this._property = this._property ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.AlertProperties()); set => this._property = value; } + + /// Source of alert + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertSource? Source { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).Source; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).Source = value; } + + /// alert status + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertStatus? Status { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).Status; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).Status = value; } + + /// dateTime in which the alert status was last modified + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string StatusModificationTime { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).StatusModificationTime; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).StatusModificationTime = value; } + + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string StatusModificationUserName { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).StatusModificationUserName; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesInternal)Property).StatusModificationUserName = value; } + + /// Creates an new instance. + public DismissAlertPayload() + { + + } + } + /// The request payload to update an alert + public partial interface IDismissAlertPayload : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// dateTime in which alert was closed + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"dateTime in which alert was closed", + SerializedName = @"closeTime", + PossibleTypes = new [] { typeof(string) })] + string CloseTime { get; set; } + /// related budget + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"related budget", + SerializedName = @"costEntityId", + PossibleTypes = new [] { typeof(string) })] + string CostEntityId { get; set; } + /// dateTime in which alert was created + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"dateTime in which alert was created", + SerializedName = @"creationTime", + PossibleTypes = new [] { typeof(string) })] + string CreationTime { get; set; } + /// Alert category + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Alert category", + SerializedName = @"category", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCategory) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCategory? DefinitionCategory { get; set; } + /// Criteria that triggered alert + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Criteria that triggered alert", + SerializedName = @"criteria", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria? DefinitionCriterion { get; set; } + /// type of alert + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"type of alert", + SerializedName = @"type", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertType? DefinitionType { get; set; } + /// Alert description + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Alert description", + SerializedName = @"description", + PossibleTypes = new [] { typeof(string) })] + string Description { get; set; } + /// budget threshold amount + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"budget threshold amount", + SerializedName = @"amount", + PossibleTypes = new [] { typeof(decimal) })] + decimal? DetailAmount { get; set; } + /// list of emails to contact + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"list of emails to contact", + SerializedName = @"contactEmails", + PossibleTypes = new [] { typeof(string) })] + string[] DetailContactEmail { get; set; } + /// list of action groups to broadcast to + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"list of action groups to broadcast to", + SerializedName = @"contactGroups", + PossibleTypes = new [] { typeof(string) })] + string[] DetailContactGroup { get; set; } + /// list of contact roles + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"list of contact roles", + SerializedName = @"contactRoles", + PossibleTypes = new [] { typeof(string) })] + string[] DetailContactRole { get; set; } + /// current spend + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"current spend", + SerializedName = @"currentSpend", + PossibleTypes = new [] { typeof(decimal) })] + decimal? DetailCurrentSpend { get; set; } + /// array of meters to filter by + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"array of meters to filter by", + SerializedName = @"meterFilter", + PossibleTypes = new [] { typeof(string) })] + string[] DetailMeterFilter { get; set; } + /// operator used to compare currentSpend with amount + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"operator used to compare currentSpend with amount", + SerializedName = @"operator", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertOperator) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertOperator? DetailOperator { get; set; } + /// overriding alert + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"overriding alert", + SerializedName = @"overridingAlert", + PossibleTypes = new [] { typeof(string) })] + string DetailOverridingAlert { get; set; } + /// datetime of periodStartDate + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"datetime of periodStartDate", + SerializedName = @"periodStartDate", + PossibleTypes = new [] { typeof(string) })] + string DetailPeriodStartDate { get; set; } + /// array of resources to filter by + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"array of resources to filter by", + SerializedName = @"resourceFilter", + PossibleTypes = new [] { typeof(string) })] + string[] DetailResourceFilter { get; set; } + /// array of resourceGroups to filter by + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"array of resourceGroups to filter by", + SerializedName = @"resourceGroupFilter", + PossibleTypes = new [] { typeof(string) })] + string[] DetailResourceGroupFilter { get; set; } + /// tags to filter by + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"tags to filter by", + SerializedName = @"tagFilter", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsTagFilter) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsTagFilter DetailTagFilter { get; set; } + /// notification threshold percentage as a decimal which activated this alert + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"notification threshold percentage as a decimal which activated this alert", + SerializedName = @"threshold", + PossibleTypes = new [] { typeof(decimal) })] + decimal? DetailThreshold { get; set; } + /// Type of timegrain cadence + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Type of timegrain cadence", + SerializedName = @"timeGrainType", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertTimeGrainType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertTimeGrainType? DetailTimeGrainType { get; set; } + /// notificationId that triggered this alert + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"notificationId that triggered this alert", + SerializedName = @"triggeredBy", + PossibleTypes = new [] { typeof(string) })] + string DetailTriggeredBy { get; set; } + /// unit of currency being used + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"unit of currency being used", + SerializedName = @"unit", + PossibleTypes = new [] { typeof(string) })] + string DetailUnit { get; set; } + /// dateTime in which alert was last modified + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"dateTime in which alert was last modified", + SerializedName = @"modificationTime", + PossibleTypes = new [] { typeof(string) })] + string ModificationTime { get; set; } + /// Source of alert + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Source of alert", + SerializedName = @"source", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertSource) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertSource? Source { get; set; } + /// alert status + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"alert status", + SerializedName = @"status", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertStatus) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertStatus? Status { get; set; } + /// dateTime in which the alert status was last modified + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"dateTime in which the alert status was last modified", + SerializedName = @"statusModificationTime", + PossibleTypes = new [] { typeof(string) })] + string StatusModificationTime { get; set; } + + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"", + SerializedName = @"statusModificationUserName", + PossibleTypes = new [] { typeof(string) })] + string StatusModificationUserName { get; set; } + + } + /// The request payload to update an alert + public partial interface IDismissAlertPayloadInternal + + { + /// dateTime in which alert was closed + string CloseTime { get; set; } + /// related budget + string CostEntityId { get; set; } + /// dateTime in which alert was created + string CreationTime { get; set; } + /// defines the type of alert + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDefinition Definition { get; set; } + /// Alert category + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCategory? DefinitionCategory { get; set; } + /// Criteria that triggered alert + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria? DefinitionCriterion { get; set; } + /// type of alert + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertType? DefinitionType { get; set; } + /// Alert description + string Description { get; set; } + /// Alert details + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetails Detail { get; set; } + /// budget threshold amount + decimal? DetailAmount { get; set; } + /// list of emails to contact + string[] DetailContactEmail { get; set; } + /// list of action groups to broadcast to + string[] DetailContactGroup { get; set; } + /// list of contact roles + string[] DetailContactRole { get; set; } + /// current spend + decimal? DetailCurrentSpend { get; set; } + /// array of meters to filter by + string[] DetailMeterFilter { get; set; } + /// operator used to compare currentSpend with amount + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertOperator? DetailOperator { get; set; } + /// overriding alert + string DetailOverridingAlert { get; set; } + /// datetime of periodStartDate + string DetailPeriodStartDate { get; set; } + /// array of resources to filter by + string[] DetailResourceFilter { get; set; } + /// array of resourceGroups to filter by + string[] DetailResourceGroupFilter { get; set; } + /// tags to filter by + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertPropertiesDetailsTagFilter DetailTagFilter { get; set; } + /// notification threshold percentage as a decimal which activated this alert + decimal? DetailThreshold { get; set; } + /// Type of timegrain cadence + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertTimeGrainType? DetailTimeGrainType { get; set; } + /// notificationId that triggered this alert + string DetailTriggeredBy { get; set; } + /// unit of currency being used + string DetailUnit { get; set; } + /// dateTime in which alert was last modified + string ModificationTime { get; set; } + /// Alert properties + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IAlertProperties Property { get; set; } + /// Source of alert + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertSource? Source { get; set; } + /// alert status + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertStatus? Status { get; set; } + /// dateTime in which the alert status was last modified + string StatusModificationTime { get; set; } + + string StatusModificationUserName { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/DismissAlertPayload.json.cs b/src/CostManagement/generated/api/Models/Api20200601/DismissAlertPayload.json.cs new file mode 100644 index 000000000000..41a2a9d4effb --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/DismissAlertPayload.json.cs @@ -0,0 +1,101 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The request payload to update an alert + public partial class DismissAlertPayload + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal DismissAlertPayload(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_property = If( json?.PropertyT("properties"), out var __jsonProperties) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.AlertProperties.FromJson(__jsonProperties) : Property;} + AfterFromJson(json); + } + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayload. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayload. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IDismissAlertPayload FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new DismissAlertPayload(json) : null; + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + AddIf( null != this._property ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._property.ToJson(null,serializationMode) : null, "properties" ,container.Add ); + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ErrorDetails.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/ErrorDetails.PowerShell.cs new file mode 100644 index 000000000000..24ec77e43de4 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ErrorDetails.PowerShell.cs @@ -0,0 +1,133 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// The details of the error. + [System.ComponentModel.TypeConverter(typeof(ErrorDetailsTypeConverter))] + public partial class ErrorDetails + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorDetails DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new ErrorDetails(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorDetails DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new ErrorDetails(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal ErrorDetails(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorDetailsInternal)this).Code = (string) content.GetValueForProperty("Code",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorDetailsInternal)this).Code, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorDetailsInternal)this).Message = (string) content.GetValueForProperty("Message",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorDetailsInternal)this).Message, global::System.Convert.ToString); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal ErrorDetails(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorDetailsInternal)this).Code = (string) content.GetValueForProperty("Code",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorDetailsInternal)this).Code, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorDetailsInternal)this).Message = (string) content.GetValueForProperty("Message",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorDetailsInternal)this).Message, global::System.Convert.ToString); + AfterDeserializePSObject(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorDetails FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// The details of the error. + [System.ComponentModel.TypeConverter(typeof(ErrorDetailsTypeConverter))] + public partial interface IErrorDetails + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ErrorDetails.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/ErrorDetails.TypeConverter.cs new file mode 100644 index 000000000000..6ee007b96cc2 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ErrorDetails.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class ErrorDetailsTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorDetails ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorDetails).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return ErrorDetails.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return ErrorDetails.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return ErrorDetails.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ErrorDetails.cs b/src/CostManagement/generated/api/Models/Api20200601/ErrorDetails.cs new file mode 100644 index 000000000000..4c21ea3e34ec --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ErrorDetails.cs @@ -0,0 +1,69 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The details of the error. + public partial class ErrorDetails : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorDetails, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorDetailsInternal + { + + /// Backing field for property. + private string _code; + + /// Error code. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string Code { get => this._code; } + + /// Backing field for property. + private string _message; + + /// Error message indicating why the operation failed. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string Message { get => this._message; } + + /// Internal Acessors for Code + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorDetailsInternal.Code { get => this._code; set { {_code = value;} } } + + /// Internal Acessors for Message + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorDetailsInternal.Message { get => this._message; set { {_message = value;} } } + + /// Creates an new instance. + public ErrorDetails() + { + + } + } + /// The details of the error. + public partial interface IErrorDetails : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// Error code. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"Error code.", + SerializedName = @"code", + PossibleTypes = new [] { typeof(string) })] + string Code { get; } + /// Error message indicating why the operation failed. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"Error message indicating why the operation failed.", + SerializedName = @"message", + PossibleTypes = new [] { typeof(string) })] + string Message { get; } + + } + /// The details of the error. + public partial interface IErrorDetailsInternal + + { + /// Error code. + string Code { get; set; } + /// Error message indicating why the operation failed. + string Message { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ErrorDetails.json.cs b/src/CostManagement/generated/api/Models/Api20200601/ErrorDetails.json.cs new file mode 100644 index 000000000000..4053e1aaa1fe --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ErrorDetails.json.cs @@ -0,0 +1,109 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The details of the error. + public partial class ErrorDetails + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal ErrorDetails(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_code = If( json?.PropertyT("code"), out var __jsonCode) ? (string)__jsonCode : (string)Code;} + {_message = If( json?.PropertyT("message"), out var __jsonMessage) ? (string)__jsonMessage : (string)Message;} + AfterFromJson(json); + } + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorDetails. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorDetails. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorDetails FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new ErrorDetails(json) : null; + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeReadOnly)) + { + AddIf( null != (((object)this._code)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._code.ToString()) : null, "code" ,container.Add ); + } + if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeReadOnly)) + { + AddIf( null != (((object)this._message)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._message.ToString()) : null, "message" ,container.Add ); + } + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ErrorResponse.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/ErrorResponse.PowerShell.cs new file mode 100644 index 000000000000..b88fda2468b3 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ErrorResponse.PowerShell.cs @@ -0,0 +1,149 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// Error response indicates that the service is not able to process the incoming request. The reason is provided in the error + /// message. + /// Some Error responses: + /// * 429 TooManyRequests - Request is throttled. Retry after waiting for the time specified in the "x-ms-ratelimit-microsoft.consumption-retry-after" + /// header. + /// * 503 ServiceUnavailable - Service is temporarily unavailable. Retry after waiting for the time specified in the "Retry-After" + /// header. + /// + [System.ComponentModel.TypeConverter(typeof(ErrorResponseTypeConverter))] + public partial class ErrorResponse + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorResponse DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new ErrorResponse(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorResponse DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new ErrorResponse(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal ErrorResponse(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorResponseInternal)this).Error = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorDetails) content.GetValueForProperty("Error",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorResponseInternal)this).Error, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ErrorDetailsTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorResponseInternal)this).Code = (string) content.GetValueForProperty("Code",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorResponseInternal)this).Code, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorResponseInternal)this).Message = (string) content.GetValueForProperty("Message",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorResponseInternal)this).Message, global::System.Convert.ToString); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal ErrorResponse(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorResponseInternal)this).Error = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorDetails) content.GetValueForProperty("Error",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorResponseInternal)this).Error, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ErrorDetailsTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorResponseInternal)this).Code = (string) content.GetValueForProperty("Code",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorResponseInternal)this).Code, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorResponseInternal)this).Message = (string) content.GetValueForProperty("Message",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorResponseInternal)this).Message, global::System.Convert.ToString); + AfterDeserializePSObject(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorResponse FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// Error response indicates that the service is not able to process the incoming request. The reason is provided in the error + /// message. + /// Some Error responses: + /// * 429 TooManyRequests - Request is throttled. Retry after waiting for the time specified in the "x-ms-ratelimit-microsoft.consumption-retry-after" + /// header. + /// * 503 ServiceUnavailable - Service is temporarily unavailable. Retry after waiting for the time specified in the "Retry-After" + /// header. + [System.ComponentModel.TypeConverter(typeof(ErrorResponseTypeConverter))] + public partial interface IErrorResponse + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ErrorResponse.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/ErrorResponse.TypeConverter.cs new file mode 100644 index 000000000000..c244b269b4ee --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ErrorResponse.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class ErrorResponseTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorResponse ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorResponse).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return ErrorResponse.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return ErrorResponse.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return ErrorResponse.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ErrorResponse.cs b/src/CostManagement/generated/api/Models/Api20200601/ErrorResponse.cs new file mode 100644 index 000000000000..07c6617d5722 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ErrorResponse.cs @@ -0,0 +1,95 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// + /// Error response indicates that the service is not able to process the incoming request. The reason is provided in the error + /// message. + /// Some Error responses: + /// * 429 TooManyRequests - Request is throttled. Retry after waiting for the time specified in the "x-ms-ratelimit-microsoft.consumption-retry-after" + /// header. + /// * 503 ServiceUnavailable - Service is temporarily unavailable. Retry after waiting for the time specified in the "Retry-After" + /// header. + /// + public partial class ErrorResponse : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorResponse, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorResponseInternal + { + + /// Error code. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string Code { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorDetailsInternal)Error).Code; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorDetails _error; + + /// The details of the error. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + internal Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorDetails Error { get => (this._error = this._error ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ErrorDetails()); set => this._error = value; } + + /// Error message indicating why the operation failed. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string Message { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorDetailsInternal)Error).Message; } + + /// Internal Acessors for Code + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorResponseInternal.Code { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorDetailsInternal)Error).Code; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorDetailsInternal)Error).Code = value; } + + /// Internal Acessors for Error + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorDetails Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorResponseInternal.Error { get => (this._error = this._error ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ErrorDetails()); set { {_error = value;} } } + + /// Internal Acessors for Message + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorResponseInternal.Message { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorDetailsInternal)Error).Message; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorDetailsInternal)Error).Message = value; } + + /// Creates an new instance. + public ErrorResponse() + { + + } + } + /// Error response indicates that the service is not able to process the incoming request. The reason is provided in the error + /// message. + /// Some Error responses: + /// * 429 TooManyRequests - Request is throttled. Retry after waiting for the time specified in the "x-ms-ratelimit-microsoft.consumption-retry-after" + /// header. + /// * 503 ServiceUnavailable - Service is temporarily unavailable. Retry after waiting for the time specified in the "Retry-After" + /// header. + public partial interface IErrorResponse : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// Error code. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"Error code.", + SerializedName = @"code", + PossibleTypes = new [] { typeof(string) })] + string Code { get; } + /// Error message indicating why the operation failed. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"Error message indicating why the operation failed.", + SerializedName = @"message", + PossibleTypes = new [] { typeof(string) })] + string Message { get; } + + } + /// Error response indicates that the service is not able to process the incoming request. The reason is provided in the error + /// message. + /// Some Error responses: + /// * 429 TooManyRequests - Request is throttled. Retry after waiting for the time specified in the "x-ms-ratelimit-microsoft.consumption-retry-after" + /// header. + /// * 503 ServiceUnavailable - Service is temporarily unavailable. Retry after waiting for the time specified in the "Retry-After" + /// header. + public partial interface IErrorResponseInternal + + { + /// Error code. + string Code { get; set; } + /// The details of the error. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorDetails Error { get; set; } + /// Error message indicating why the operation failed. + string Message { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ErrorResponse.json.cs b/src/CostManagement/generated/api/Models/Api20200601/ErrorResponse.json.cs new file mode 100644 index 000000000000..ae809dfd0941 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ErrorResponse.json.cs @@ -0,0 +1,109 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// + /// Error response indicates that the service is not able to process the incoming request. The reason is provided in the error + /// message. + /// Some Error responses: + /// * 429 TooManyRequests - Request is throttled. Retry after waiting for the time specified in the "x-ms-ratelimit-microsoft.consumption-retry-after" + /// header. + /// * 503 ServiceUnavailable - Service is temporarily unavailable. Retry after waiting for the time specified in the "Retry-After" + /// header. + /// + public partial class ErrorResponse + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal ErrorResponse(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_error = If( json?.PropertyT("error"), out var __jsonError) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ErrorDetails.FromJson(__jsonError) : Error;} + AfterFromJson(json); + } + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorResponse. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorResponse. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorResponse FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new ErrorResponse(json) : null; + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + AddIf( null != this._error ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._error.ToJson(null,serializationMode) : null, "error" ,container.Add ); + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/Export.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/Export.PowerShell.cs new file mode 100644 index 000000000000..8a2aa513ae68 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/Export.PowerShell.cs @@ -0,0 +1,189 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// An export resource. + [System.ComponentModel.TypeConverter(typeof(ExportTypeConverter))] + public partial class Export + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new Export(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new Export(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal Export(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).Property = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportProperties) content.GetValueForProperty("Property",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).Property, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportPropertiesTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)this).Name, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)this).Type = (string) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)this).Type, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)this).ETag = (string) content.GetValueForProperty("ETag",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)this).ETag, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)this).Id = (string) content.GetValueForProperty("Id",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)this).Id, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).DeliveryInfo = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfo) content.GetValueForProperty("DeliveryInfo",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).DeliveryInfo, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDeliveryInfoTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).Definition = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinition) content.GetValueForProperty("Definition",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).Definition, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDefinitionTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).RunHistory = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionListResult) content.GetValueForProperty("RunHistory",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).RunHistory, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportExecutionListResultTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).Format = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType?) content.GetValueForProperty("Format",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).Format, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).NextRunTimeEstimate = (global::System.DateTime?) content.GetValueForProperty("NextRunTimeEstimate",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).NextRunTimeEstimate, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).Schedule = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportSchedule) content.GetValueForProperty("Schedule",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).Schedule, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportScheduleTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).DefinitionDataSet = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDataset) content.GetValueForProperty("DefinitionDataSet",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).DefinitionDataSet, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDatasetTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).DefinitionType = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType) content.GetValueForProperty("DefinitionType",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).DefinitionType, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).DefinitionTimeframe = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType) content.GetValueForProperty("DefinitionTimeframe",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).DefinitionTimeframe, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).DeliveryInfoDestination = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestination) content.GetValueForProperty("DeliveryInfoDestination",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).DeliveryInfoDestination, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDeliveryDestinationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).DefinitionTimePeriod = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportTimePeriod) content.GetValueForProperty("DefinitionTimePeriod",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).DefinitionTimePeriod, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportTimePeriodTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).RunHistoryValue = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution[]) content.GetValueForProperty("RunHistoryValue",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).RunHistoryValue, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportExecutionTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).ScheduleRecurrencePeriod = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportRecurrencePeriod) content.GetValueForProperty("ScheduleRecurrencePeriod",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).ScheduleRecurrencePeriod, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportRecurrencePeriodTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).ScheduleRecurrence = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType) content.GetValueForProperty("ScheduleRecurrence",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).ScheduleRecurrence, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).ScheduleStatus = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType?) content.GetValueForProperty("ScheduleStatus",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).ScheduleStatus, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).DataSetGranularity = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType?) content.GetValueForProperty("DataSetGranularity",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).DataSetGranularity, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).DataSetConfiguration = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetConfiguration) content.GetValueForProperty("DataSetConfiguration",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).DataSetConfiguration, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDatasetConfigurationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).DestinationContainer = (string) content.GetValueForProperty("DestinationContainer",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).DestinationContainer, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).DestinationResourceId = (string) content.GetValueForProperty("DestinationResourceId",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).DestinationResourceId, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).DestinationRootFolderPath = (string) content.GetValueForProperty("DestinationRootFolderPath",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).DestinationRootFolderPath, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).RecurrencePeriodTo = (global::System.DateTime?) content.GetValueForProperty("RecurrencePeriodTo",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).RecurrencePeriodTo, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).RecurrencePeriodFrom = (global::System.DateTime) content.GetValueForProperty("RecurrencePeriodFrom",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).RecurrencePeriodFrom, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).TimePeriodFrom = (global::System.DateTime) content.GetValueForProperty("TimePeriodFrom",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).TimePeriodFrom, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).TimePeriodTo = (global::System.DateTime) content.GetValueForProperty("TimePeriodTo",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).TimePeriodTo, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).ConfigurationColumn = (string[]) content.GetValueForProperty("ConfigurationColumn",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).ConfigurationColumn, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal Export(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).Property = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportProperties) content.GetValueForProperty("Property",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).Property, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportPropertiesTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)this).Name, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)this).Type = (string) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)this).Type, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)this).ETag = (string) content.GetValueForProperty("ETag",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)this).ETag, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)this).Id = (string) content.GetValueForProperty("Id",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)this).Id, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).DeliveryInfo = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfo) content.GetValueForProperty("DeliveryInfo",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).DeliveryInfo, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDeliveryInfoTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).Definition = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinition) content.GetValueForProperty("Definition",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).Definition, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDefinitionTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).RunHistory = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionListResult) content.GetValueForProperty("RunHistory",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).RunHistory, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportExecutionListResultTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).Format = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType?) content.GetValueForProperty("Format",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).Format, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).NextRunTimeEstimate = (global::System.DateTime?) content.GetValueForProperty("NextRunTimeEstimate",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).NextRunTimeEstimate, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).Schedule = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportSchedule) content.GetValueForProperty("Schedule",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).Schedule, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportScheduleTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).DefinitionDataSet = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDataset) content.GetValueForProperty("DefinitionDataSet",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).DefinitionDataSet, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDatasetTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).DefinitionType = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType) content.GetValueForProperty("DefinitionType",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).DefinitionType, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).DefinitionTimeframe = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType) content.GetValueForProperty("DefinitionTimeframe",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).DefinitionTimeframe, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).DeliveryInfoDestination = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestination) content.GetValueForProperty("DeliveryInfoDestination",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).DeliveryInfoDestination, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDeliveryDestinationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).DefinitionTimePeriod = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportTimePeriod) content.GetValueForProperty("DefinitionTimePeriod",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).DefinitionTimePeriod, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportTimePeriodTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).RunHistoryValue = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution[]) content.GetValueForProperty("RunHistoryValue",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).RunHistoryValue, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportExecutionTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).ScheduleRecurrencePeriod = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportRecurrencePeriod) content.GetValueForProperty("ScheduleRecurrencePeriod",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).ScheduleRecurrencePeriod, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportRecurrencePeriodTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).ScheduleRecurrence = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType) content.GetValueForProperty("ScheduleRecurrence",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).ScheduleRecurrence, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).ScheduleStatus = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType?) content.GetValueForProperty("ScheduleStatus",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).ScheduleStatus, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).DataSetGranularity = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType?) content.GetValueForProperty("DataSetGranularity",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).DataSetGranularity, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).DataSetConfiguration = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetConfiguration) content.GetValueForProperty("DataSetConfiguration",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).DataSetConfiguration, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDatasetConfigurationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).DestinationContainer = (string) content.GetValueForProperty("DestinationContainer",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).DestinationContainer, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).DestinationResourceId = (string) content.GetValueForProperty("DestinationResourceId",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).DestinationResourceId, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).DestinationRootFolderPath = (string) content.GetValueForProperty("DestinationRootFolderPath",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).DestinationRootFolderPath, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).RecurrencePeriodTo = (global::System.DateTime?) content.GetValueForProperty("RecurrencePeriodTo",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).RecurrencePeriodTo, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).RecurrencePeriodFrom = (global::System.DateTime) content.GetValueForProperty("RecurrencePeriodFrom",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).RecurrencePeriodFrom, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).TimePeriodFrom = (global::System.DateTime) content.GetValueForProperty("TimePeriodFrom",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).TimePeriodFrom, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).TimePeriodTo = (global::System.DateTime) content.GetValueForProperty("TimePeriodTo",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).TimePeriodTo, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).ConfigurationColumn = (string[]) content.GetValueForProperty("ConfigurationColumn",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal)this).ConfigurationColumn, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + AfterDeserializePSObject(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// An export resource. + [System.ComponentModel.TypeConverter(typeof(ExportTypeConverter))] + public partial interface IExport + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/Export.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/Export.TypeConverter.cs new file mode 100644 index 000000000000..fd6a8416ee1e --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/Export.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class ExportTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return Export.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return Export.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return Export.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/Export.cs b/src/CostManagement/generated/api/Models/Api20200601/Export.cs new file mode 100644 index 000000000000..e5c17d4e99a5 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/Export.cs @@ -0,0 +1,402 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// An export resource. + public partial class Export : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IValidates + { + /// + /// Backing field for Inherited model + /// + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResource __proxyResource = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ProxyResource(); + + /// + /// Array of column names to be included in the export. If not provided then the export will include all available columns. + /// The available columns can vary by customer channel (see examples). + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string[] ConfigurationColumn { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)Property).ConfigurationColumn; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)Property).ConfigurationColumn = value; } + + /// The granularity of rows in the export. Currently only 'Daily' is supported. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType? DataSetGranularity { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)Property).DataSetGranularity; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)Property).DataSetGranularity = value; } + + /// + /// The time frame for pulling data for the export. If custom, then a specific time period must be provided. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType DefinitionTimeframe { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)Property).DefinitionTimeframe; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)Property).DefinitionTimeframe = value; } + + /// + /// The type of the export. Note that 'Usage' is equivalent to 'ActualCost' and is applicable to exports that do not yet provide + /// data for charges or amortization for service reservations. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType DefinitionType { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)Property).DefinitionType; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)Property).DefinitionType = value; } + + /// The name of the container where exports will be uploaded. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string DestinationContainer { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)Property).DestinationContainer; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)Property).DestinationContainer = value; } + + /// The resource id of the storage account where exports will be delivered. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string DestinationResourceId { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)Property).DestinationResourceId; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)Property).DestinationResourceId = value; } + + /// The name of the directory where exports will be uploaded. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string DestinationRootFolderPath { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)Property).DestinationRootFolderPath; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)Property).DestinationRootFolderPath = value; } + + /// + /// eTag of the resource. To handle concurrent update scenario, this field will be used to determine whether the user is updating + /// the latest version or not. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inherited)] + public string ETag { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)__proxyResource).ETag; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)__proxyResource).ETag = value; } + + /// The format of the export being delivered. Currently only 'Csv' is supported. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType? Format { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)Property).Format; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)Property).Format = value; } + + /// Resource Id. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inherited)] + public string Id { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)__proxyResource).Id; } + + /// Internal Acessors for DataSetConfiguration + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetConfiguration Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal.DataSetConfiguration { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)Property).DataSetConfiguration; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)Property).DataSetConfiguration = value; } + + /// Internal Acessors for Definition + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinition Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal.Definition { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)Property).Definition; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)Property).Definition = value; } + + /// Internal Acessors for DefinitionDataSet + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDataset Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal.DefinitionDataSet { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)Property).DefinitionDataSet; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)Property).DefinitionDataSet = value; } + + /// Internal Acessors for DefinitionTimePeriod + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportTimePeriod Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal.DefinitionTimePeriod { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)Property).DefinitionTimePeriod; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)Property).DefinitionTimePeriod = value; } + + /// Internal Acessors for DeliveryInfo + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfo Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal.DeliveryInfo { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)Property).DeliveryInfo; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)Property).DeliveryInfo = value; } + + /// Internal Acessors for DeliveryInfoDestination + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestination Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal.DeliveryInfoDestination { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)Property).DeliveryInfoDestination; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)Property).DeliveryInfoDestination = value; } + + /// Internal Acessors for NextRunTimeEstimate + global::System.DateTime? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal.NextRunTimeEstimate { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)Property).NextRunTimeEstimate; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)Property).NextRunTimeEstimate = value; } + + /// Internal Acessors for Property + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportProperties Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal.Property { get => (this._property = this._property ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportProperties()); set { {_property = value;} } } + + /// Internal Acessors for RunHistory + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionListResult Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal.RunHistory { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)Property).RunHistory; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)Property).RunHistory = value; } + + /// Internal Acessors for RunHistoryValue + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution[] Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal.RunHistoryValue { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)Property).RunHistoryValue; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)Property).RunHistoryValue = value; } + + /// Internal Acessors for Schedule + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportSchedule Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal.Schedule { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportPropertiesInternal)Property).Schedule; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportPropertiesInternal)Property).Schedule = value; } + + /// Internal Acessors for ScheduleRecurrencePeriod + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportRecurrencePeriod Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportInternal.ScheduleRecurrencePeriod { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportPropertiesInternal)Property).ScheduleRecurrencePeriod; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportPropertiesInternal)Property).ScheduleRecurrencePeriod = value; } + + /// Internal Acessors for Id + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal.Id { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)__proxyResource).Id; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)__proxyResource).Id = value; } + + /// Internal Acessors for Name + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal.Name { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)__proxyResource).Name; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)__proxyResource).Name = value; } + + /// Internal Acessors for Type + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal.Type { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)__proxyResource).Type; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)__proxyResource).Type = value; } + + /// Resource name. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inherited)] + public string Name { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)__proxyResource).Name; } + + /// + /// If the export has an active schedule, provides an estimate of the next execution time. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public global::System.DateTime? NextRunTimeEstimate { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)Property).NextRunTimeEstimate; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportProperties _property; + + /// Export properties + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + internal Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportProperties Property { get => (this._property = this._property ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportProperties()); set => this._property = value; } + + /// The start date of recurrence. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public global::System.DateTime RecurrencePeriodFrom { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportPropertiesInternal)Property).RecurrencePeriodFrom; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportPropertiesInternal)Property).RecurrencePeriodFrom = value; } + + /// The end date of recurrence. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public global::System.DateTime? RecurrencePeriodTo { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportPropertiesInternal)Property).RecurrencePeriodTo; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportPropertiesInternal)Property).RecurrencePeriodTo = value; } + + /// A list of export executions. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution[] RunHistoryValue { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)Property).RunHistoryValue; } + + /// The schedule recurrence. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType ScheduleRecurrence { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportPropertiesInternal)Property).ScheduleRecurrence; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportPropertiesInternal)Property).ScheduleRecurrence = value; } + + /// + /// The status of the export's schedule. If 'Inactive', the export's schedule is paused. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType? ScheduleStatus { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportPropertiesInternal)Property).ScheduleStatus; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportPropertiesInternal)Property).ScheduleStatus = value; } + + /// The start date for export data. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public global::System.DateTime TimePeriodFrom { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)Property).TimePeriodFrom; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)Property).TimePeriodFrom = value; } + + /// The end date for export data. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public global::System.DateTime TimePeriodTo { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)Property).TimePeriodTo; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)Property).TimePeriodTo = value; } + + /// Resource type. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inherited)] + public string Type { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)__proxyResource).Type; } + + /// Creates an new instance. + public Export() + { + + } + + /// Validates that this object meets the validation criteria. + /// an instance that will receive validation + /// events. + /// + /// A < see cref = "global::System.Threading.Tasks.Task" /> that will be complete when validation is completed. + /// + public async global::System.Threading.Tasks.Task Validate(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener) + { + await eventListener.AssertNotNull(nameof(__proxyResource), __proxyResource); + await eventListener.AssertObjectIsValid(nameof(__proxyResource), __proxyResource); + } + } + /// An export resource. + public partial interface IExport : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResource + { + /// + /// Array of column names to be included in the export. If not provided then the export will include all available columns. + /// The available columns can vary by customer channel (see examples). + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Array of column names to be included in the export. If not provided then the export will include all available columns. The available columns can vary by customer channel (see examples).", + SerializedName = @"columns", + PossibleTypes = new [] { typeof(string) })] + string[] ConfigurationColumn { get; set; } + /// The granularity of rows in the export. Currently only 'Daily' is supported. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The granularity of rows in the export. Currently only 'Daily' is supported.", + SerializedName = @"granularity", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType? DataSetGranularity { get; set; } + /// + /// The time frame for pulling data for the export. If custom, then a specific time period must be provided. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The time frame for pulling data for the export. If custom, then a specific time period must be provided.", + SerializedName = @"timeframe", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType DefinitionTimeframe { get; set; } + /// + /// The type of the export. Note that 'Usage' is equivalent to 'ActualCost' and is applicable to exports that do not yet provide + /// data for charges or amortization for service reservations. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The type of the export. Note that 'Usage' is equivalent to 'ActualCost' and is applicable to exports that do not yet provide data for charges or amortization for service reservations.", + SerializedName = @"type", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType DefinitionType { get; set; } + /// The name of the container where exports will be uploaded. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The name of the container where exports will be uploaded.", + SerializedName = @"container", + PossibleTypes = new [] { typeof(string) })] + string DestinationContainer { get; set; } + /// The resource id of the storage account where exports will be delivered. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The resource id of the storage account where exports will be delivered.", + SerializedName = @"resourceId", + PossibleTypes = new [] { typeof(string) })] + string DestinationResourceId { get; set; } + /// The name of the directory where exports will be uploaded. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The name of the directory where exports will be uploaded.", + SerializedName = @"rootFolderPath", + PossibleTypes = new [] { typeof(string) })] + string DestinationRootFolderPath { get; set; } + /// The format of the export being delivered. Currently only 'Csv' is supported. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The format of the export being delivered. Currently only 'Csv' is supported.", + SerializedName = @"format", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType? Format { get; set; } + /// + /// If the export has an active schedule, provides an estimate of the next execution time. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"If the export has an active schedule, provides an estimate of the next execution time.", + SerializedName = @"nextRunTimeEstimate", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime? NextRunTimeEstimate { get; } + /// The start date of recurrence. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The start date of recurrence.", + SerializedName = @"from", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime RecurrencePeriodFrom { get; set; } + /// The end date of recurrence. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The end date of recurrence.", + SerializedName = @"to", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime? RecurrencePeriodTo { get; set; } + /// A list of export executions. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"A list of export executions.", + SerializedName = @"value", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution[] RunHistoryValue { get; } + /// The schedule recurrence. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The schedule recurrence.", + SerializedName = @"recurrence", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType ScheduleRecurrence { get; set; } + /// + /// The status of the export's schedule. If 'Inactive', the export's schedule is paused. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The status of the export's schedule. If 'Inactive', the export's schedule is paused.", + SerializedName = @"status", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType? ScheduleStatus { get; set; } + /// The start date for export data. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The start date for export data.", + SerializedName = @"from", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime TimePeriodFrom { get; set; } + /// The end date for export data. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The end date for export data.", + SerializedName = @"to", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime TimePeriodTo { get; set; } + + } + /// An export resource. + public partial interface IExportInternal : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal + { + /// + /// Array of column names to be included in the export. If not provided then the export will include all available columns. + /// The available columns can vary by customer channel (see examples). + /// + string[] ConfigurationColumn { get; set; } + /// The export dataset configuration. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetConfiguration DataSetConfiguration { get; set; } + /// The granularity of rows in the export. Currently only 'Daily' is supported. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType? DataSetGranularity { get; set; } + /// Has the definition for the export. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinition Definition { get; set; } + /// The definition for data in the export. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDataset DefinitionDataSet { get; set; } + /// Has time period for pulling data for the export. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportTimePeriod DefinitionTimePeriod { get; set; } + /// + /// The time frame for pulling data for the export. If custom, then a specific time period must be provided. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType DefinitionTimeframe { get; set; } + /// + /// The type of the export. Note that 'Usage' is equivalent to 'ActualCost' and is applicable to exports that do not yet provide + /// data for charges or amortization for service reservations. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType DefinitionType { get; set; } + /// Has delivery information for the export. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfo DeliveryInfo { get; set; } + /// Has destination for the export being delivered. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestination DeliveryInfoDestination { get; set; } + /// The name of the container where exports will be uploaded. + string DestinationContainer { get; set; } + /// The resource id of the storage account where exports will be delivered. + string DestinationResourceId { get; set; } + /// The name of the directory where exports will be uploaded. + string DestinationRootFolderPath { get; set; } + /// The format of the export being delivered. Currently only 'Csv' is supported. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType? Format { get; set; } + /// + /// If the export has an active schedule, provides an estimate of the next execution time. + /// + global::System.DateTime? NextRunTimeEstimate { get; set; } + /// Export properties + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportProperties Property { get; set; } + /// The start date of recurrence. + global::System.DateTime RecurrencePeriodFrom { get; set; } + /// The end date of recurrence. + global::System.DateTime? RecurrencePeriodTo { get; set; } + /// If requested, has the most recent execution history for the export. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionListResult RunHistory { get; set; } + /// A list of export executions. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution[] RunHistoryValue { get; set; } + /// Has schedule information for the export. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportSchedule Schedule { get; set; } + /// The schedule recurrence. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType ScheduleRecurrence { get; set; } + /// + /// Has start and end date of the recurrence. The start date must be in future. If present, the end date must be greater than + /// start date. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportRecurrencePeriod ScheduleRecurrencePeriod { get; set; } + /// + /// The status of the export's schedule. If 'Inactive', the export's schedule is paused. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType? ScheduleStatus { get; set; } + /// The start date for export data. + global::System.DateTime TimePeriodFrom { get; set; } + /// The end date for export data. + global::System.DateTime TimePeriodTo { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/Export.json.cs b/src/CostManagement/generated/api/Models/Api20200601/Export.json.cs new file mode 100644 index 000000000000..da49e1a15295 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/Export.json.cs @@ -0,0 +1,103 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// An export resource. + public partial class Export + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal Export(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + __proxyResource = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ProxyResource(json); + {_property = If( json?.PropertyT("properties"), out var __jsonProperties) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportProperties.FromJson(__jsonProperties) : Property;} + AfterFromJson(json); + } + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new Export(json) : null; + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + __proxyResource?.ToJson(container, serializationMode); + AddIf( null != this._property ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._property.ToJson(null,serializationMode) : null, "properties" ,container.Add ); + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportDataset.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportDataset.PowerShell.cs new file mode 100644 index 000000000000..334cef29e5b1 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportDataset.PowerShell.cs @@ -0,0 +1,135 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// The definition for data in the export. + [System.ComponentModel.TypeConverter(typeof(ExportDatasetTypeConverter))] + public partial class ExportDataset + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDataset DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new ExportDataset(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDataset DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new ExportDataset(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal ExportDataset(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetInternal)this).Configuration = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetConfiguration) content.GetValueForProperty("Configuration",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetInternal)this).Configuration, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDatasetConfigurationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetInternal)this).Granularity = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType?) content.GetValueForProperty("Granularity",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetInternal)this).Granularity, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetInternal)this).ConfigurationColumn = (string[]) content.GetValueForProperty("ConfigurationColumn",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetInternal)this).ConfigurationColumn, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal ExportDataset(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetInternal)this).Configuration = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetConfiguration) content.GetValueForProperty("Configuration",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetInternal)this).Configuration, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDatasetConfigurationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetInternal)this).Granularity = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType?) content.GetValueForProperty("Granularity",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetInternal)this).Granularity, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetInternal)this).ConfigurationColumn = (string[]) content.GetValueForProperty("ConfigurationColumn",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetInternal)this).ConfigurationColumn, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + AfterDeserializePSObject(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDataset FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// The definition for data in the export. + [System.ComponentModel.TypeConverter(typeof(ExportDatasetTypeConverter))] + public partial interface IExportDataset + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportDataset.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportDataset.TypeConverter.cs new file mode 100644 index 000000000000..9d67ec52f376 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportDataset.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class ExportDatasetTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDataset ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDataset).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return ExportDataset.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return ExportDataset.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return ExportDataset.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportDataset.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportDataset.cs new file mode 100644 index 000000000000..19ba451afcb4 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportDataset.cs @@ -0,0 +1,81 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The definition for data in the export. + public partial class ExportDataset : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDataset, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetInternal + { + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetConfiguration _configuration; + + /// The export dataset configuration. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + internal Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetConfiguration Configuration { get => (this._configuration = this._configuration ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDatasetConfiguration()); set => this._configuration = value; } + + /// + /// Array of column names to be included in the export. If not provided then the export will include all available columns. + /// The available columns can vary by customer channel (see examples). + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string[] ConfigurationColumn { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetConfigurationInternal)Configuration).Column; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetConfigurationInternal)Configuration).Column = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType? _granularity; + + /// The granularity of rows in the export. Currently only 'Daily' is supported. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType? Granularity { get => this._granularity; set => this._granularity = value; } + + /// Internal Acessors for Configuration + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetConfiguration Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetInternal.Configuration { get => (this._configuration = this._configuration ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDatasetConfiguration()); set { {_configuration = value;} } } + + /// Creates an new instance. + public ExportDataset() + { + + } + } + /// The definition for data in the export. + public partial interface IExportDataset : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// + /// Array of column names to be included in the export. If not provided then the export will include all available columns. + /// The available columns can vary by customer channel (see examples). + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Array of column names to be included in the export. If not provided then the export will include all available columns. The available columns can vary by customer channel (see examples).", + SerializedName = @"columns", + PossibleTypes = new [] { typeof(string) })] + string[] ConfigurationColumn { get; set; } + /// The granularity of rows in the export. Currently only 'Daily' is supported. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The granularity of rows in the export. Currently only 'Daily' is supported.", + SerializedName = @"granularity", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType? Granularity { get; set; } + + } + /// The definition for data in the export. + public partial interface IExportDatasetInternal + + { + /// The export dataset configuration. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetConfiguration Configuration { get; set; } + /// + /// Array of column names to be included in the export. If not provided then the export will include all available columns. + /// The available columns can vary by customer channel (see examples). + /// + string[] ConfigurationColumn { get; set; } + /// The granularity of rows in the export. Currently only 'Daily' is supported. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType? Granularity { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportDataset.json.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportDataset.json.cs new file mode 100644 index 000000000000..b9bdf7602536 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportDataset.json.cs @@ -0,0 +1,103 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The definition for data in the export. + public partial class ExportDataset + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal ExportDataset(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_configuration = If( json?.PropertyT("configuration"), out var __jsonConfiguration) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDatasetConfiguration.FromJson(__jsonConfiguration) : Configuration;} + {_granularity = If( json?.PropertyT("granularity"), out var __jsonGranularity) ? (string)__jsonGranularity : (string)Granularity;} + AfterFromJson(json); + } + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDataset. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDataset. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDataset FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new ExportDataset(json) : null; + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + AddIf( null != this._configuration ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._configuration.ToJson(null,serializationMode) : null, "configuration" ,container.Add ); + AddIf( null != (((object)this._granularity)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._granularity.ToString()) : null, "granularity" ,container.Add ); + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportDatasetConfiguration.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportDatasetConfiguration.PowerShell.cs new file mode 100644 index 000000000000..e2727460ca8c --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportDatasetConfiguration.PowerShell.cs @@ -0,0 +1,137 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// The export dataset configuration. Allows columns to be selected for the export. If not provided then the export will include + /// all available columns. + /// + [System.ComponentModel.TypeConverter(typeof(ExportDatasetConfigurationTypeConverter))] + public partial class ExportDatasetConfiguration + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetConfiguration DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new ExportDatasetConfiguration(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetConfiguration DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new ExportDatasetConfiguration(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal ExportDatasetConfiguration(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetConfigurationInternal)this).Column = (string[]) content.GetValueForProperty("Column",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetConfigurationInternal)this).Column, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal ExportDatasetConfiguration(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetConfigurationInternal)this).Column = (string[]) content.GetValueForProperty("Column",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetConfigurationInternal)this).Column, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + AfterDeserializePSObject(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetConfiguration FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// The export dataset configuration. Allows columns to be selected for the export. If not provided then the export will include + /// all available columns. + [System.ComponentModel.TypeConverter(typeof(ExportDatasetConfigurationTypeConverter))] + public partial interface IExportDatasetConfiguration + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportDatasetConfiguration.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportDatasetConfiguration.TypeConverter.cs new file mode 100644 index 000000000000..b8bb789663aa --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportDatasetConfiguration.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class ExportDatasetConfigurationTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetConfiguration ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetConfiguration).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return ExportDatasetConfiguration.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return ExportDatasetConfiguration.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return ExportDatasetConfiguration.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportDatasetConfiguration.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportDatasetConfiguration.cs new file mode 100644 index 000000000000..554a445c905f --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportDatasetConfiguration.cs @@ -0,0 +1,60 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// + /// The export dataset configuration. Allows columns to be selected for the export. If not provided then the export will include + /// all available columns. + /// + public partial class ExportDatasetConfiguration : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetConfiguration, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetConfigurationInternal + { + + /// Backing field for property. + private string[] _column; + + /// + /// Array of column names to be included in the export. If not provided then the export will include all available columns. + /// The available columns can vary by customer channel (see examples). + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string[] Column { get => this._column; set => this._column = value; } + + /// Creates an new instance. + public ExportDatasetConfiguration() + { + + } + } + /// The export dataset configuration. Allows columns to be selected for the export. If not provided then the export will include + /// all available columns. + public partial interface IExportDatasetConfiguration : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// + /// Array of column names to be included in the export. If not provided then the export will include all available columns. + /// The available columns can vary by customer channel (see examples). + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Array of column names to be included in the export. If not provided then the export will include all available columns. The available columns can vary by customer channel (see examples).", + SerializedName = @"columns", + PossibleTypes = new [] { typeof(string) })] + string[] Column { get; set; } + + } + /// The export dataset configuration. Allows columns to be selected for the export. If not provided then the export will include + /// all available columns. + public partial interface IExportDatasetConfigurationInternal + + { + /// + /// Array of column names to be included in the export. If not provided then the export will include all available columns. + /// The available columns can vary by customer channel (see examples). + /// + string[] Column { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportDatasetConfiguration.json.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportDatasetConfiguration.json.cs new file mode 100644 index 000000000000..6eb4e8c7b733 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportDatasetConfiguration.json.cs @@ -0,0 +1,112 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// + /// The export dataset configuration. Allows columns to be selected for the export. If not provided then the export will include + /// all available columns. + /// + public partial class ExportDatasetConfiguration + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal ExportDatasetConfiguration(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_column = If( json?.PropertyT("columns"), out var __jsonColumns) ? If( __jsonColumns as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonArray, out var __v) ? new global::System.Func(()=> global::System.Linq.Enumerable.ToArray(global::System.Linq.Enumerable.Select(__v, (__u)=>(string) (__u is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString __t ? (string)(__t.ToString()) : null)) ))() : null : Column;} + AfterFromJson(json); + } + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetConfiguration. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetConfiguration. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetConfiguration FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new ExportDatasetConfiguration(json) : null; + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + if (null != this._column) + { + var __w = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.XNodeArray(); + foreach( var __x in this._column ) + { + AddIf(null != (((object)__x)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(__x.ToString()) : null ,__w.Add); + } + container.Add("columns",__w); + } + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportDefinition.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportDefinition.PowerShell.cs new file mode 100644 index 000000000000..4e12c07c28cd --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportDefinition.PowerShell.cs @@ -0,0 +1,147 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// The definition of an export. + [System.ComponentModel.TypeConverter(typeof(ExportDefinitionTypeConverter))] + public partial class ExportDefinition + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinition DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new ExportDefinition(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinition DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new ExportDefinition(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal ExportDefinition(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)this).DataSet = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDataset) content.GetValueForProperty("DataSet",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)this).DataSet, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDatasetTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)this).TimePeriod = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportTimePeriod) content.GetValueForProperty("TimePeriod",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)this).TimePeriod, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportTimePeriodTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)this).Type = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)this).Type, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)this).Timeframe = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType) content.GetValueForProperty("Timeframe",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)this).Timeframe, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)this).DataSetConfiguration = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetConfiguration) content.GetValueForProperty("DataSetConfiguration",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)this).DataSetConfiguration, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDatasetConfigurationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)this).DataSetGranularity = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType?) content.GetValueForProperty("DataSetGranularity",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)this).DataSetGranularity, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)this).TimePeriodFrom = (global::System.DateTime) content.GetValueForProperty("TimePeriodFrom",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)this).TimePeriodFrom, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)this).TimePeriodTo = (global::System.DateTime) content.GetValueForProperty("TimePeriodTo",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)this).TimePeriodTo, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)this).ConfigurationColumn = (string[]) content.GetValueForProperty("ConfigurationColumn",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)this).ConfigurationColumn, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal ExportDefinition(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)this).DataSet = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDataset) content.GetValueForProperty("DataSet",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)this).DataSet, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDatasetTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)this).TimePeriod = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportTimePeriod) content.GetValueForProperty("TimePeriod",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)this).TimePeriod, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportTimePeriodTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)this).Type = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)this).Type, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)this).Timeframe = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType) content.GetValueForProperty("Timeframe",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)this).Timeframe, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)this).DataSetConfiguration = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetConfiguration) content.GetValueForProperty("DataSetConfiguration",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)this).DataSetConfiguration, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDatasetConfigurationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)this).DataSetGranularity = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType?) content.GetValueForProperty("DataSetGranularity",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)this).DataSetGranularity, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)this).TimePeriodFrom = (global::System.DateTime) content.GetValueForProperty("TimePeriodFrom",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)this).TimePeriodFrom, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)this).TimePeriodTo = (global::System.DateTime) content.GetValueForProperty("TimePeriodTo",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)this).TimePeriodTo, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)this).ConfigurationColumn = (string[]) content.GetValueForProperty("ConfigurationColumn",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal)this).ConfigurationColumn, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + AfterDeserializePSObject(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinition FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// The definition of an export. + [System.ComponentModel.TypeConverter(typeof(ExportDefinitionTypeConverter))] + public partial interface IExportDefinition + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportDefinition.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportDefinition.TypeConverter.cs new file mode 100644 index 000000000000..a9c6344e55a8 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportDefinition.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class ExportDefinitionTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinition ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinition).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return ExportDefinition.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return ExportDefinition.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return ExportDefinition.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportDefinition.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportDefinition.cs new file mode 100644 index 000000000000..309f0bcb7836 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportDefinition.cs @@ -0,0 +1,172 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The definition of an export. + public partial class ExportDefinition : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinition, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal + { + + /// + /// Array of column names to be included in the export. If not provided then the export will include all available columns. + /// The available columns can vary by customer channel (see examples). + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string[] ConfigurationColumn { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetInternal)DataSet).ConfigurationColumn; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetInternal)DataSet).ConfigurationColumn = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDataset _dataSet; + + /// The definition for data in the export. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + internal Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDataset DataSet { get => (this._dataSet = this._dataSet ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDataset()); set => this._dataSet = value; } + + /// The granularity of rows in the export. Currently only 'Daily' is supported. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType? DataSetGranularity { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetInternal)DataSet).Granularity; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetInternal)DataSet).Granularity = value; } + + /// Internal Acessors for DataSet + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDataset Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal.DataSet { get => (this._dataSet = this._dataSet ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDataset()); set { {_dataSet = value;} } } + + /// Internal Acessors for DataSetConfiguration + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetConfiguration Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal.DataSetConfiguration { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetInternal)DataSet).Configuration; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetInternal)DataSet).Configuration = value; } + + /// Internal Acessors for TimePeriod + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportTimePeriod Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinitionInternal.TimePeriod { get => (this._timePeriod = this._timePeriod ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportTimePeriod()); set { {_timePeriod = value;} } } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportTimePeriod _timePeriod; + + /// Has time period for pulling data for the export. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + internal Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportTimePeriod TimePeriod { get => (this._timePeriod = this._timePeriod ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportTimePeriod()); set => this._timePeriod = value; } + + /// The start date for export data. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public global::System.DateTime TimePeriodFrom { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportTimePeriodInternal)TimePeriod).From; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportTimePeriodInternal)TimePeriod).From = value; } + + /// The end date for export data. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public global::System.DateTime TimePeriodTo { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportTimePeriodInternal)TimePeriod).To; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportTimePeriodInternal)TimePeriod).To = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType _timeframe; + + /// + /// The time frame for pulling data for the export. If custom, then a specific time period must be provided. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType Timeframe { get => this._timeframe; set => this._timeframe = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType _type; + + /// + /// The type of the export. Note that 'Usage' is equivalent to 'ActualCost' and is applicable to exports that do not yet provide + /// data for charges or amortization for service reservations. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType Type { get => this._type; set => this._type = value; } + + /// Creates an new instance. + public ExportDefinition() + { + + } + } + /// The definition of an export. + public partial interface IExportDefinition : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// + /// Array of column names to be included in the export. If not provided then the export will include all available columns. + /// The available columns can vary by customer channel (see examples). + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Array of column names to be included in the export. If not provided then the export will include all available columns. The available columns can vary by customer channel (see examples).", + SerializedName = @"columns", + PossibleTypes = new [] { typeof(string) })] + string[] ConfigurationColumn { get; set; } + /// The granularity of rows in the export. Currently only 'Daily' is supported. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The granularity of rows in the export. Currently only 'Daily' is supported.", + SerializedName = @"granularity", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType? DataSetGranularity { get; set; } + /// The start date for export data. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The start date for export data.", + SerializedName = @"from", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime TimePeriodFrom { get; set; } + /// The end date for export data. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The end date for export data.", + SerializedName = @"to", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime TimePeriodTo { get; set; } + /// + /// The time frame for pulling data for the export. If custom, then a specific time period must be provided. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The time frame for pulling data for the export. If custom, then a specific time period must be provided.", + SerializedName = @"timeframe", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType Timeframe { get; set; } + /// + /// The type of the export. Note that 'Usage' is equivalent to 'ActualCost' and is applicable to exports that do not yet provide + /// data for charges or amortization for service reservations. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The type of the export. Note that 'Usage' is equivalent to 'ActualCost' and is applicable to exports that do not yet provide data for charges or amortization for service reservations.", + SerializedName = @"type", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType Type { get; set; } + + } + /// The definition of an export. + public partial interface IExportDefinitionInternal + + { + /// + /// Array of column names to be included in the export. If not provided then the export will include all available columns. + /// The available columns can vary by customer channel (see examples). + /// + string[] ConfigurationColumn { get; set; } + /// The definition for data in the export. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDataset DataSet { get; set; } + /// The export dataset configuration. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetConfiguration DataSetConfiguration { get; set; } + /// The granularity of rows in the export. Currently only 'Daily' is supported. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType? DataSetGranularity { get; set; } + /// Has time period for pulling data for the export. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportTimePeriod TimePeriod { get; set; } + /// The start date for export data. + global::System.DateTime TimePeriodFrom { get; set; } + /// The end date for export data. + global::System.DateTime TimePeriodTo { get; set; } + /// + /// The time frame for pulling data for the export. If custom, then a specific time period must be provided. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType Timeframe { get; set; } + /// + /// The type of the export. Note that 'Usage' is equivalent to 'ActualCost' and is applicable to exports that do not yet provide + /// data for charges or amortization for service reservations. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType Type { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportDefinition.json.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportDefinition.json.cs new file mode 100644 index 000000000000..738a5af1bdd1 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportDefinition.json.cs @@ -0,0 +1,107 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The definition of an export. + public partial class ExportDefinition + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal ExportDefinition(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_dataSet = If( json?.PropertyT("dataSet"), out var __jsonDataSet) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDataset.FromJson(__jsonDataSet) : DataSet;} + {_timePeriod = If( json?.PropertyT("timePeriod"), out var __jsonTimePeriod) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportTimePeriod.FromJson(__jsonTimePeriod) : TimePeriod;} + {_type = If( json?.PropertyT("type"), out var __jsonType) ? (string)__jsonType : (string)Type;} + {_timeframe = If( json?.PropertyT("timeframe"), out var __jsonTimeframe) ? (string)__jsonTimeframe : (string)Timeframe;} + AfterFromJson(json); + } + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinition. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinition. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinition FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new ExportDefinition(json) : null; + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + AddIf( null != this._dataSet ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._dataSet.ToJson(null,serializationMode) : null, "dataSet" ,container.Add ); + AddIf( null != this._timePeriod ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._timePeriod.ToJson(null,serializationMode) : null, "timePeriod" ,container.Add ); + AddIf( null != (((object)this._type)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._type.ToString()) : null, "type" ,container.Add ); + AddIf( null != (((object)this._timeframe)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._timeframe.ToString()) : null, "timeframe" ,container.Add ); + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportDeliveryDestination.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportDeliveryDestination.PowerShell.cs new file mode 100644 index 000000000000..7a81be8fa242 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportDeliveryDestination.PowerShell.cs @@ -0,0 +1,147 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// The destination information for the delivery of the export. To allow access to a storage account, you must register the + /// account's subscription with the Microsoft.CostManagementExports resource provider. This is required once per subscription. + /// When creating an export in the Azure portal, it is done automatically, however API users need to register the subscription. + /// For more information see https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-supported-services + /// . + /// + [System.ComponentModel.TypeConverter(typeof(ExportDeliveryDestinationTypeConverter))] + public partial class ExportDeliveryDestination + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestination DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new ExportDeliveryDestination(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestination DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new ExportDeliveryDestination(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal ExportDeliveryDestination(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestinationInternal)this).Container = (string) content.GetValueForProperty("Container",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestinationInternal)this).Container, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestinationInternal)this).ResourceId = (string) content.GetValueForProperty("ResourceId",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestinationInternal)this).ResourceId, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestinationInternal)this).RootFolderPath = (string) content.GetValueForProperty("RootFolderPath",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestinationInternal)this).RootFolderPath, global::System.Convert.ToString); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal ExportDeliveryDestination(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestinationInternal)this).Container = (string) content.GetValueForProperty("Container",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestinationInternal)this).Container, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestinationInternal)this).ResourceId = (string) content.GetValueForProperty("ResourceId",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestinationInternal)this).ResourceId, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestinationInternal)this).RootFolderPath = (string) content.GetValueForProperty("RootFolderPath",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestinationInternal)this).RootFolderPath, global::System.Convert.ToString); + AfterDeserializePSObject(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestination FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// The destination information for the delivery of the export. To allow access to a storage account, you must register the + /// account's subscription with the Microsoft.CostManagementExports resource provider. This is required once per subscription. + /// When creating an export in the Azure portal, it is done automatically, however API users need to register the subscription. + /// For more information see https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-supported-services + /// . + [System.ComponentModel.TypeConverter(typeof(ExportDeliveryDestinationTypeConverter))] + public partial interface IExportDeliveryDestination + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportDeliveryDestination.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportDeliveryDestination.TypeConverter.cs new file mode 100644 index 000000000000..2170f4ef266e --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportDeliveryDestination.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class ExportDeliveryDestinationTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestination ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestination).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return ExportDeliveryDestination.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return ExportDeliveryDestination.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return ExportDeliveryDestination.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportDeliveryDestination.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportDeliveryDestination.cs new file mode 100644 index 000000000000..422d35b7f161 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportDeliveryDestination.cs @@ -0,0 +1,94 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// + /// The destination information for the delivery of the export. To allow access to a storage account, you must register the + /// account's subscription with the Microsoft.CostManagementExports resource provider. This is required once per subscription. + /// When creating an export in the Azure portal, it is done automatically, however API users need to register the subscription. + /// For more information see https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-supported-services + /// . + /// + public partial class ExportDeliveryDestination : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestination, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestinationInternal + { + + /// Backing field for property. + private string _container; + + /// The name of the container where exports will be uploaded. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string Container { get => this._container; set => this._container = value; } + + /// Backing field for property. + private string _resourceId; + + /// The resource id of the storage account where exports will be delivered. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string ResourceId { get => this._resourceId; set => this._resourceId = value; } + + /// Backing field for property. + private string _rootFolderPath; + + /// The name of the directory where exports will be uploaded. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string RootFolderPath { get => this._rootFolderPath; set => this._rootFolderPath = value; } + + /// Creates an new instance. + public ExportDeliveryDestination() + { + + } + } + /// The destination information for the delivery of the export. To allow access to a storage account, you must register the + /// account's subscription with the Microsoft.CostManagementExports resource provider. This is required once per subscription. + /// When creating an export in the Azure portal, it is done automatically, however API users need to register the subscription. + /// For more information see https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-supported-services + /// . + public partial interface IExportDeliveryDestination : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// The name of the container where exports will be uploaded. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The name of the container where exports will be uploaded.", + SerializedName = @"container", + PossibleTypes = new [] { typeof(string) })] + string Container { get; set; } + /// The resource id of the storage account where exports will be delivered. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The resource id of the storage account where exports will be delivered.", + SerializedName = @"resourceId", + PossibleTypes = new [] { typeof(string) })] + string ResourceId { get; set; } + /// The name of the directory where exports will be uploaded. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The name of the directory where exports will be uploaded.", + SerializedName = @"rootFolderPath", + PossibleTypes = new [] { typeof(string) })] + string RootFolderPath { get; set; } + + } + /// The destination information for the delivery of the export. To allow access to a storage account, you must register the + /// account's subscription with the Microsoft.CostManagementExports resource provider. This is required once per subscription. + /// When creating an export in the Azure portal, it is done automatically, however API users need to register the subscription. + /// For more information see https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-supported-services + /// . + public partial interface IExportDeliveryDestinationInternal + + { + /// The name of the container where exports will be uploaded. + string Container { get; set; } + /// The resource id of the storage account where exports will be delivered. + string ResourceId { get; set; } + /// The name of the directory where exports will be uploaded. + string RootFolderPath { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportDeliveryDestination.json.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportDeliveryDestination.json.cs new file mode 100644 index 000000000000..aea5d3bbf31f --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportDeliveryDestination.json.cs @@ -0,0 +1,111 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// + /// The destination information for the delivery of the export. To allow access to a storage account, you must register the + /// account's subscription with the Microsoft.CostManagementExports resource provider. This is required once per subscription. + /// When creating an export in the Azure portal, it is done automatically, however API users need to register the subscription. + /// For more information see https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-supported-services + /// . + /// + public partial class ExportDeliveryDestination + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal ExportDeliveryDestination(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_container = If( json?.PropertyT("container"), out var __jsonContainer) ? (string)__jsonContainer : (string)Container;} + {_resourceId = If( json?.PropertyT("resourceId"), out var __jsonResourceId) ? (string)__jsonResourceId : (string)ResourceId;} + {_rootFolderPath = If( json?.PropertyT("rootFolderPath"), out var __jsonRootFolderPath) ? (string)__jsonRootFolderPath : (string)RootFolderPath;} + AfterFromJson(json); + } + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestination. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestination. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestination FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new ExportDeliveryDestination(json) : null; + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + AddIf( null != (((object)this._container)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._container.ToString()) : null, "container" ,container.Add ); + AddIf( null != (((object)this._resourceId)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._resourceId.ToString()) : null, "resourceId" ,container.Add ); + AddIf( null != (((object)this._rootFolderPath)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._rootFolderPath.ToString()) : null, "rootFolderPath" ,container.Add ); + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportDeliveryInfo.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportDeliveryInfo.PowerShell.cs new file mode 100644 index 000000000000..3bd71b5ecba0 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportDeliveryInfo.PowerShell.cs @@ -0,0 +1,137 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// The delivery information associated with a export. + [System.ComponentModel.TypeConverter(typeof(ExportDeliveryInfoTypeConverter))] + public partial class ExportDeliveryInfo + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfo DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new ExportDeliveryInfo(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfo DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new ExportDeliveryInfo(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal ExportDeliveryInfo(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfoInternal)this).Destination = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestination) content.GetValueForProperty("Destination",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfoInternal)this).Destination, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDeliveryDestinationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfoInternal)this).DestinationContainer = (string) content.GetValueForProperty("DestinationContainer",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfoInternal)this).DestinationContainer, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfoInternal)this).DestinationResourceId = (string) content.GetValueForProperty("DestinationResourceId",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfoInternal)this).DestinationResourceId, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfoInternal)this).DestinationRootFolderPath = (string) content.GetValueForProperty("DestinationRootFolderPath",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfoInternal)this).DestinationRootFolderPath, global::System.Convert.ToString); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal ExportDeliveryInfo(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfoInternal)this).Destination = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestination) content.GetValueForProperty("Destination",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfoInternal)this).Destination, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDeliveryDestinationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfoInternal)this).DestinationContainer = (string) content.GetValueForProperty("DestinationContainer",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfoInternal)this).DestinationContainer, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfoInternal)this).DestinationResourceId = (string) content.GetValueForProperty("DestinationResourceId",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfoInternal)this).DestinationResourceId, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfoInternal)this).DestinationRootFolderPath = (string) content.GetValueForProperty("DestinationRootFolderPath",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfoInternal)this).DestinationRootFolderPath, global::System.Convert.ToString); + AfterDeserializePSObject(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfo FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// The delivery information associated with a export. + [System.ComponentModel.TypeConverter(typeof(ExportDeliveryInfoTypeConverter))] + public partial interface IExportDeliveryInfo + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportDeliveryInfo.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportDeliveryInfo.TypeConverter.cs new file mode 100644 index 000000000000..c52f0edd1250 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportDeliveryInfo.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class ExportDeliveryInfoTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfo ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfo).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return ExportDeliveryInfo.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return ExportDeliveryInfo.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return ExportDeliveryInfo.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportDeliveryInfo.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportDeliveryInfo.cs new file mode 100644 index 000000000000..28a0b8e54cb4 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportDeliveryInfo.cs @@ -0,0 +1,83 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The delivery information associated with a export. + public partial class ExportDeliveryInfo : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfo, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfoInternal + { + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestination _destination; + + /// Has destination for the export being delivered. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + internal Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestination Destination { get => (this._destination = this._destination ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDeliveryDestination()); set => this._destination = value; } + + /// The name of the container where exports will be uploaded. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string DestinationContainer { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestinationInternal)Destination).Container; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestinationInternal)Destination).Container = value; } + + /// The resource id of the storage account where exports will be delivered. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string DestinationResourceId { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestinationInternal)Destination).ResourceId; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestinationInternal)Destination).ResourceId = value; } + + /// The name of the directory where exports will be uploaded. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string DestinationRootFolderPath { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestinationInternal)Destination).RootFolderPath; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestinationInternal)Destination).RootFolderPath = value; } + + /// Internal Acessors for Destination + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestination Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfoInternal.Destination { get => (this._destination = this._destination ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDeliveryDestination()); set { {_destination = value;} } } + + /// Creates an new instance. + public ExportDeliveryInfo() + { + + } + } + /// The delivery information associated with a export. + public partial interface IExportDeliveryInfo : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// The name of the container where exports will be uploaded. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The name of the container where exports will be uploaded.", + SerializedName = @"container", + PossibleTypes = new [] { typeof(string) })] + string DestinationContainer { get; set; } + /// The resource id of the storage account where exports will be delivered. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The resource id of the storage account where exports will be delivered.", + SerializedName = @"resourceId", + PossibleTypes = new [] { typeof(string) })] + string DestinationResourceId { get; set; } + /// The name of the directory where exports will be uploaded. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The name of the directory where exports will be uploaded.", + SerializedName = @"rootFolderPath", + PossibleTypes = new [] { typeof(string) })] + string DestinationRootFolderPath { get; set; } + + } + /// The delivery information associated with a export. + public partial interface IExportDeliveryInfoInternal + + { + /// Has destination for the export being delivered. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestination Destination { get; set; } + /// The name of the container where exports will be uploaded. + string DestinationContainer { get; set; } + /// The resource id of the storage account where exports will be delivered. + string DestinationResourceId { get; set; } + /// The name of the directory where exports will be uploaded. + string DestinationRootFolderPath { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportDeliveryInfo.json.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportDeliveryInfo.json.cs new file mode 100644 index 000000000000..5fdf03cde528 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportDeliveryInfo.json.cs @@ -0,0 +1,101 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The delivery information associated with a export. + public partial class ExportDeliveryInfo + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal ExportDeliveryInfo(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_destination = If( json?.PropertyT("destination"), out var __jsonDestination) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDeliveryDestination.FromJson(__jsonDestination) : Destination;} + AfterFromJson(json); + } + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfo. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfo. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfo FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new ExportDeliveryInfo(json) : null; + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + AddIf( null != this._destination ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._destination.ToJson(null,serializationMode) : null, "destination" ,container.Add ); + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportExecution.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportExecution.PowerShell.cs new file mode 100644 index 000000000000..6c5ab925b0c5 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportExecution.PowerShell.cs @@ -0,0 +1,199 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// An export execution. + [System.ComponentModel.TypeConverter(typeof(ExportExecutionTypeConverter))] + public partial class ExportExecution + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new ExportExecution(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new ExportExecution(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal ExportExecution(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).Property = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionProperties) content.GetValueForProperty("Property",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).Property, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportExecutionPropertiesTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Name, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Type = (string) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Type, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Id = (string) content.GetValueForProperty("Id",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Id, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Tag = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceTags) content.GetValueForProperty("Tag",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Tag, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ResourceTagsTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).ExecutionType = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionType?) content.GetValueForProperty("ExecutionType",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).ExecutionType, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).Error = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorDetails) content.GetValueForProperty("Error",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).Error, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ErrorDetailsTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).FileName = (string) content.GetValueForProperty("FileName",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).FileName, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).ProcessingEndTime = (global::System.DateTime?) content.GetValueForProperty("ProcessingEndTime",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).ProcessingEndTime, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).ProcessingStartTime = (global::System.DateTime?) content.GetValueForProperty("ProcessingStartTime",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).ProcessingStartTime, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).Status = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionStatus?) content.GetValueForProperty("Status",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).Status, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionStatus.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).SubmittedBy = (string) content.GetValueForProperty("SubmittedBy",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).SubmittedBy, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).SubmittedTime = (global::System.DateTime?) content.GetValueForProperty("SubmittedTime",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).SubmittedTime, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).RunSetting = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportProperties) content.GetValueForProperty("RunSetting",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).RunSetting, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.CommonExportPropertiesTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).Code = (string) content.GetValueForProperty("Code",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).Code, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).RunSettingDefinition = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinition) content.GetValueForProperty("RunSettingDefinition",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).RunSettingDefinition, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDefinitionTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).RunSettingDeliveryInfo = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfo) content.GetValueForProperty("RunSettingDeliveryInfo",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).RunSettingDeliveryInfo, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDeliveryInfoTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).RunSettingRunHistory = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionListResult) content.GetValueForProperty("RunSettingRunHistory",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).RunSettingRunHistory, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportExecutionListResultTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).RunSettingFormat = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType?) content.GetValueForProperty("RunSettingFormat",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).RunSettingFormat, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).RunSettingNextRunTimeEstimate = (global::System.DateTime?) content.GetValueForProperty("RunSettingNextRunTimeEstimate",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).RunSettingNextRunTimeEstimate, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).Message = (string) content.GetValueForProperty("Message",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).Message, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).DefinitionDataSet = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDataset) content.GetValueForProperty("DefinitionDataSet",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).DefinitionDataSet, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDatasetTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).DefinitionType = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType) content.GetValueForProperty("DefinitionType",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).DefinitionType, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).DefinitionTimeframe = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType) content.GetValueForProperty("DefinitionTimeframe",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).DefinitionTimeframe, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).DeliveryInfoDestination = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestination) content.GetValueForProperty("DeliveryInfoDestination",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).DeliveryInfoDestination, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDeliveryDestinationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).DefinitionTimePeriod = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportTimePeriod) content.GetValueForProperty("DefinitionTimePeriod",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).DefinitionTimePeriod, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportTimePeriodTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).RunHistoryValue = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution[]) content.GetValueForProperty("RunHistoryValue",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).RunHistoryValue, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportExecutionTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).TimePeriodFrom = (global::System.DateTime) content.GetValueForProperty("TimePeriodFrom",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).TimePeriodFrom, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).DataSetGranularity = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType?) content.GetValueForProperty("DataSetGranularity",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).DataSetGranularity, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).DataSetConfiguration = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetConfiguration) content.GetValueForProperty("DataSetConfiguration",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).DataSetConfiguration, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDatasetConfigurationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).DestinationContainer = (string) content.GetValueForProperty("DestinationContainer",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).DestinationContainer, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).DestinationResourceId = (string) content.GetValueForProperty("DestinationResourceId",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).DestinationResourceId, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).DestinationRootFolderPath = (string) content.GetValueForProperty("DestinationRootFolderPath",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).DestinationRootFolderPath, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).TimePeriodTo = (global::System.DateTime) content.GetValueForProperty("TimePeriodTo",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).TimePeriodTo, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).ConfigurationColumn = (string[]) content.GetValueForProperty("ConfigurationColumn",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).ConfigurationColumn, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal ExportExecution(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).Property = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionProperties) content.GetValueForProperty("Property",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).Property, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportExecutionPropertiesTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Name, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Type = (string) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Type, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Id = (string) content.GetValueForProperty("Id",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Id, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Tag = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceTags) content.GetValueForProperty("Tag",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Tag, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ResourceTagsTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).ExecutionType = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionType?) content.GetValueForProperty("ExecutionType",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).ExecutionType, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).Error = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorDetails) content.GetValueForProperty("Error",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).Error, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ErrorDetailsTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).FileName = (string) content.GetValueForProperty("FileName",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).FileName, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).ProcessingEndTime = (global::System.DateTime?) content.GetValueForProperty("ProcessingEndTime",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).ProcessingEndTime, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).ProcessingStartTime = (global::System.DateTime?) content.GetValueForProperty("ProcessingStartTime",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).ProcessingStartTime, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).Status = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionStatus?) content.GetValueForProperty("Status",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).Status, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionStatus.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).SubmittedBy = (string) content.GetValueForProperty("SubmittedBy",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).SubmittedBy, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).SubmittedTime = (global::System.DateTime?) content.GetValueForProperty("SubmittedTime",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).SubmittedTime, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).RunSetting = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportProperties) content.GetValueForProperty("RunSetting",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).RunSetting, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.CommonExportPropertiesTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).Code = (string) content.GetValueForProperty("Code",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).Code, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).RunSettingDefinition = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinition) content.GetValueForProperty("RunSettingDefinition",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).RunSettingDefinition, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDefinitionTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).RunSettingDeliveryInfo = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfo) content.GetValueForProperty("RunSettingDeliveryInfo",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).RunSettingDeliveryInfo, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDeliveryInfoTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).RunSettingRunHistory = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionListResult) content.GetValueForProperty("RunSettingRunHistory",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).RunSettingRunHistory, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportExecutionListResultTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).RunSettingFormat = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType?) content.GetValueForProperty("RunSettingFormat",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).RunSettingFormat, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).RunSettingNextRunTimeEstimate = (global::System.DateTime?) content.GetValueForProperty("RunSettingNextRunTimeEstimate",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).RunSettingNextRunTimeEstimate, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).Message = (string) content.GetValueForProperty("Message",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).Message, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).DefinitionDataSet = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDataset) content.GetValueForProperty("DefinitionDataSet",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).DefinitionDataSet, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDatasetTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).DefinitionType = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType) content.GetValueForProperty("DefinitionType",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).DefinitionType, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).DefinitionTimeframe = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType) content.GetValueForProperty("DefinitionTimeframe",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).DefinitionTimeframe, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).DeliveryInfoDestination = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestination) content.GetValueForProperty("DeliveryInfoDestination",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).DeliveryInfoDestination, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDeliveryDestinationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).DefinitionTimePeriod = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportTimePeriod) content.GetValueForProperty("DefinitionTimePeriod",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).DefinitionTimePeriod, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportTimePeriodTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).RunHistoryValue = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution[]) content.GetValueForProperty("RunHistoryValue",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).RunHistoryValue, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportExecutionTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).TimePeriodFrom = (global::System.DateTime) content.GetValueForProperty("TimePeriodFrom",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).TimePeriodFrom, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).DataSetGranularity = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType?) content.GetValueForProperty("DataSetGranularity",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).DataSetGranularity, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).DataSetConfiguration = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetConfiguration) content.GetValueForProperty("DataSetConfiguration",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).DataSetConfiguration, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDatasetConfigurationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).DestinationContainer = (string) content.GetValueForProperty("DestinationContainer",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).DestinationContainer, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).DestinationResourceId = (string) content.GetValueForProperty("DestinationResourceId",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).DestinationResourceId, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).DestinationRootFolderPath = (string) content.GetValueForProperty("DestinationRootFolderPath",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).DestinationRootFolderPath, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).TimePeriodTo = (global::System.DateTime) content.GetValueForProperty("TimePeriodTo",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).TimePeriodTo, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).ConfigurationColumn = (string[]) content.GetValueForProperty("ConfigurationColumn",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal)this).ConfigurationColumn, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + AfterDeserializePSObject(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// An export execution. + [System.ComponentModel.TypeConverter(typeof(ExportExecutionTypeConverter))] + public partial interface IExportExecution + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportExecution.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportExecution.TypeConverter.cs new file mode 100644 index 000000000000..263d2b5cd238 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportExecution.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class ExportExecutionTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return ExportExecution.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return ExportExecution.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return ExportExecution.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportExecution.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportExecution.cs new file mode 100644 index 000000000000..4ff63f1eb0eb --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportExecution.cs @@ -0,0 +1,504 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// An export execution. + public partial class ExportExecution : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IValidates + { + /// + /// Backing field for Inherited model + /// + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResource __resource = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.Resource(); + + /// Error code. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.DoNotFormat] + public string Code { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).Code; } + + /// + /// Array of column names to be included in the export. If not provided then the export will include all available columns. + /// The available columns can vary by customer channel (see examples). + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.DoNotFormat] + public string[] ConfigurationColumn { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).ConfigurationColumn; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).ConfigurationColumn = value; } + + /// The granularity of rows in the export. Currently only 'Daily' is supported. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.DoNotFormat] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType? DataSetGranularity { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).DataSetGranularity; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).DataSetGranularity = value; } + + /// + /// The time frame for pulling data for the export. If custom, then a specific time period must be provided. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.DoNotFormat] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType DefinitionTimeframe { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).DefinitionTimeframe; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).DefinitionTimeframe = value; } + + /// + /// The type of the export. Note that 'Usage' is equivalent to 'ActualCost' and is applicable to exports that do not yet provide + /// data for charges or amortization for service reservations. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.DoNotFormat] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType DefinitionType { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).DefinitionType; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).DefinitionType = value; } + + /// The name of the container where exports will be uploaded. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.DoNotFormat] + public string DestinationContainer { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).DestinationContainer; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).DestinationContainer = value; } + + /// The resource id of the storage account where exports will be delivered. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.DoNotFormat] + public string DestinationResourceId { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).DestinationResourceId; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).DestinationResourceId = value; } + + /// The name of the directory where exports will be uploaded. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.DoNotFormat] + public string DestinationRootFolderPath { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).DestinationRootFolderPath; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).DestinationRootFolderPath = value; } + + /// The type of the export execution. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.FormatTable(Index = 0)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionType? ExecutionType { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).ExecutionType; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).ExecutionType = value; } + + /// The name of the exported file. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.FormatTable(Index = 5)] + public string FileName { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).FileName; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).FileName = value; } + + /// Resource Id. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inherited)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.DoNotFormat] + public string Id { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)__resource).Id; } + + /// Error message indicating why the operation failed. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.DoNotFormat] + public string Message { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).Message; } + + /// Internal Acessors for Code + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal.Code { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).Code; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).Code = value; } + + /// Internal Acessors for DataSetConfiguration + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetConfiguration Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal.DataSetConfiguration { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).DataSetConfiguration; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).DataSetConfiguration = value; } + + /// Internal Acessors for DefinitionDataSet + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDataset Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal.DefinitionDataSet { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).DefinitionDataSet; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).DefinitionDataSet = value; } + + /// Internal Acessors for DefinitionTimePeriod + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportTimePeriod Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal.DefinitionTimePeriod { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).DefinitionTimePeriod; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).DefinitionTimePeriod = value; } + + /// Internal Acessors for DeliveryInfoDestination + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestination Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal.DeliveryInfoDestination { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).DeliveryInfoDestination; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).DeliveryInfoDestination = value; } + + /// Internal Acessors for Error + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorDetails Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal.Error { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).Error; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).Error = value; } + + /// Internal Acessors for Message + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal.Message { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).Message; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).Message = value; } + + /// Internal Acessors for Property + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionProperties Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal.Property { get => (this._property = this._property ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportExecutionProperties()); set { {_property = value;} } } + + /// Internal Acessors for RunHistoryValue + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution[] Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal.RunHistoryValue { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).RunHistoryValue; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).RunHistoryValue = value; } + + /// Internal Acessors for RunSetting + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportProperties Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal.RunSetting { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).RunSetting; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).RunSetting = value; } + + /// Internal Acessors for RunSettingDefinition + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinition Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal.RunSettingDefinition { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).RunSettingDefinition; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).RunSettingDefinition = value; } + + /// Internal Acessors for RunSettingDeliveryInfo + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfo Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal.RunSettingDeliveryInfo { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).RunSettingDeliveryInfo; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).RunSettingDeliveryInfo = value; } + + /// Internal Acessors for RunSettingNextRunTimeEstimate + global::System.DateTime? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal.RunSettingNextRunTimeEstimate { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).RunSettingNextRunTimeEstimate; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).RunSettingNextRunTimeEstimate = value; } + + /// Internal Acessors for RunSettingRunHistory + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionListResult Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionInternal.RunSettingRunHistory { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).RunSettingRunHistory; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).RunSettingRunHistory = value; } + + /// Internal Acessors for Id + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal.Id { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)__resource).Id; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)__resource).Id = value; } + + /// Internal Acessors for Name + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal.Name { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)__resource).Name; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)__resource).Name = value; } + + /// Internal Acessors for Tag + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceTags Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal.Tag { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)__resource).Tag; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)__resource).Tag = value; } + + /// Internal Acessors for Type + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal.Type { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)__resource).Type; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)__resource).Type = value; } + + /// Resource name. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inherited)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.DoNotFormat] + public string Name { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)__resource).Name; } + + /// The time when the export execution finished. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.FormatTable(Index = 2)] + public global::System.DateTime? ProcessingEndTime { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).ProcessingEndTime; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).ProcessingEndTime = value; } + + /// The time when export was picked up to be executed. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.FormatTable(Index = 1)] + public global::System.DateTime? ProcessingStartTime { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).ProcessingStartTime; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).ProcessingStartTime = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionProperties _property; + + /// Export execution properties + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.DoNotFormat] + internal Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionProperties Property { get => (this._property = this._property ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportExecutionProperties()); set => this._property = value; } + + /// A list of export executions. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.DoNotFormat] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution[] RunHistoryValue { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).RunHistoryValue; } + + /// The format of the export being delivered. Currently only 'Csv' is supported. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.DoNotFormat] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType? RunSettingFormat { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).RunSettingFormat; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).RunSettingFormat = value; } + + /// + /// If the export has an active schedule, provides an estimate of the next execution time. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.DoNotFormat] + public global::System.DateTime? RunSettingNextRunTimeEstimate { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).RunSettingNextRunTimeEstimate; } + + /// The last known status of the export execution. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.FormatTable(Index = 4)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionStatus? Status { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).Status; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).Status = value; } + + /// + /// The identifier for the entity that executed the export. For OnDemand executions it is the user email. For scheduled executions + /// it is 'System'. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.DoNotFormat] + public string SubmittedBy { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).SubmittedBy; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).SubmittedBy = value; } + + /// The time when export was queued to be executed. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.DoNotFormat] + public global::System.DateTime? SubmittedTime { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).SubmittedTime; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).SubmittedTime = value; } + + /// Resource tags. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inherited)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.DoNotFormat] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceTags Tag { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)__resource).Tag; } + + /// The start date for export data. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.DoNotFormat] + public global::System.DateTime TimePeriodFrom { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).TimePeriodFrom; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).TimePeriodFrom = value; } + + /// The end date for export data. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.DoNotFormat] + public global::System.DateTime TimePeriodTo { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).TimePeriodTo; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)Property).TimePeriodTo = value; } + + /// Resource type. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inherited)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.DoNotFormat] + public string Type { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)__resource).Type; } + + /// Creates an new instance. + public ExportExecution() + { + + } + + /// Validates that this object meets the validation criteria. + /// an instance that will receive validation + /// events. + /// + /// A < see cref = "global::System.Threading.Tasks.Task" /> that will be complete when validation is completed. + /// + public async global::System.Threading.Tasks.Task Validate(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener) + { + await eventListener.AssertNotNull(nameof(__resource), __resource); + await eventListener.AssertObjectIsValid(nameof(__resource), __resource); + } + } + /// An export execution. + public partial interface IExportExecution : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResource + { + /// Error code. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"Error code.", + SerializedName = @"code", + PossibleTypes = new [] { typeof(string) })] + string Code { get; } + /// + /// Array of column names to be included in the export. If not provided then the export will include all available columns. + /// The available columns can vary by customer channel (see examples). + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Array of column names to be included in the export. If not provided then the export will include all available columns. The available columns can vary by customer channel (see examples).", + SerializedName = @"columns", + PossibleTypes = new [] { typeof(string) })] + string[] ConfigurationColumn { get; set; } + /// The granularity of rows in the export. Currently only 'Daily' is supported. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The granularity of rows in the export. Currently only 'Daily' is supported.", + SerializedName = @"granularity", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType? DataSetGranularity { get; set; } + /// + /// The time frame for pulling data for the export. If custom, then a specific time period must be provided. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The time frame for pulling data for the export. If custom, then a specific time period must be provided.", + SerializedName = @"timeframe", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType DefinitionTimeframe { get; set; } + /// + /// The type of the export. Note that 'Usage' is equivalent to 'ActualCost' and is applicable to exports that do not yet provide + /// data for charges or amortization for service reservations. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The type of the export. Note that 'Usage' is equivalent to 'ActualCost' and is applicable to exports that do not yet provide data for charges or amortization for service reservations.", + SerializedName = @"type", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType DefinitionType { get; set; } + /// The name of the container where exports will be uploaded. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The name of the container where exports will be uploaded.", + SerializedName = @"container", + PossibleTypes = new [] { typeof(string) })] + string DestinationContainer { get; set; } + /// The resource id of the storage account where exports will be delivered. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The resource id of the storage account where exports will be delivered.", + SerializedName = @"resourceId", + PossibleTypes = new [] { typeof(string) })] + string DestinationResourceId { get; set; } + /// The name of the directory where exports will be uploaded. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The name of the directory where exports will be uploaded.", + SerializedName = @"rootFolderPath", + PossibleTypes = new [] { typeof(string) })] + string DestinationRootFolderPath { get; set; } + /// The type of the export execution. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The type of the export execution.", + SerializedName = @"executionType", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionType? ExecutionType { get; set; } + /// The name of the exported file. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The name of the exported file.", + SerializedName = @"fileName", + PossibleTypes = new [] { typeof(string) })] + string FileName { get; set; } + /// Error message indicating why the operation failed. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"Error message indicating why the operation failed.", + SerializedName = @"message", + PossibleTypes = new [] { typeof(string) })] + string Message { get; } + /// The time when the export execution finished. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The time when the export execution finished.", + SerializedName = @"processingEndTime", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime? ProcessingEndTime { get; set; } + /// The time when export was picked up to be executed. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The time when export was picked up to be executed.", + SerializedName = @"processingStartTime", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime? ProcessingStartTime { get; set; } + /// A list of export executions. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"A list of export executions.", + SerializedName = @"value", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution[] RunHistoryValue { get; } + /// The format of the export being delivered. Currently only 'Csv' is supported. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The format of the export being delivered. Currently only 'Csv' is supported.", + SerializedName = @"format", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType? RunSettingFormat { get; set; } + /// + /// If the export has an active schedule, provides an estimate of the next execution time. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"If the export has an active schedule, provides an estimate of the next execution time.", + SerializedName = @"nextRunTimeEstimate", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime? RunSettingNextRunTimeEstimate { get; } + /// The last known status of the export execution. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The last known status of the export execution.", + SerializedName = @"status", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionStatus) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionStatus? Status { get; set; } + /// + /// The identifier for the entity that executed the export. For OnDemand executions it is the user email. For scheduled executions + /// it is 'System'. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The identifier for the entity that executed the export. For OnDemand executions it is the user email. For scheduled executions it is 'System'.", + SerializedName = @"submittedBy", + PossibleTypes = new [] { typeof(string) })] + string SubmittedBy { get; set; } + /// The time when export was queued to be executed. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The time when export was queued to be executed.", + SerializedName = @"submittedTime", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime? SubmittedTime { get; set; } + /// The start date for export data. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The start date for export data.", + SerializedName = @"from", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime TimePeriodFrom { get; set; } + /// The end date for export data. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The end date for export data.", + SerializedName = @"to", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime TimePeriodTo { get; set; } + + } + /// An export execution. + public partial interface IExportExecutionInternal : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal + { + /// Error code. + string Code { get; set; } + /// + /// Array of column names to be included in the export. If not provided then the export will include all available columns. + /// The available columns can vary by customer channel (see examples). + /// + string[] ConfigurationColumn { get; set; } + /// The export dataset configuration. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetConfiguration DataSetConfiguration { get; set; } + /// The granularity of rows in the export. Currently only 'Daily' is supported. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType? DataSetGranularity { get; set; } + /// The definition for data in the export. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDataset DefinitionDataSet { get; set; } + /// Has time period for pulling data for the export. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportTimePeriod DefinitionTimePeriod { get; set; } + /// + /// The time frame for pulling data for the export. If custom, then a specific time period must be provided. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType DefinitionTimeframe { get; set; } + /// + /// The type of the export. Note that 'Usage' is equivalent to 'ActualCost' and is applicable to exports that do not yet provide + /// data for charges or amortization for service reservations. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType DefinitionType { get; set; } + /// Has destination for the export being delivered. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestination DeliveryInfoDestination { get; set; } + /// The name of the container where exports will be uploaded. + string DestinationContainer { get; set; } + /// The resource id of the storage account where exports will be delivered. + string DestinationResourceId { get; set; } + /// The name of the directory where exports will be uploaded. + string DestinationRootFolderPath { get; set; } + /// The details of any error. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorDetails Error { get; set; } + /// The type of the export execution. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionType? ExecutionType { get; set; } + /// The name of the exported file. + string FileName { get; set; } + /// Error message indicating why the operation failed. + string Message { get; set; } + /// The time when the export execution finished. + global::System.DateTime? ProcessingEndTime { get; set; } + /// The time when export was picked up to be executed. + global::System.DateTime? ProcessingStartTime { get; set; } + /// Export execution properties + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionProperties Property { get; set; } + /// A list of export executions. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution[] RunHistoryValue { get; set; } + /// The export settings that were in effect for this execution. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportProperties RunSetting { get; set; } + /// Has the definition for the export. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinition RunSettingDefinition { get; set; } + /// Has delivery information for the export. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfo RunSettingDeliveryInfo { get; set; } + /// The format of the export being delivered. Currently only 'Csv' is supported. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType? RunSettingFormat { get; set; } + /// + /// If the export has an active schedule, provides an estimate of the next execution time. + /// + global::System.DateTime? RunSettingNextRunTimeEstimate { get; set; } + /// If requested, has the most recent execution history for the export. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionListResult RunSettingRunHistory { get; set; } + /// The last known status of the export execution. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionStatus? Status { get; set; } + /// + /// The identifier for the entity that executed the export. For OnDemand executions it is the user email. For scheduled executions + /// it is 'System'. + /// + string SubmittedBy { get; set; } + /// The time when export was queued to be executed. + global::System.DateTime? SubmittedTime { get; set; } + /// The start date for export data. + global::System.DateTime TimePeriodFrom { get; set; } + /// The end date for export data. + global::System.DateTime TimePeriodTo { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportExecution.json.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportExecution.json.cs new file mode 100644 index 000000000000..adc7c3c6dcbc --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportExecution.json.cs @@ -0,0 +1,103 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// An export execution. + public partial class ExportExecution + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal ExportExecution(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + __resource = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.Resource(json); + {_property = If( json?.PropertyT("properties"), out var __jsonProperties) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportExecutionProperties.FromJson(__jsonProperties) : Property;} + AfterFromJson(json); + } + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new ExportExecution(json) : null; + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + __resource?.ToJson(container, serializationMode); + AddIf( null != this._property ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._property.ToJson(null,serializationMode) : null, "properties" ,container.Add ); + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportExecutionListResult.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportExecutionListResult.PowerShell.cs new file mode 100644 index 000000000000..03dfb4da655a --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportExecutionListResult.PowerShell.cs @@ -0,0 +1,133 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// Result of listing the execution history of an export. + [System.ComponentModel.TypeConverter(typeof(ExportExecutionListResultTypeConverter))] + public partial class ExportExecutionListResult + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionListResult DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new ExportExecutionListResult(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionListResult DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new ExportExecutionListResult(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal ExportExecutionListResult(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionListResultInternal)this).Value = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution[]) content.GetValueForProperty("Value",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionListResultInternal)this).Value, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportExecutionTypeConverter.ConvertFrom)); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal ExportExecutionListResult(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionListResultInternal)this).Value = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution[]) content.GetValueForProperty("Value",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionListResultInternal)this).Value, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportExecutionTypeConverter.ConvertFrom)); + AfterDeserializePSObject(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionListResult FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// Result of listing the execution history of an export. + [System.ComponentModel.TypeConverter(typeof(ExportExecutionListResultTypeConverter))] + public partial interface IExportExecutionListResult + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportExecutionListResult.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportExecutionListResult.TypeConverter.cs new file mode 100644 index 000000000000..dd602a84416a --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportExecutionListResult.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class ExportExecutionListResultTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionListResult ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionListResult).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return ExportExecutionListResult.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return ExportExecutionListResult.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return ExportExecutionListResult.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportExecutionListResult.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportExecutionListResult.cs new file mode 100644 index 000000000000..75ec1783cee7 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportExecutionListResult.cs @@ -0,0 +1,49 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// Result of listing the execution history of an export. + public partial class ExportExecutionListResult : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionListResult, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionListResultInternal + { + + /// Internal Acessors for Value + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution[] Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionListResultInternal.Value { get => this._value; set { {_value = value;} } } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution[] _value; + + /// A list of export executions. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution[] Value { get => this._value; } + + /// Creates an new instance. + public ExportExecutionListResult() + { + + } + } + /// Result of listing the execution history of an export. + public partial interface IExportExecutionListResult : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// A list of export executions. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"A list of export executions.", + SerializedName = @"value", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution[] Value { get; } + + } + /// Result of listing the execution history of an export. + public partial interface IExportExecutionListResultInternal + + { + /// A list of export executions. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution[] Value { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportExecutionListResult.json.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportExecutionListResult.json.cs new file mode 100644 index 000000000000..ce7966292e94 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportExecutionListResult.json.cs @@ -0,0 +1,112 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// Result of listing the execution history of an export. + public partial class ExportExecutionListResult + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal ExportExecutionListResult(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_value = If( json?.PropertyT("value"), out var __jsonValue) ? If( __jsonValue as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonArray, out var __v) ? new global::System.Func(()=> global::System.Linq.Enumerable.ToArray(global::System.Linq.Enumerable.Select(__v, (__u)=>(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution) (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportExecution.FromJson(__u) )) ))() : null : Value;} + AfterFromJson(json); + } + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionListResult. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionListResult. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionListResult FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new ExportExecutionListResult(json) : null; + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeReadOnly)) + { + if (null != this._value) + { + var __w = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.XNodeArray(); + foreach( var __x in this._value ) + { + AddIf(__x?.ToJson(null, serializationMode) ,__w.Add); + } + container.Add("value",__w); + } + } + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportExecutionProperties.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportExecutionProperties.PowerShell.cs new file mode 100644 index 000000000000..88921936a0b7 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportExecutionProperties.PowerShell.cs @@ -0,0 +1,191 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// The properties of the export execution. + [System.ComponentModel.TypeConverter(typeof(ExportExecutionPropertiesTypeConverter))] + public partial class ExportExecutionProperties + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionProperties DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new ExportExecutionProperties(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionProperties DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new ExportExecutionProperties(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal ExportExecutionProperties(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).Error = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorDetails) content.GetValueForProperty("Error",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).Error, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ErrorDetailsTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).RunSetting = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportProperties) content.GetValueForProperty("RunSetting",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).RunSetting, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.CommonExportPropertiesTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).ExecutionType = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionType?) content.GetValueForProperty("ExecutionType",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).ExecutionType, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).FileName = (string) content.GetValueForProperty("FileName",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).FileName, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).ProcessingEndTime = (global::System.DateTime?) content.GetValueForProperty("ProcessingEndTime",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).ProcessingEndTime, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).ProcessingStartTime = (global::System.DateTime?) content.GetValueForProperty("ProcessingStartTime",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).ProcessingStartTime, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).Status = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionStatus?) content.GetValueForProperty("Status",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).Status, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionStatus.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).SubmittedBy = (string) content.GetValueForProperty("SubmittedBy",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).SubmittedBy, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).SubmittedTime = (global::System.DateTime?) content.GetValueForProperty("SubmittedTime",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).SubmittedTime, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).Code = (string) content.GetValueForProperty("Code",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).Code, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).RunSettingDefinition = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinition) content.GetValueForProperty("RunSettingDefinition",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).RunSettingDefinition, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDefinitionTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).RunSettingDeliveryInfo = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfo) content.GetValueForProperty("RunSettingDeliveryInfo",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).RunSettingDeliveryInfo, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDeliveryInfoTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).RunSettingRunHistory = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionListResult) content.GetValueForProperty("RunSettingRunHistory",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).RunSettingRunHistory, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportExecutionListResultTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).RunSettingFormat = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType?) content.GetValueForProperty("RunSettingFormat",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).RunSettingFormat, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).RunSettingNextRunTimeEstimate = (global::System.DateTime?) content.GetValueForProperty("RunSettingNextRunTimeEstimate",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).RunSettingNextRunTimeEstimate, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).Message = (string) content.GetValueForProperty("Message",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).Message, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).DefinitionDataSet = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDataset) content.GetValueForProperty("DefinitionDataSet",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).DefinitionDataSet, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDatasetTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).RunHistoryValue = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution[]) content.GetValueForProperty("RunHistoryValue",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).RunHistoryValue, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportExecutionTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).DefinitionType = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType) content.GetValueForProperty("DefinitionType",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).DefinitionType, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).DefinitionTimeframe = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType) content.GetValueForProperty("DefinitionTimeframe",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).DefinitionTimeframe, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).DeliveryInfoDestination = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestination) content.GetValueForProperty("DeliveryInfoDestination",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).DeliveryInfoDestination, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDeliveryDestinationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).DefinitionTimePeriod = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportTimePeriod) content.GetValueForProperty("DefinitionTimePeriod",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).DefinitionTimePeriod, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportTimePeriodTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).TimePeriodFrom = (global::System.DateTime) content.GetValueForProperty("TimePeriodFrom",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).TimePeriodFrom, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).DataSetGranularity = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType?) content.GetValueForProperty("DataSetGranularity",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).DataSetGranularity, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).DataSetConfiguration = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetConfiguration) content.GetValueForProperty("DataSetConfiguration",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).DataSetConfiguration, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDatasetConfigurationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).DestinationContainer = (string) content.GetValueForProperty("DestinationContainer",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).DestinationContainer, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).DestinationResourceId = (string) content.GetValueForProperty("DestinationResourceId",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).DestinationResourceId, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).DestinationRootFolderPath = (string) content.GetValueForProperty("DestinationRootFolderPath",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).DestinationRootFolderPath, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).TimePeriodTo = (global::System.DateTime) content.GetValueForProperty("TimePeriodTo",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).TimePeriodTo, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).ConfigurationColumn = (string[]) content.GetValueForProperty("ConfigurationColumn",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).ConfigurationColumn, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal ExportExecutionProperties(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).Error = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorDetails) content.GetValueForProperty("Error",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).Error, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ErrorDetailsTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).RunSetting = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportProperties) content.GetValueForProperty("RunSetting",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).RunSetting, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.CommonExportPropertiesTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).ExecutionType = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionType?) content.GetValueForProperty("ExecutionType",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).ExecutionType, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).FileName = (string) content.GetValueForProperty("FileName",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).FileName, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).ProcessingEndTime = (global::System.DateTime?) content.GetValueForProperty("ProcessingEndTime",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).ProcessingEndTime, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).ProcessingStartTime = (global::System.DateTime?) content.GetValueForProperty("ProcessingStartTime",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).ProcessingStartTime, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).Status = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionStatus?) content.GetValueForProperty("Status",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).Status, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionStatus.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).SubmittedBy = (string) content.GetValueForProperty("SubmittedBy",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).SubmittedBy, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).SubmittedTime = (global::System.DateTime?) content.GetValueForProperty("SubmittedTime",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).SubmittedTime, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).Code = (string) content.GetValueForProperty("Code",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).Code, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).RunSettingDefinition = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinition) content.GetValueForProperty("RunSettingDefinition",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).RunSettingDefinition, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDefinitionTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).RunSettingDeliveryInfo = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfo) content.GetValueForProperty("RunSettingDeliveryInfo",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).RunSettingDeliveryInfo, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDeliveryInfoTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).RunSettingRunHistory = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionListResult) content.GetValueForProperty("RunSettingRunHistory",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).RunSettingRunHistory, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportExecutionListResultTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).RunSettingFormat = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType?) content.GetValueForProperty("RunSettingFormat",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).RunSettingFormat, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).RunSettingNextRunTimeEstimate = (global::System.DateTime?) content.GetValueForProperty("RunSettingNextRunTimeEstimate",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).RunSettingNextRunTimeEstimate, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).Message = (string) content.GetValueForProperty("Message",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).Message, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).DefinitionDataSet = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDataset) content.GetValueForProperty("DefinitionDataSet",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).DefinitionDataSet, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDatasetTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).RunHistoryValue = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution[]) content.GetValueForProperty("RunHistoryValue",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).RunHistoryValue, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportExecutionTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).DefinitionType = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType) content.GetValueForProperty("DefinitionType",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).DefinitionType, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).DefinitionTimeframe = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType) content.GetValueForProperty("DefinitionTimeframe",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).DefinitionTimeframe, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).DeliveryInfoDestination = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestination) content.GetValueForProperty("DeliveryInfoDestination",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).DeliveryInfoDestination, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDeliveryDestinationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).DefinitionTimePeriod = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportTimePeriod) content.GetValueForProperty("DefinitionTimePeriod",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).DefinitionTimePeriod, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportTimePeriodTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).TimePeriodFrom = (global::System.DateTime) content.GetValueForProperty("TimePeriodFrom",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).TimePeriodFrom, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).DataSetGranularity = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType?) content.GetValueForProperty("DataSetGranularity",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).DataSetGranularity, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).DataSetConfiguration = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetConfiguration) content.GetValueForProperty("DataSetConfiguration",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).DataSetConfiguration, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDatasetConfigurationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).DestinationContainer = (string) content.GetValueForProperty("DestinationContainer",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).DestinationContainer, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).DestinationResourceId = (string) content.GetValueForProperty("DestinationResourceId",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).DestinationResourceId, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).DestinationRootFolderPath = (string) content.GetValueForProperty("DestinationRootFolderPath",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).DestinationRootFolderPath, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).TimePeriodTo = (global::System.DateTime) content.GetValueForProperty("TimePeriodTo",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).TimePeriodTo, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).ConfigurationColumn = (string[]) content.GetValueForProperty("ConfigurationColumn",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal)this).ConfigurationColumn, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + AfterDeserializePSObject(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionProperties FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// The properties of the export execution. + [System.ComponentModel.TypeConverter(typeof(ExportExecutionPropertiesTypeConverter))] + public partial interface IExportExecutionProperties + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportExecutionProperties.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportExecutionProperties.TypeConverter.cs new file mode 100644 index 000000000000..f162572e670e --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportExecutionProperties.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class ExportExecutionPropertiesTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionProperties ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionProperties).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return ExportExecutionProperties.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return ExportExecutionProperties.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return ExportExecutionProperties.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportExecutionProperties.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportExecutionProperties.cs new file mode 100644 index 000000000000..9eb0efe6eb2f --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportExecutionProperties.cs @@ -0,0 +1,454 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The properties of the export execution. + public partial class ExportExecutionProperties : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionProperties, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal + { + + /// Error code. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string Code { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorDetailsInternal)Error).Code; } + + /// + /// Array of column names to be included in the export. If not provided then the export will include all available columns. + /// The available columns can vary by customer channel (see examples). + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string[] ConfigurationColumn { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)RunSetting).ConfigurationColumn; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)RunSetting).ConfigurationColumn = value; } + + /// The granularity of rows in the export. Currently only 'Daily' is supported. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType? DataSetGranularity { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)RunSetting).DataSetGranularity; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)RunSetting).DataSetGranularity = value; } + + /// + /// The time frame for pulling data for the export. If custom, then a specific time period must be provided. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType DefinitionTimeframe { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)RunSetting).DefinitionTimeframe; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)RunSetting).DefinitionTimeframe = value; } + + /// + /// The type of the export. Note that 'Usage' is equivalent to 'ActualCost' and is applicable to exports that do not yet provide + /// data for charges or amortization for service reservations. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType DefinitionType { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)RunSetting).DefinitionType; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)RunSetting).DefinitionType = value; } + + /// The name of the container where exports will be uploaded. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string DestinationContainer { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)RunSetting).DestinationContainer; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)RunSetting).DestinationContainer = value; } + + /// The resource id of the storage account where exports will be delivered. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string DestinationResourceId { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)RunSetting).DestinationResourceId; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)RunSetting).DestinationResourceId = value; } + + /// The name of the directory where exports will be uploaded. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string DestinationRootFolderPath { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)RunSetting).DestinationRootFolderPath; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)RunSetting).DestinationRootFolderPath = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorDetails _error; + + /// The details of any error. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + internal Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorDetails Error { get => (this._error = this._error ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ErrorDetails()); set => this._error = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionType? _executionType; + + /// The type of the export execution. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionType? ExecutionType { get => this._executionType; set => this._executionType = value; } + + /// Backing field for property. + private string _fileName; + + /// The name of the exported file. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string FileName { get => this._fileName; set => this._fileName = value; } + + /// Error message indicating why the operation failed. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string Message { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorDetailsInternal)Error).Message; } + + /// Internal Acessors for Code + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal.Code { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorDetailsInternal)Error).Code; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorDetailsInternal)Error).Code = value; } + + /// Internal Acessors for DataSetConfiguration + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetConfiguration Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal.DataSetConfiguration { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)RunSetting).DataSetConfiguration; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)RunSetting).DataSetConfiguration = value; } + + /// Internal Acessors for DefinitionDataSet + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDataset Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal.DefinitionDataSet { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)RunSetting).DefinitionDataSet; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)RunSetting).DefinitionDataSet = value; } + + /// Internal Acessors for DefinitionTimePeriod + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportTimePeriod Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal.DefinitionTimePeriod { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)RunSetting).DefinitionTimePeriod; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)RunSetting).DefinitionTimePeriod = value; } + + /// Internal Acessors for DeliveryInfoDestination + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestination Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal.DeliveryInfoDestination { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)RunSetting).DeliveryInfoDestination; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)RunSetting).DeliveryInfoDestination = value; } + + /// Internal Acessors for Error + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorDetails Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal.Error { get => (this._error = this._error ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ErrorDetails()); set { {_error = value;} } } + + /// Internal Acessors for Message + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal.Message { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorDetailsInternal)Error).Message; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorDetailsInternal)Error).Message = value; } + + /// Internal Acessors for RunHistoryValue + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution[] Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal.RunHistoryValue { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)RunSetting).RunHistoryValue; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)RunSetting).RunHistoryValue = value; } + + /// Internal Acessors for RunSetting + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportProperties Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal.RunSetting { get => (this._runSetting = this._runSetting ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.CommonExportProperties()); set { {_runSetting = value;} } } + + /// Internal Acessors for RunSettingDefinition + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinition Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal.RunSettingDefinition { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)RunSetting).Definition; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)RunSetting).Definition = value; } + + /// Internal Acessors for RunSettingDeliveryInfo + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfo Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal.RunSettingDeliveryInfo { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)RunSetting).DeliveryInfo; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)RunSetting).DeliveryInfo = value; } + + /// Internal Acessors for RunSettingNextRunTimeEstimate + global::System.DateTime? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal.RunSettingNextRunTimeEstimate { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)RunSetting).NextRunTimeEstimate; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)RunSetting).NextRunTimeEstimate = value; } + + /// Internal Acessors for RunSettingRunHistory + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionListResult Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionPropertiesInternal.RunSettingRunHistory { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)RunSetting).RunHistory; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)RunSetting).RunHistory = value; } + + /// Backing field for property. + private global::System.DateTime? _processingEndTime; + + /// The time when the export execution finished. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public global::System.DateTime? ProcessingEndTime { get => this._processingEndTime; set => this._processingEndTime = value; } + + /// Backing field for property. + private global::System.DateTime? _processingStartTime; + + /// The time when export was picked up to be executed. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public global::System.DateTime? ProcessingStartTime { get => this._processingStartTime; set => this._processingStartTime = value; } + + /// A list of export executions. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution[] RunHistoryValue { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)RunSetting).RunHistoryValue; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportProperties _runSetting; + + /// The export settings that were in effect for this execution. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + internal Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportProperties RunSetting { get => (this._runSetting = this._runSetting ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.CommonExportProperties()); set => this._runSetting = value; } + + /// The format of the export being delivered. Currently only 'Csv' is supported. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType? RunSettingFormat { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)RunSetting).Format; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)RunSetting).Format = value; } + + /// + /// If the export has an active schedule, provides an estimate of the next execution time. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public global::System.DateTime? RunSettingNextRunTimeEstimate { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)RunSetting).NextRunTimeEstimate; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionStatus? _status; + + /// The last known status of the export execution. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionStatus? Status { get => this._status; set => this._status = value; } + + /// Backing field for property. + private string _submittedBy; + + /// + /// The identifier for the entity that executed the export. For OnDemand executions it is the user email. For scheduled executions + /// it is 'System'. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string SubmittedBy { get => this._submittedBy; set => this._submittedBy = value; } + + /// Backing field for property. + private global::System.DateTime? _submittedTime; + + /// The time when export was queued to be executed. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public global::System.DateTime? SubmittedTime { get => this._submittedTime; set => this._submittedTime = value; } + + /// The start date for export data. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public global::System.DateTime TimePeriodFrom { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)RunSetting).TimePeriodFrom; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)RunSetting).TimePeriodFrom = value; } + + /// The end date for export data. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public global::System.DateTime TimePeriodTo { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)RunSetting).TimePeriodTo; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)RunSetting).TimePeriodTo = value; } + + /// Creates an new instance. + public ExportExecutionProperties() + { + + } + } + /// The properties of the export execution. + public partial interface IExportExecutionProperties : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// Error code. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"Error code.", + SerializedName = @"code", + PossibleTypes = new [] { typeof(string) })] + string Code { get; } + /// + /// Array of column names to be included in the export. If not provided then the export will include all available columns. + /// The available columns can vary by customer channel (see examples). + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Array of column names to be included in the export. If not provided then the export will include all available columns. The available columns can vary by customer channel (see examples).", + SerializedName = @"columns", + PossibleTypes = new [] { typeof(string) })] + string[] ConfigurationColumn { get; set; } + /// The granularity of rows in the export. Currently only 'Daily' is supported. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The granularity of rows in the export. Currently only 'Daily' is supported.", + SerializedName = @"granularity", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType? DataSetGranularity { get; set; } + /// + /// The time frame for pulling data for the export. If custom, then a specific time period must be provided. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The time frame for pulling data for the export. If custom, then a specific time period must be provided.", + SerializedName = @"timeframe", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType DefinitionTimeframe { get; set; } + /// + /// The type of the export. Note that 'Usage' is equivalent to 'ActualCost' and is applicable to exports that do not yet provide + /// data for charges or amortization for service reservations. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The type of the export. Note that 'Usage' is equivalent to 'ActualCost' and is applicable to exports that do not yet provide data for charges or amortization for service reservations.", + SerializedName = @"type", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType DefinitionType { get; set; } + /// The name of the container where exports will be uploaded. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The name of the container where exports will be uploaded.", + SerializedName = @"container", + PossibleTypes = new [] { typeof(string) })] + string DestinationContainer { get; set; } + /// The resource id of the storage account where exports will be delivered. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The resource id of the storage account where exports will be delivered.", + SerializedName = @"resourceId", + PossibleTypes = new [] { typeof(string) })] + string DestinationResourceId { get; set; } + /// The name of the directory where exports will be uploaded. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The name of the directory where exports will be uploaded.", + SerializedName = @"rootFolderPath", + PossibleTypes = new [] { typeof(string) })] + string DestinationRootFolderPath { get; set; } + /// The type of the export execution. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The type of the export execution.", + SerializedName = @"executionType", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionType? ExecutionType { get; set; } + /// The name of the exported file. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The name of the exported file.", + SerializedName = @"fileName", + PossibleTypes = new [] { typeof(string) })] + string FileName { get; set; } + /// Error message indicating why the operation failed. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"Error message indicating why the operation failed.", + SerializedName = @"message", + PossibleTypes = new [] { typeof(string) })] + string Message { get; } + /// The time when the export execution finished. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The time when the export execution finished.", + SerializedName = @"processingEndTime", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime? ProcessingEndTime { get; set; } + /// The time when export was picked up to be executed. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The time when export was picked up to be executed.", + SerializedName = @"processingStartTime", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime? ProcessingStartTime { get; set; } + /// A list of export executions. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"A list of export executions.", + SerializedName = @"value", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution[] RunHistoryValue { get; } + /// The format of the export being delivered. Currently only 'Csv' is supported. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The format of the export being delivered. Currently only 'Csv' is supported.", + SerializedName = @"format", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType? RunSettingFormat { get; set; } + /// + /// If the export has an active schedule, provides an estimate of the next execution time. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"If the export has an active schedule, provides an estimate of the next execution time.", + SerializedName = @"nextRunTimeEstimate", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime? RunSettingNextRunTimeEstimate { get; } + /// The last known status of the export execution. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The last known status of the export execution.", + SerializedName = @"status", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionStatus) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionStatus? Status { get; set; } + /// + /// The identifier for the entity that executed the export. For OnDemand executions it is the user email. For scheduled executions + /// it is 'System'. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The identifier for the entity that executed the export. For OnDemand executions it is the user email. For scheduled executions it is 'System'.", + SerializedName = @"submittedBy", + PossibleTypes = new [] { typeof(string) })] + string SubmittedBy { get; set; } + /// The time when export was queued to be executed. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The time when export was queued to be executed.", + SerializedName = @"submittedTime", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime? SubmittedTime { get; set; } + /// The start date for export data. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The start date for export data.", + SerializedName = @"from", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime TimePeriodFrom { get; set; } + /// The end date for export data. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The end date for export data.", + SerializedName = @"to", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime TimePeriodTo { get; set; } + + } + /// The properties of the export execution. + public partial interface IExportExecutionPropertiesInternal + + { + /// Error code. + string Code { get; set; } + /// + /// Array of column names to be included in the export. If not provided then the export will include all available columns. + /// The available columns can vary by customer channel (see examples). + /// + string[] ConfigurationColumn { get; set; } + /// The export dataset configuration. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetConfiguration DataSetConfiguration { get; set; } + /// The granularity of rows in the export. Currently only 'Daily' is supported. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType? DataSetGranularity { get; set; } + /// The definition for data in the export. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDataset DefinitionDataSet { get; set; } + /// Has time period for pulling data for the export. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportTimePeriod DefinitionTimePeriod { get; set; } + /// + /// The time frame for pulling data for the export. If custom, then a specific time period must be provided. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType DefinitionTimeframe { get; set; } + /// + /// The type of the export. Note that 'Usage' is equivalent to 'ActualCost' and is applicable to exports that do not yet provide + /// data for charges or amortization for service reservations. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType DefinitionType { get; set; } + /// Has destination for the export being delivered. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestination DeliveryInfoDestination { get; set; } + /// The name of the container where exports will be uploaded. + string DestinationContainer { get; set; } + /// The resource id of the storage account where exports will be delivered. + string DestinationResourceId { get; set; } + /// The name of the directory where exports will be uploaded. + string DestinationRootFolderPath { get; set; } + /// The details of any error. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IErrorDetails Error { get; set; } + /// The type of the export execution. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionType? ExecutionType { get; set; } + /// The name of the exported file. + string FileName { get; set; } + /// Error message indicating why the operation failed. + string Message { get; set; } + /// The time when the export execution finished. + global::System.DateTime? ProcessingEndTime { get; set; } + /// The time when export was picked up to be executed. + global::System.DateTime? ProcessingStartTime { get; set; } + /// A list of export executions. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution[] RunHistoryValue { get; set; } + /// The export settings that were in effect for this execution. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportProperties RunSetting { get; set; } + /// Has the definition for the export. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinition RunSettingDefinition { get; set; } + /// Has delivery information for the export. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfo RunSettingDeliveryInfo { get; set; } + /// The format of the export being delivered. Currently only 'Csv' is supported. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType? RunSettingFormat { get; set; } + /// + /// If the export has an active schedule, provides an estimate of the next execution time. + /// + global::System.DateTime? RunSettingNextRunTimeEstimate { get; set; } + /// If requested, has the most recent execution history for the export. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionListResult RunSettingRunHistory { get; set; } + /// The last known status of the export execution. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionStatus? Status { get; set; } + /// + /// The identifier for the entity that executed the export. For OnDemand executions it is the user email. For scheduled executions + /// it is 'System'. + /// + string SubmittedBy { get; set; } + /// The time when export was queued to be executed. + global::System.DateTime? SubmittedTime { get; set; } + /// The start date for export data. + global::System.DateTime TimePeriodFrom { get; set; } + /// The end date for export data. + global::System.DateTime TimePeriodTo { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportExecutionProperties.json.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportExecutionProperties.json.cs new file mode 100644 index 000000000000..d05ce7204a76 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportExecutionProperties.json.cs @@ -0,0 +1,117 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The properties of the export execution. + public partial class ExportExecutionProperties + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal ExportExecutionProperties(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_error = If( json?.PropertyT("error"), out var __jsonError) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ErrorDetails.FromJson(__jsonError) : Error;} + {_runSetting = If( json?.PropertyT("runSettings"), out var __jsonRunSettings) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.CommonExportProperties.FromJson(__jsonRunSettings) : RunSetting;} + {_executionType = If( json?.PropertyT("executionType"), out var __jsonExecutionType) ? (string)__jsonExecutionType : (string)ExecutionType;} + {_fileName = If( json?.PropertyT("fileName"), out var __jsonFileName) ? (string)__jsonFileName : (string)FileName;} + {_processingEndTime = If( json?.PropertyT("processingEndTime"), out var __jsonProcessingEndTime) ? global::System.DateTime.TryParse((string)__jsonProcessingEndTime, global::System.Globalization.CultureInfo.InvariantCulture, global::System.Globalization.DateTimeStyles.AdjustToUniversal, out var __jsonProcessingEndTimeValue) ? __jsonProcessingEndTimeValue : ProcessingEndTime : ProcessingEndTime;} + {_processingStartTime = If( json?.PropertyT("processingStartTime"), out var __jsonProcessingStartTime) ? global::System.DateTime.TryParse((string)__jsonProcessingStartTime, global::System.Globalization.CultureInfo.InvariantCulture, global::System.Globalization.DateTimeStyles.AdjustToUniversal, out var __jsonProcessingStartTimeValue) ? __jsonProcessingStartTimeValue : ProcessingStartTime : ProcessingStartTime;} + {_status = If( json?.PropertyT("status"), out var __jsonStatus) ? (string)__jsonStatus : (string)Status;} + {_submittedBy = If( json?.PropertyT("submittedBy"), out var __jsonSubmittedBy) ? (string)__jsonSubmittedBy : (string)SubmittedBy;} + {_submittedTime = If( json?.PropertyT("submittedTime"), out var __jsonSubmittedTime) ? global::System.DateTime.TryParse((string)__jsonSubmittedTime, global::System.Globalization.CultureInfo.InvariantCulture, global::System.Globalization.DateTimeStyles.AdjustToUniversal, out var __jsonSubmittedTimeValue) ? __jsonSubmittedTimeValue : SubmittedTime : SubmittedTime;} + AfterFromJson(json); + } + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionProperties. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionProperties. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionProperties FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new ExportExecutionProperties(json) : null; + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + AddIf( null != this._error ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._error.ToJson(null,serializationMode) : null, "error" ,container.Add ); + AddIf( null != this._runSetting ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._runSetting.ToJson(null,serializationMode) : null, "runSettings" ,container.Add ); + AddIf( null != (((object)this._executionType)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._executionType.ToString()) : null, "executionType" ,container.Add ); + AddIf( null != (((object)this._fileName)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._fileName.ToString()) : null, "fileName" ,container.Add ); + AddIf( null != this._processingEndTime ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._processingEndTime?.ToString(@"yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK",global::System.Globalization.CultureInfo.InvariantCulture)) : null, "processingEndTime" ,container.Add ); + AddIf( null != this._processingStartTime ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._processingStartTime?.ToString(@"yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK",global::System.Globalization.CultureInfo.InvariantCulture)) : null, "processingStartTime" ,container.Add ); + AddIf( null != (((object)this._status)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._status.ToString()) : null, "status" ,container.Add ); + AddIf( null != (((object)this._submittedBy)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._submittedBy.ToString()) : null, "submittedBy" ,container.Add ); + AddIf( null != this._submittedTime ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._submittedTime?.ToString(@"yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK",global::System.Globalization.CultureInfo.InvariantCulture)) : null, "submittedTime" ,container.Add ); + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportListResult.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportListResult.PowerShell.cs new file mode 100644 index 000000000000..cc31927f4480 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportListResult.PowerShell.cs @@ -0,0 +1,133 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// Result of listing exports. It contains a list of available exports in the scope provided. + /// + [System.ComponentModel.TypeConverter(typeof(ExportListResultTypeConverter))] + public partial class ExportListResult + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportListResult DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new ExportListResult(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportListResult DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new ExportListResult(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal ExportListResult(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportListResultInternal)this).Value = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport[]) content.GetValueForProperty("Value",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportListResultInternal)this).Value, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportTypeConverter.ConvertFrom)); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal ExportListResult(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportListResultInternal)this).Value = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport[]) content.GetValueForProperty("Value",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportListResultInternal)this).Value, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportTypeConverter.ConvertFrom)); + AfterDeserializePSObject(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportListResult FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// Result of listing exports. It contains a list of available exports in the scope provided. + [System.ComponentModel.TypeConverter(typeof(ExportListResultTypeConverter))] + public partial interface IExportListResult + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportListResult.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportListResult.TypeConverter.cs new file mode 100644 index 000000000000..b823d44efabf --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportListResult.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class ExportListResultTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportListResult ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportListResult).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return ExportListResult.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return ExportListResult.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return ExportListResult.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportListResult.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportListResult.cs new file mode 100644 index 000000000000..b8d28941ec92 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportListResult.cs @@ -0,0 +1,51 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// + /// Result of listing exports. It contains a list of available exports in the scope provided. + /// + public partial class ExportListResult : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportListResult, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportListResultInternal + { + + /// Internal Acessors for Value + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport[] Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportListResultInternal.Value { get => this._value; set { {_value = value;} } } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport[] _value; + + /// The list of exports. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport[] Value { get => this._value; } + + /// Creates an new instance. + public ExportListResult() + { + + } + } + /// Result of listing exports. It contains a list of available exports in the scope provided. + public partial interface IExportListResult : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// The list of exports. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"The list of exports.", + SerializedName = @"value", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport[] Value { get; } + + } + /// Result of listing exports. It contains a list of available exports in the scope provided. + public partial interface IExportListResultInternal + + { + /// The list of exports. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport[] Value { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportListResult.json.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportListResult.json.cs new file mode 100644 index 000000000000..0c9fb826da58 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportListResult.json.cs @@ -0,0 +1,114 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// + /// Result of listing exports. It contains a list of available exports in the scope provided. + /// + public partial class ExportListResult + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal ExportListResult(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_value = If( json?.PropertyT("value"), out var __jsonValue) ? If( __jsonValue as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonArray, out var __v) ? new global::System.Func(()=> global::System.Linq.Enumerable.ToArray(global::System.Linq.Enumerable.Select(__v, (__u)=>(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport) (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.Export.FromJson(__u) )) ))() : null : Value;} + AfterFromJson(json); + } + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportListResult. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportListResult. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportListResult FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new ExportListResult(json) : null; + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeReadOnly)) + { + if (null != this._value) + { + var __w = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.XNodeArray(); + foreach( var __x in this._value ) + { + AddIf(__x?.ToJson(null, serializationMode) ,__w.Add); + } + container.Add("value",__w); + } + } + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportProperties.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportProperties.PowerShell.cs new file mode 100644 index 000000000000..90dd35618c1f --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportProperties.PowerShell.cs @@ -0,0 +1,179 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// The properties of the export. + [System.ComponentModel.TypeConverter(typeof(ExportPropertiesTypeConverter))] + public partial class ExportProperties + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportProperties DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new ExportProperties(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportProperties DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new ExportProperties(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal ExportProperties(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportPropertiesInternal)this).Schedule = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportSchedule) content.GetValueForProperty("Schedule",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportPropertiesInternal)this).Schedule, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportScheduleTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DefinitionDataSet = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDataset) content.GetValueForProperty("DefinitionDataSet",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DefinitionDataSet, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDatasetTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).RunHistoryValue = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution[]) content.GetValueForProperty("RunHistoryValue",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).RunHistoryValue, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportExecutionTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DefinitionType = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType) content.GetValueForProperty("DefinitionType",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DefinitionType, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DefinitionTimeframe = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType) content.GetValueForProperty("DefinitionTimeframe",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DefinitionTimeframe, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DeliveryInfoDestination = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestination) content.GetValueForProperty("DeliveryInfoDestination",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DeliveryInfoDestination, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDeliveryDestinationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DefinitionTimePeriod = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportTimePeriod) content.GetValueForProperty("DefinitionTimePeriod",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DefinitionTimePeriod, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportTimePeriodTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).TimePeriodFrom = (global::System.DateTime) content.GetValueForProperty("TimePeriodFrom",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).TimePeriodFrom, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DataSetGranularity = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType?) content.GetValueForProperty("DataSetGranularity",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DataSetGranularity, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DataSetConfiguration = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetConfiguration) content.GetValueForProperty("DataSetConfiguration",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DataSetConfiguration, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDatasetConfigurationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DestinationContainer = (string) content.GetValueForProperty("DestinationContainer",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DestinationContainer, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DestinationResourceId = (string) content.GetValueForProperty("DestinationResourceId",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DestinationResourceId, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DestinationRootFolderPath = (string) content.GetValueForProperty("DestinationRootFolderPath",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DestinationRootFolderPath, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).TimePeriodTo = (global::System.DateTime) content.GetValueForProperty("TimePeriodTo",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).TimePeriodTo, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).ConfigurationColumn = (string[]) content.GetValueForProperty("ConfigurationColumn",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).ConfigurationColumn, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).Definition = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinition) content.GetValueForProperty("Definition",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).Definition, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDefinitionTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DeliveryInfo = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfo) content.GetValueForProperty("DeliveryInfo",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DeliveryInfo, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDeliveryInfoTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).RunHistory = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionListResult) content.GetValueForProperty("RunHistory",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).RunHistory, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportExecutionListResultTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).Format = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType?) content.GetValueForProperty("Format",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).Format, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).NextRunTimeEstimate = (global::System.DateTime?) content.GetValueForProperty("NextRunTimeEstimate",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).NextRunTimeEstimate, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportPropertiesInternal)this).ScheduleRecurrencePeriod = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportRecurrencePeriod) content.GetValueForProperty("ScheduleRecurrencePeriod",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportPropertiesInternal)this).ScheduleRecurrencePeriod, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportRecurrencePeriodTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportPropertiesInternal)this).ScheduleRecurrence = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType) content.GetValueForProperty("ScheduleRecurrence",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportPropertiesInternal)this).ScheduleRecurrence, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportPropertiesInternal)this).ScheduleStatus = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType?) content.GetValueForProperty("ScheduleStatus",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportPropertiesInternal)this).ScheduleStatus, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportPropertiesInternal)this).RecurrencePeriodFrom = (global::System.DateTime) content.GetValueForProperty("RecurrencePeriodFrom",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportPropertiesInternal)this).RecurrencePeriodFrom, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportPropertiesInternal)this).RecurrencePeriodTo = (global::System.DateTime?) content.GetValueForProperty("RecurrencePeriodTo",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportPropertiesInternal)this).RecurrencePeriodTo, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal ExportProperties(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportPropertiesInternal)this).Schedule = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportSchedule) content.GetValueForProperty("Schedule",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportPropertiesInternal)this).Schedule, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportScheduleTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DefinitionDataSet = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDataset) content.GetValueForProperty("DefinitionDataSet",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DefinitionDataSet, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDatasetTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).RunHistoryValue = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution[]) content.GetValueForProperty("RunHistoryValue",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).RunHistoryValue, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportExecutionTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DefinitionType = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType) content.GetValueForProperty("DefinitionType",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DefinitionType, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DefinitionTimeframe = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType) content.GetValueForProperty("DefinitionTimeframe",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DefinitionTimeframe, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DeliveryInfoDestination = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestination) content.GetValueForProperty("DeliveryInfoDestination",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DeliveryInfoDestination, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDeliveryDestinationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DefinitionTimePeriod = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportTimePeriod) content.GetValueForProperty("DefinitionTimePeriod",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DefinitionTimePeriod, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportTimePeriodTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).TimePeriodFrom = (global::System.DateTime) content.GetValueForProperty("TimePeriodFrom",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).TimePeriodFrom, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DataSetGranularity = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType?) content.GetValueForProperty("DataSetGranularity",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DataSetGranularity, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DataSetConfiguration = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetConfiguration) content.GetValueForProperty("DataSetConfiguration",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DataSetConfiguration, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDatasetConfigurationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DestinationContainer = (string) content.GetValueForProperty("DestinationContainer",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DestinationContainer, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DestinationResourceId = (string) content.GetValueForProperty("DestinationResourceId",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DestinationResourceId, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DestinationRootFolderPath = (string) content.GetValueForProperty("DestinationRootFolderPath",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DestinationRootFolderPath, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).TimePeriodTo = (global::System.DateTime) content.GetValueForProperty("TimePeriodTo",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).TimePeriodTo, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).ConfigurationColumn = (string[]) content.GetValueForProperty("ConfigurationColumn",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).ConfigurationColumn, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).Definition = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinition) content.GetValueForProperty("Definition",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).Definition, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDefinitionTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DeliveryInfo = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfo) content.GetValueForProperty("DeliveryInfo",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).DeliveryInfo, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportDeliveryInfoTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).RunHistory = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionListResult) content.GetValueForProperty("RunHistory",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).RunHistory, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportExecutionListResultTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).Format = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType?) content.GetValueForProperty("Format",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).Format, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).NextRunTimeEstimate = (global::System.DateTime?) content.GetValueForProperty("NextRunTimeEstimate",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)this).NextRunTimeEstimate, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportPropertiesInternal)this).ScheduleRecurrencePeriod = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportRecurrencePeriod) content.GetValueForProperty("ScheduleRecurrencePeriod",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportPropertiesInternal)this).ScheduleRecurrencePeriod, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportRecurrencePeriodTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportPropertiesInternal)this).ScheduleRecurrence = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType) content.GetValueForProperty("ScheduleRecurrence",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportPropertiesInternal)this).ScheduleRecurrence, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportPropertiesInternal)this).ScheduleStatus = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType?) content.GetValueForProperty("ScheduleStatus",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportPropertiesInternal)this).ScheduleStatus, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportPropertiesInternal)this).RecurrencePeriodFrom = (global::System.DateTime) content.GetValueForProperty("RecurrencePeriodFrom",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportPropertiesInternal)this).RecurrencePeriodFrom, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportPropertiesInternal)this).RecurrencePeriodTo = (global::System.DateTime?) content.GetValueForProperty("RecurrencePeriodTo",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportPropertiesInternal)this).RecurrencePeriodTo, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + AfterDeserializePSObject(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportProperties FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// The properties of the export. + [System.ComponentModel.TypeConverter(typeof(ExportPropertiesTypeConverter))] + public partial interface IExportProperties + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportProperties.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportProperties.TypeConverter.cs new file mode 100644 index 000000000000..02de5d2770b8 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportProperties.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class ExportPropertiesTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportProperties ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportProperties).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return ExportProperties.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return ExportProperties.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return ExportProperties.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportProperties.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportProperties.cs new file mode 100644 index 000000000000..12f53210733c --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportProperties.cs @@ -0,0 +1,222 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The properties of the export. + public partial class ExportProperties : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportProperties, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportPropertiesInternal, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IValidates + { + /// + /// Backing field for Inherited model + /// + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportProperties __commonExportProperties = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.CommonExportProperties(); + + /// + /// Array of column names to be included in the export. If not provided then the export will include all available columns. + /// The available columns can vary by customer channel (see examples). + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inherited)] + public string[] ConfigurationColumn { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)__commonExportProperties).ConfigurationColumn; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)__commonExportProperties).ConfigurationColumn = value; } + + /// The export dataset configuration. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inherited)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDatasetConfiguration DataSetConfiguration { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)__commonExportProperties).DataSetConfiguration; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)__commonExportProperties).DataSetConfiguration = value; } + + /// The granularity of rows in the export. Currently only 'Daily' is supported. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inherited)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType? DataSetGranularity { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)__commonExportProperties).DataSetGranularity; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)__commonExportProperties).DataSetGranularity = value; } + + /// Has the definition for the export. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inherited)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDefinition Definition { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)__commonExportProperties).Definition; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)__commonExportProperties).Definition = value; } + + /// The definition for data in the export. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inherited)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDataset DefinitionDataSet { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)__commonExportProperties).DefinitionDataSet; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)__commonExportProperties).DefinitionDataSet = value; } + + /// Has time period for pulling data for the export. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inherited)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportTimePeriod DefinitionTimePeriod { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)__commonExportProperties).DefinitionTimePeriod; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)__commonExportProperties).DefinitionTimePeriod = value; } + + /// + /// The time frame for pulling data for the export. If custom, then a specific time period must be provided. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inherited)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType DefinitionTimeframe { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)__commonExportProperties).DefinitionTimeframe; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)__commonExportProperties).DefinitionTimeframe = value; } + + /// + /// The type of the export. Note that 'Usage' is equivalent to 'ActualCost' and is applicable to exports that do not yet provide + /// data for charges or amortization for service reservations. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inherited)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType DefinitionType { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)__commonExportProperties).DefinitionType; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)__commonExportProperties).DefinitionType = value; } + + /// Has delivery information for the export. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inherited)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryInfo DeliveryInfo { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)__commonExportProperties).DeliveryInfo; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)__commonExportProperties).DeliveryInfo = value; } + + /// Has destination for the export being delivered. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inherited)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportDeliveryDestination DeliveryInfoDestination { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)__commonExportProperties).DeliveryInfoDestination; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)__commonExportProperties).DeliveryInfoDestination = value; } + + /// The name of the container where exports will be uploaded. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inherited)] + public string DestinationContainer { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)__commonExportProperties).DestinationContainer; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)__commonExportProperties).DestinationContainer = value; } + + /// The resource id of the storage account where exports will be delivered. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inherited)] + public string DestinationResourceId { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)__commonExportProperties).DestinationResourceId; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)__commonExportProperties).DestinationResourceId = value; } + + /// The name of the directory where exports will be uploaded. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inherited)] + public string DestinationRootFolderPath { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)__commonExportProperties).DestinationRootFolderPath; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)__commonExportProperties).DestinationRootFolderPath = value; } + + /// The format of the export being delivered. Currently only 'Csv' is supported. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inherited)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType? Format { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)__commonExportProperties).Format; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)__commonExportProperties).Format = value; } + + /// Internal Acessors for NextRunTimeEstimate + global::System.DateTime? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal.NextRunTimeEstimate { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)__commonExportProperties).NextRunTimeEstimate; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)__commonExportProperties).NextRunTimeEstimate = value; } + + /// Internal Acessors for RunHistoryValue + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution[] Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal.RunHistoryValue { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)__commonExportProperties).RunHistoryValue; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)__commonExportProperties).RunHistoryValue = value; } + + /// Internal Acessors for Schedule + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportSchedule Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportPropertiesInternal.Schedule { get => (this._schedule = this._schedule ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportSchedule()); set { {_schedule = value;} } } + + /// Internal Acessors for ScheduleRecurrencePeriod + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportRecurrencePeriod Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportPropertiesInternal.ScheduleRecurrencePeriod { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportScheduleInternal)Schedule).RecurrencePeriod; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportScheduleInternal)Schedule).RecurrencePeriod = value; } + + /// + /// If the export has an active schedule, provides an estimate of the next execution time. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inherited)] + public global::System.DateTime? NextRunTimeEstimate { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)__commonExportProperties).NextRunTimeEstimate; } + + /// The start date of recurrence. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public global::System.DateTime RecurrencePeriodFrom { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportScheduleInternal)Schedule).RecurrencePeriodFrom; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportScheduleInternal)Schedule).RecurrencePeriodFrom = value; } + + /// The end date of recurrence. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public global::System.DateTime? RecurrencePeriodTo { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportScheduleInternal)Schedule).RecurrencePeriodTo; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportScheduleInternal)Schedule).RecurrencePeriodTo = value; } + + /// If requested, has the most recent execution history for the export. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inherited)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecutionListResult RunHistory { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)__commonExportProperties).RunHistory; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)__commonExportProperties).RunHistory = value; } + + /// A list of export executions. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inherited)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution[] RunHistoryValue { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)__commonExportProperties).RunHistoryValue; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportSchedule _schedule; + + /// Has schedule information for the export. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + internal Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportSchedule Schedule { get => (this._schedule = this._schedule ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportSchedule()); set => this._schedule = value; } + + /// The schedule recurrence. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType ScheduleRecurrence { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportScheduleInternal)Schedule).Recurrence; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportScheduleInternal)Schedule).Recurrence = value; } + + /// + /// The status of the export's schedule. If 'Inactive', the export's schedule is paused. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType? ScheduleStatus { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportScheduleInternal)Schedule).Status; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportScheduleInternal)Schedule).Status = value; } + + /// The start date for export data. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inherited)] + public global::System.DateTime TimePeriodFrom { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)__commonExportProperties).TimePeriodFrom; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)__commonExportProperties).TimePeriodFrom = value; } + + /// The end date for export data. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inherited)] + public global::System.DateTime TimePeriodTo { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)__commonExportProperties).TimePeriodTo; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal)__commonExportProperties).TimePeriodTo = value; } + + /// Creates an new instance. + public ExportProperties() + { + + } + + /// Validates that this object meets the validation criteria. + /// an instance that will receive validation + /// events. + /// + /// A < see cref = "global::System.Threading.Tasks.Task" /> that will be complete when validation is completed. + /// + public async global::System.Threading.Tasks.Task Validate(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener) + { + await eventListener.AssertNotNull(nameof(__commonExportProperties), __commonExportProperties); + await eventListener.AssertObjectIsValid(nameof(__commonExportProperties), __commonExportProperties); + } + } + /// The properties of the export. + public partial interface IExportProperties : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportProperties + { + /// The start date of recurrence. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The start date of recurrence.", + SerializedName = @"from", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime RecurrencePeriodFrom { get; set; } + /// The end date of recurrence. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The end date of recurrence.", + SerializedName = @"to", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime? RecurrencePeriodTo { get; set; } + /// The schedule recurrence. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The schedule recurrence.", + SerializedName = @"recurrence", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType ScheduleRecurrence { get; set; } + /// + /// The status of the export's schedule. If 'Inactive', the export's schedule is paused. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The status of the export's schedule. If 'Inactive', the export's schedule is paused.", + SerializedName = @"status", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType? ScheduleStatus { get; set; } + + } + /// The properties of the export. + public partial interface IExportPropertiesInternal : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ICommonExportPropertiesInternal + { + /// The start date of recurrence. + global::System.DateTime RecurrencePeriodFrom { get; set; } + /// The end date of recurrence. + global::System.DateTime? RecurrencePeriodTo { get; set; } + /// Has schedule information for the export. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportSchedule Schedule { get; set; } + /// The schedule recurrence. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType ScheduleRecurrence { get; set; } + /// + /// Has start and end date of the recurrence. The start date must be in future. If present, the end date must be greater than + /// start date. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportRecurrencePeriod ScheduleRecurrencePeriod { get; set; } + /// + /// The status of the export's schedule. If 'Inactive', the export's schedule is paused. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType? ScheduleStatus { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportProperties.json.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportProperties.json.cs new file mode 100644 index 000000000000..c45c38813d82 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportProperties.json.cs @@ -0,0 +1,103 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The properties of the export. + public partial class ExportProperties + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal ExportProperties(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + __commonExportProperties = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.CommonExportProperties(json); + {_schedule = If( json?.PropertyT("schedule"), out var __jsonSchedule) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportSchedule.FromJson(__jsonSchedule) : Schedule;} + AfterFromJson(json); + } + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportProperties. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportProperties. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportProperties FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new ExportProperties(json) : null; + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + __commonExportProperties?.ToJson(container, serializationMode); + AddIf( null != this._schedule ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._schedule.ToJson(null,serializationMode) : null, "schedule" ,container.Add ); + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportRecurrencePeriod.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportRecurrencePeriod.PowerShell.cs new file mode 100644 index 000000000000..b9e3ac4603df --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportRecurrencePeriod.PowerShell.cs @@ -0,0 +1,135 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// The start and end date for recurrence schedule. + [System.ComponentModel.TypeConverter(typeof(ExportRecurrencePeriodTypeConverter))] + public partial class ExportRecurrencePeriod + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportRecurrencePeriod DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new ExportRecurrencePeriod(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportRecurrencePeriod DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new ExportRecurrencePeriod(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal ExportRecurrencePeriod(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportRecurrencePeriodInternal)this).From = (global::System.DateTime) content.GetValueForProperty("From",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportRecurrencePeriodInternal)this).From, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportRecurrencePeriodInternal)this).To = (global::System.DateTime?) content.GetValueForProperty("To",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportRecurrencePeriodInternal)this).To, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal ExportRecurrencePeriod(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportRecurrencePeriodInternal)this).From = (global::System.DateTime) content.GetValueForProperty("From",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportRecurrencePeriodInternal)this).From, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportRecurrencePeriodInternal)this).To = (global::System.DateTime?) content.GetValueForProperty("To",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportRecurrencePeriodInternal)this).To, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + AfterDeserializePSObject(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportRecurrencePeriod FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// The start and end date for recurrence schedule. + [System.ComponentModel.TypeConverter(typeof(ExportRecurrencePeriodTypeConverter))] + public partial interface IExportRecurrencePeriod + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportRecurrencePeriod.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportRecurrencePeriod.TypeConverter.cs new file mode 100644 index 000000000000..d1e38003cb69 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportRecurrencePeriod.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class ExportRecurrencePeriodTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportRecurrencePeriod ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportRecurrencePeriod).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return ExportRecurrencePeriod.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return ExportRecurrencePeriod.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return ExportRecurrencePeriod.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportRecurrencePeriod.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportRecurrencePeriod.cs new file mode 100644 index 000000000000..725bdff31943 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportRecurrencePeriod.cs @@ -0,0 +1,63 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The start and end date for recurrence schedule. + public partial class ExportRecurrencePeriod : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportRecurrencePeriod, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportRecurrencePeriodInternal + { + + /// Backing field for property. + private global::System.DateTime _from; + + /// The start date of recurrence. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public global::System.DateTime From { get => this._from; set => this._from = value; } + + /// Backing field for property. + private global::System.DateTime? _to; + + /// The end date of recurrence. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public global::System.DateTime? To { get => this._to; set => this._to = value; } + + /// Creates an new instance. + public ExportRecurrencePeriod() + { + + } + } + /// The start and end date for recurrence schedule. + public partial interface IExportRecurrencePeriod : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// The start date of recurrence. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The start date of recurrence.", + SerializedName = @"from", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime From { get; set; } + /// The end date of recurrence. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The end date of recurrence.", + SerializedName = @"to", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime? To { get; set; } + + } + /// The start and end date for recurrence schedule. + public partial interface IExportRecurrencePeriodInternal + + { + /// The start date of recurrence. + global::System.DateTime From { get; set; } + /// The end date of recurrence. + global::System.DateTime? To { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportRecurrencePeriod.json.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportRecurrencePeriod.json.cs new file mode 100644 index 000000000000..8d9e9fa85ef1 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportRecurrencePeriod.json.cs @@ -0,0 +1,103 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The start and end date for recurrence schedule. + public partial class ExportRecurrencePeriod + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal ExportRecurrencePeriod(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_from = If( json?.PropertyT("from"), out var __jsonFrom) ? global::System.DateTime.TryParse((string)__jsonFrom, global::System.Globalization.CultureInfo.InvariantCulture, global::System.Globalization.DateTimeStyles.AdjustToUniversal, out var __jsonFromValue) ? __jsonFromValue : From : From;} + {_to = If( json?.PropertyT("to"), out var __jsonTo) ? global::System.DateTime.TryParse((string)__jsonTo, global::System.Globalization.CultureInfo.InvariantCulture, global::System.Globalization.DateTimeStyles.AdjustToUniversal, out var __jsonToValue) ? __jsonToValue : To : To;} + AfterFromJson(json); + } + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportRecurrencePeriod. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportRecurrencePeriod. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportRecurrencePeriod FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new ExportRecurrencePeriod(json) : null; + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + AddIf( (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._from.ToString(@"yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK",global::System.Globalization.CultureInfo.InvariantCulture)), "from" ,container.Add ); + AddIf( null != this._to ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._to?.ToString(@"yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK",global::System.Globalization.CultureInfo.InvariantCulture)) : null, "to" ,container.Add ); + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportSchedule.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportSchedule.PowerShell.cs new file mode 100644 index 000000000000..d85680130d40 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportSchedule.PowerShell.cs @@ -0,0 +1,139 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// The schedule associated with the export. + [System.ComponentModel.TypeConverter(typeof(ExportScheduleTypeConverter))] + public partial class ExportSchedule + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportSchedule DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new ExportSchedule(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportSchedule DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new ExportSchedule(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal ExportSchedule(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportScheduleInternal)this).RecurrencePeriod = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportRecurrencePeriod) content.GetValueForProperty("RecurrencePeriod",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportScheduleInternal)this).RecurrencePeriod, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportRecurrencePeriodTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportScheduleInternal)this).Recurrence = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType) content.GetValueForProperty("Recurrence",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportScheduleInternal)this).Recurrence, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportScheduleInternal)this).Status = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType?) content.GetValueForProperty("Status",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportScheduleInternal)this).Status, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportScheduleInternal)this).RecurrencePeriodFrom = (global::System.DateTime) content.GetValueForProperty("RecurrencePeriodFrom",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportScheduleInternal)this).RecurrencePeriodFrom, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportScheduleInternal)this).RecurrencePeriodTo = (global::System.DateTime?) content.GetValueForProperty("RecurrencePeriodTo",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportScheduleInternal)this).RecurrencePeriodTo, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal ExportSchedule(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportScheduleInternal)this).RecurrencePeriod = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportRecurrencePeriod) content.GetValueForProperty("RecurrencePeriod",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportScheduleInternal)this).RecurrencePeriod, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportRecurrencePeriodTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportScheduleInternal)this).Recurrence = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType) content.GetValueForProperty("Recurrence",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportScheduleInternal)this).Recurrence, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportScheduleInternal)this).Status = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType?) content.GetValueForProperty("Status",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportScheduleInternal)this).Status, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportScheduleInternal)this).RecurrencePeriodFrom = (global::System.DateTime) content.GetValueForProperty("RecurrencePeriodFrom",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportScheduleInternal)this).RecurrencePeriodFrom, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportScheduleInternal)this).RecurrencePeriodTo = (global::System.DateTime?) content.GetValueForProperty("RecurrencePeriodTo",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportScheduleInternal)this).RecurrencePeriodTo, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + AfterDeserializePSObject(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportSchedule FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// The schedule associated with the export. + [System.ComponentModel.TypeConverter(typeof(ExportScheduleTypeConverter))] + public partial interface IExportSchedule + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportSchedule.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportSchedule.TypeConverter.cs new file mode 100644 index 000000000000..212bbf8f521d --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportSchedule.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class ExportScheduleTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportSchedule ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportSchedule).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return ExportSchedule.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return ExportSchedule.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return ExportSchedule.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportSchedule.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportSchedule.cs new file mode 100644 index 000000000000..9ac8a3ca020b --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportSchedule.cs @@ -0,0 +1,115 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The schedule associated with the export. + public partial class ExportSchedule : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportSchedule, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportScheduleInternal + { + + /// Internal Acessors for RecurrencePeriod + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportRecurrencePeriod Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportScheduleInternal.RecurrencePeriod { get => (this._recurrencePeriod = this._recurrencePeriod ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportRecurrencePeriod()); set { {_recurrencePeriod = value;} } } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType _recurrence; + + /// The schedule recurrence. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType Recurrence { get => this._recurrence; set => this._recurrence = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportRecurrencePeriod _recurrencePeriod; + + /// + /// Has start and end date of the recurrence. The start date must be in future. If present, the end date must be greater than + /// start date. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + internal Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportRecurrencePeriod RecurrencePeriod { get => (this._recurrencePeriod = this._recurrencePeriod ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportRecurrencePeriod()); set => this._recurrencePeriod = value; } + + /// The start date of recurrence. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public global::System.DateTime RecurrencePeriodFrom { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportRecurrencePeriodInternal)RecurrencePeriod).From; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportRecurrencePeriodInternal)RecurrencePeriod).From = value; } + + /// The end date of recurrence. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public global::System.DateTime? RecurrencePeriodTo { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportRecurrencePeriodInternal)RecurrencePeriod).To; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportRecurrencePeriodInternal)RecurrencePeriod).To = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType? _status; + + /// + /// The status of the export's schedule. If 'Inactive', the export's schedule is paused. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType? Status { get => this._status; set => this._status = value; } + + /// Creates an new instance. + public ExportSchedule() + { + + } + } + /// The schedule associated with the export. + public partial interface IExportSchedule : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// The schedule recurrence. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The schedule recurrence.", + SerializedName = @"recurrence", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType Recurrence { get; set; } + /// The start date of recurrence. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The start date of recurrence.", + SerializedName = @"from", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime RecurrencePeriodFrom { get; set; } + /// The end date of recurrence. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The end date of recurrence.", + SerializedName = @"to", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime? RecurrencePeriodTo { get; set; } + /// + /// The status of the export's schedule. If 'Inactive', the export's schedule is paused. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The status of the export's schedule. If 'Inactive', the export's schedule is paused.", + SerializedName = @"status", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType? Status { get; set; } + + } + /// The schedule associated with the export. + public partial interface IExportScheduleInternal + + { + /// The schedule recurrence. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType Recurrence { get; set; } + /// + /// Has start and end date of the recurrence. The start date must be in future. If present, the end date must be greater than + /// start date. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportRecurrencePeriod RecurrencePeriod { get; set; } + /// The start date of recurrence. + global::System.DateTime RecurrencePeriodFrom { get; set; } + /// The end date of recurrence. + global::System.DateTime? RecurrencePeriodTo { get; set; } + /// + /// The status of the export's schedule. If 'Inactive', the export's schedule is paused. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType? Status { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportSchedule.json.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportSchedule.json.cs new file mode 100644 index 000000000000..6122c1d5f753 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportSchedule.json.cs @@ -0,0 +1,105 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The schedule associated with the export. + public partial class ExportSchedule + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal ExportSchedule(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_recurrencePeriod = If( json?.PropertyT("recurrencePeriod"), out var __jsonRecurrencePeriod) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ExportRecurrencePeriod.FromJson(__jsonRecurrencePeriod) : RecurrencePeriod;} + {_recurrence = If( json?.PropertyT("recurrence"), out var __jsonRecurrence) ? (string)__jsonRecurrence : (string)Recurrence;} + {_status = If( json?.PropertyT("status"), out var __jsonStatus) ? (string)__jsonStatus : (string)Status;} + AfterFromJson(json); + } + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportSchedule. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportSchedule. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportSchedule FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new ExportSchedule(json) : null; + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + AddIf( null != this._recurrencePeriod ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._recurrencePeriod.ToJson(null,serializationMode) : null, "recurrencePeriod" ,container.Add ); + AddIf( null != (((object)this._recurrence)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._recurrence.ToString()) : null, "recurrence" ,container.Add ); + AddIf( null != (((object)this._status)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._status.ToString()) : null, "status" ,container.Add ); + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportTimePeriod.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportTimePeriod.PowerShell.cs new file mode 100644 index 000000000000..3f118352c511 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportTimePeriod.PowerShell.cs @@ -0,0 +1,137 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// The date range for data in the export. This should only be specified with timeFrame set to 'Custom'. The maximum date + /// range is 3 months. + /// + [System.ComponentModel.TypeConverter(typeof(ExportTimePeriodTypeConverter))] + public partial class ExportTimePeriod + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportTimePeriod DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new ExportTimePeriod(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportTimePeriod DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new ExportTimePeriod(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal ExportTimePeriod(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportTimePeriodInternal)this).From = (global::System.DateTime) content.GetValueForProperty("From",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportTimePeriodInternal)this).From, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportTimePeriodInternal)this).To = (global::System.DateTime) content.GetValueForProperty("To",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportTimePeriodInternal)this).To, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal ExportTimePeriod(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportTimePeriodInternal)this).From = (global::System.DateTime) content.GetValueForProperty("From",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportTimePeriodInternal)this).From, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportTimePeriodInternal)this).To = (global::System.DateTime) content.GetValueForProperty("To",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportTimePeriodInternal)this).To, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + AfterDeserializePSObject(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportTimePeriod FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// The date range for data in the export. This should only be specified with timeFrame set to 'Custom'. The maximum date + /// range is 3 months. + [System.ComponentModel.TypeConverter(typeof(ExportTimePeriodTypeConverter))] + public partial interface IExportTimePeriod + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportTimePeriod.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportTimePeriod.TypeConverter.cs new file mode 100644 index 000000000000..e9973835e6b6 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportTimePeriod.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class ExportTimePeriodTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportTimePeriod ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportTimePeriod).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return ExportTimePeriod.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return ExportTimePeriod.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return ExportTimePeriod.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportTimePeriod.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportTimePeriod.cs new file mode 100644 index 000000000000..daa419f8152c --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportTimePeriod.cs @@ -0,0 +1,68 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// + /// The date range for data in the export. This should only be specified with timeFrame set to 'Custom'. The maximum date + /// range is 3 months. + /// + public partial class ExportTimePeriod : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportTimePeriod, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportTimePeriodInternal + { + + /// Backing field for property. + private global::System.DateTime _from; + + /// The start date for export data. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public global::System.DateTime From { get => this._from; set => this._from = value; } + + /// Backing field for property. + private global::System.DateTime _to; + + /// The end date for export data. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public global::System.DateTime To { get => this._to; set => this._to = value; } + + /// Creates an new instance. + public ExportTimePeriod() + { + + } + } + /// The date range for data in the export. This should only be specified with timeFrame set to 'Custom'. The maximum date + /// range is 3 months. + public partial interface IExportTimePeriod : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// The start date for export data. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The start date for export data.", + SerializedName = @"from", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime From { get; set; } + /// The end date for export data. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The end date for export data.", + SerializedName = @"to", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime To { get; set; } + + } + /// The date range for data in the export. This should only be specified with timeFrame set to 'Custom'. The maximum date + /// range is 3 months. + public partial interface IExportTimePeriodInternal + + { + /// The start date for export data. + global::System.DateTime From { get; set; } + /// The end date for export data. + global::System.DateTime To { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ExportTimePeriod.json.cs b/src/CostManagement/generated/api/Models/Api20200601/ExportTimePeriod.json.cs new file mode 100644 index 000000000000..cfceb606a6dd --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ExportTimePeriod.json.cs @@ -0,0 +1,106 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// + /// The date range for data in the export. This should only be specified with timeFrame set to 'Custom'. The maximum date + /// range is 3 months. + /// + public partial class ExportTimePeriod + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal ExportTimePeriod(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_from = If( json?.PropertyT("from"), out var __jsonFrom) ? global::System.DateTime.TryParse((string)__jsonFrom, global::System.Globalization.CultureInfo.InvariantCulture, global::System.Globalization.DateTimeStyles.AdjustToUniversal, out var __jsonFromValue) ? __jsonFromValue : From : From;} + {_to = If( json?.PropertyT("to"), out var __jsonTo) ? global::System.DateTime.TryParse((string)__jsonTo, global::System.Globalization.CultureInfo.InvariantCulture, global::System.Globalization.DateTimeStyles.AdjustToUniversal, out var __jsonToValue) ? __jsonToValue : To : To;} + AfterFromJson(json); + } + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportTimePeriod. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportTimePeriod. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportTimePeriod FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new ExportTimePeriod(json) : null; + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + AddIf( (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._from.ToString(@"yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK",global::System.Globalization.CultureInfo.InvariantCulture)), "from" ,container.Add ); + AddIf( (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._to.ToString(@"yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK",global::System.Globalization.CultureInfo.InvariantCulture)), "to" ,container.Add ); + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ForecastDataset.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/ForecastDataset.PowerShell.cs new file mode 100644 index 000000000000..8a6d260817f2 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ForecastDataset.PowerShell.cs @@ -0,0 +1,139 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// The definition of data present in the forecast. + [System.ComponentModel.TypeConverter(typeof(ForecastDatasetTypeConverter))] + public partial class ForecastDataset + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDataset DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new ForecastDataset(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDataset DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new ForecastDataset(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal ForecastDataset(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetInternal)this).Configuration = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetConfiguration) content.GetValueForProperty("Configuration",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetInternal)this).Configuration, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryDatasetConfigurationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetInternal)this).Aggregation = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetAggregation) content.GetValueForProperty("Aggregation",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetInternal)this).Aggregation, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ForecastDatasetAggregationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetInternal)this).Filter = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter) content.GetValueForProperty("Filter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetInternal)this).Filter, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryFilterTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetInternal)this).Granularity = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType?) content.GetValueForProperty("Granularity",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetInternal)this).Granularity, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetInternal)this).ConfigurationColumn = (string[]) content.GetValueForProperty("ConfigurationColumn",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetInternal)this).ConfigurationColumn, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal ForecastDataset(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetInternal)this).Configuration = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetConfiguration) content.GetValueForProperty("Configuration",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetInternal)this).Configuration, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryDatasetConfigurationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetInternal)this).Aggregation = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetAggregation) content.GetValueForProperty("Aggregation",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetInternal)this).Aggregation, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ForecastDatasetAggregationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetInternal)this).Filter = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter) content.GetValueForProperty("Filter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetInternal)this).Filter, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryFilterTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetInternal)this).Granularity = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType?) content.GetValueForProperty("Granularity",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetInternal)this).Granularity, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetInternal)this).ConfigurationColumn = (string[]) content.GetValueForProperty("ConfigurationColumn",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetInternal)this).ConfigurationColumn, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + AfterDeserializePSObject(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDataset FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// The definition of data present in the forecast. + [System.ComponentModel.TypeConverter(typeof(ForecastDatasetTypeConverter))] + public partial interface IForecastDataset + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ForecastDataset.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/ForecastDataset.TypeConverter.cs new file mode 100644 index 000000000000..335c553388eb --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ForecastDataset.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class ForecastDatasetTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDataset ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDataset).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return ForecastDataset.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return ForecastDataset.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return ForecastDataset.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ForecastDataset.cs b/src/CostManagement/generated/api/Models/Api20200601/ForecastDataset.cs new file mode 100644 index 000000000000..313e75598bc4 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ForecastDataset.cs @@ -0,0 +1,130 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The definition of data present in the forecast. + public partial class ForecastDataset : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDataset, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetInternal + { + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetAggregation _aggregation; + + /// + /// Dictionary of aggregation expression to use in the forecast. The key of each item in the dictionary is the alias for the + /// aggregated column. forecast can have up to 2 aggregation clauses. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetAggregation Aggregation { get => (this._aggregation = this._aggregation ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ForecastDatasetAggregation()); set => this._aggregation = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetConfiguration _configuration; + + /// + /// Has configuration information for the data in the export. The configuration will be ignored if aggregation and grouping + /// are provided. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + internal Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetConfiguration Configuration { get => (this._configuration = this._configuration ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryDatasetConfiguration()); set => this._configuration = value; } + + /// + /// Array of column names to be included in the query. Any valid query column name is allowed. If not provided, then query + /// includes all columns. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string[] ConfigurationColumn { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetConfigurationInternal)Configuration).Column; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetConfigurationInternal)Configuration).Column = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter _filter; + + /// Has filter expression to use in the forecast. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter Filter { get => (this._filter = this._filter ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryFilter()); set => this._filter = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType? _granularity; + + /// The granularity of rows in the forecast. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType? Granularity { get => this._granularity; set => this._granularity = value; } + + /// Internal Acessors for Configuration + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetConfiguration Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetInternal.Configuration { get => (this._configuration = this._configuration ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryDatasetConfiguration()); set { {_configuration = value;} } } + + /// Creates an new instance. + public ForecastDataset() + { + + } + } + /// The definition of data present in the forecast. + public partial interface IForecastDataset : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// + /// Dictionary of aggregation expression to use in the forecast. The key of each item in the dictionary is the alias for the + /// aggregated column. forecast can have up to 2 aggregation clauses. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Dictionary of aggregation expression to use in the forecast. The key of each item in the dictionary is the alias for the aggregated column. forecast can have up to 2 aggregation clauses.", + SerializedName = @"aggregation", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetAggregation) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetAggregation Aggregation { get; set; } + /// + /// Array of column names to be included in the query. Any valid query column name is allowed. If not provided, then query + /// includes all columns. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Array of column names to be included in the query. Any valid query column name is allowed. If not provided, then query includes all columns.", + SerializedName = @"columns", + PossibleTypes = new [] { typeof(string) })] + string[] ConfigurationColumn { get; set; } + /// Has filter expression to use in the forecast. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Has filter expression to use in the forecast.", + SerializedName = @"filter", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter Filter { get; set; } + /// The granularity of rows in the forecast. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The granularity of rows in the forecast.", + SerializedName = @"granularity", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType? Granularity { get; set; } + + } + /// The definition of data present in the forecast. + public partial interface IForecastDatasetInternal + + { + /// + /// Dictionary of aggregation expression to use in the forecast. The key of each item in the dictionary is the alias for the + /// aggregated column. forecast can have up to 2 aggregation clauses. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetAggregation Aggregation { get; set; } + /// + /// Has configuration information for the data in the export. The configuration will be ignored if aggregation and grouping + /// are provided. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetConfiguration Configuration { get; set; } + /// + /// Array of column names to be included in the query. Any valid query column name is allowed. If not provided, then query + /// includes all columns. + /// + string[] ConfigurationColumn { get; set; } + /// Has filter expression to use in the forecast. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter Filter { get; set; } + /// The granularity of rows in the forecast. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType? Granularity { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ForecastDataset.json.cs b/src/CostManagement/generated/api/Models/Api20200601/ForecastDataset.json.cs new file mode 100644 index 000000000000..92feac698e88 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ForecastDataset.json.cs @@ -0,0 +1,107 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The definition of data present in the forecast. + public partial class ForecastDataset + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal ForecastDataset(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_configuration = If( json?.PropertyT("configuration"), out var __jsonConfiguration) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryDatasetConfiguration.FromJson(__jsonConfiguration) : Configuration;} + {_aggregation = If( json?.PropertyT("aggregation"), out var __jsonAggregation) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ForecastDatasetAggregation.FromJson(__jsonAggregation) : Aggregation;} + {_filter = If( json?.PropertyT("filter"), out var __jsonFilter) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryFilter.FromJson(__jsonFilter) : Filter;} + {_granularity = If( json?.PropertyT("granularity"), out var __jsonGranularity) ? (string)__jsonGranularity : (string)Granularity;} + AfterFromJson(json); + } + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDataset. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDataset. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDataset FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new ForecastDataset(json) : null; + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + AddIf( null != this._configuration ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._configuration.ToJson(null,serializationMode) : null, "configuration" ,container.Add ); + AddIf( null != this._aggregation ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._aggregation.ToJson(null,serializationMode) : null, "aggregation" ,container.Add ); + AddIf( null != this._filter ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._filter.ToJson(null,serializationMode) : null, "filter" ,container.Add ); + AddIf( null != (((object)this._granularity)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._granularity.ToString()) : null, "granularity" ,container.Add ); + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ForecastDatasetAggregation.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/ForecastDatasetAggregation.PowerShell.cs new file mode 100644 index 000000000000..e26b34cf8ee0 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ForecastDatasetAggregation.PowerShell.cs @@ -0,0 +1,139 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// Dictionary of aggregation expression to use in the forecast. The key of each item in the dictionary is the alias for the + /// aggregated column. forecast can have up to 2 aggregation clauses. + /// + [System.ComponentModel.TypeConverter(typeof(ForecastDatasetAggregationTypeConverter))] + public partial class ForecastDatasetAggregation + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetAggregation DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new ForecastDatasetAggregation(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetAggregation DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new ForecastDatasetAggregation(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal ForecastDatasetAggregation(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + // this type is a dictionary; copy elements from source to here. + CopyFrom(content); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal ForecastDatasetAggregation(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + // this type is a dictionary; copy elements from source to here. + CopyFrom(content); + AfterDeserializePSObject(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetAggregation FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// Dictionary of aggregation expression to use in the forecast. The key of each item in the dictionary is the alias for the + /// aggregated column. forecast can have up to 2 aggregation clauses. + [System.ComponentModel.TypeConverter(typeof(ForecastDatasetAggregationTypeConverter))] + public partial interface IForecastDatasetAggregation + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ForecastDatasetAggregation.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/ForecastDatasetAggregation.TypeConverter.cs new file mode 100644 index 000000000000..845a6dc3ddd5 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ForecastDatasetAggregation.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class ForecastDatasetAggregationTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetAggregation ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetAggregation).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return ForecastDatasetAggregation.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return ForecastDatasetAggregation.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return ForecastDatasetAggregation.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ForecastDatasetAggregation.cs b/src/CostManagement/generated/api/Models/Api20200601/ForecastDatasetAggregation.cs new file mode 100644 index 000000000000..c01b6512a6c9 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ForecastDatasetAggregation.cs @@ -0,0 +1,35 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// + /// Dictionary of aggregation expression to use in the forecast. The key of each item in the dictionary is the alias for the + /// aggregated column. forecast can have up to 2 aggregation clauses. + /// + public partial class ForecastDatasetAggregation : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetAggregation, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetAggregationInternal + { + + /// Creates an new instance. + public ForecastDatasetAggregation() + { + + } + } + /// Dictionary of aggregation expression to use in the forecast. The key of each item in the dictionary is the alias for the + /// aggregated column. forecast can have up to 2 aggregation clauses. + public partial interface IForecastDatasetAggregation : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IAssociativeArray + { + + } + /// Dictionary of aggregation expression to use in the forecast. The key of each item in the dictionary is the alias for the + /// aggregated column. forecast can have up to 2 aggregation clauses. + public partial interface IForecastDatasetAggregationInternal + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ForecastDatasetAggregation.dictionary.cs b/src/CostManagement/generated/api/Models/Api20200601/ForecastDatasetAggregation.dictionary.cs new file mode 100644 index 000000000000..f8c5a3d46d65 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ForecastDatasetAggregation.dictionary.cs @@ -0,0 +1,70 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + public partial class ForecastDatasetAggregation : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IAssociativeArray + { + protected global::System.Collections.Generic.Dictionary __additionalProperties = new global::System.Collections.Generic.Dictionary(); + + global::System.Collections.Generic.IDictionary Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IAssociativeArray.AdditionalProperties { get => __additionalProperties; } + + int Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IAssociativeArray.Count { get => __additionalProperties.Count; } + + global::System.Collections.Generic.IEnumerable Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IAssociativeArray.Keys { get => __additionalProperties.Keys; } + + global::System.Collections.Generic.IEnumerable Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IAssociativeArray.Values { get => __additionalProperties.Values; } + + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryAggregation this[global::System.String index] { get => __additionalProperties[index]; set => __additionalProperties[index] = value; } + + /// + /// + public void Add(global::System.String key, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryAggregation value) => __additionalProperties.Add( key, value); + + public void Clear() => __additionalProperties.Clear(); + + /// + public bool ContainsKey(global::System.String key) => __additionalProperties.ContainsKey( key); + + /// + public void CopyFrom(global::System.Collections.IDictionary source) + { + if (null != source) + { + foreach( var property in Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.TypeConverterExtensions.GetFilteredProperties(source, new global::System.Collections.Generic.HashSet() { } ) ) + { + if ((null != property.Key && null != property.Value)) + { + this.__additionalProperties.Add(property.Key.ToString(), global::System.Management.Automation.LanguagePrimitives.ConvertTo( property.Value)); + } + } + } + } + + /// + public void CopyFrom(global::System.Management.Automation.PSObject source) + { + if (null != source) + { + foreach( var property in Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.TypeConverterExtensions.GetFilteredProperties(source, new global::System.Collections.Generic.HashSet() { } ) ) + { + if ((null != property.Key && null != property.Value)) + { + this.__additionalProperties.Add(property.Key.ToString(), global::System.Management.Automation.LanguagePrimitives.ConvertTo( property.Value)); + } + } + } + } + + /// + public bool Remove(global::System.String key) => __additionalProperties.Remove( key); + + /// + /// + public bool TryGetValue(global::System.String key, out Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryAggregation value) => __additionalProperties.TryGetValue( key, out value); + + /// + + public static implicit operator global::System.Collections.Generic.Dictionary(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ForecastDatasetAggregation source) => source.__additionalProperties; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ForecastDatasetAggregation.json.cs b/src/CostManagement/generated/api/Models/Api20200601/ForecastDatasetAggregation.json.cs new file mode 100644 index 000000000000..1de5997c9363 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ForecastDatasetAggregation.json.cs @@ -0,0 +1,105 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// + /// Dictionary of aggregation expression to use in the forecast. The key of each item in the dictionary is the alias for the + /// aggregated column. forecast can have up to 2 aggregation clauses. + /// + public partial class ForecastDatasetAggregation + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + /// + internal ForecastDatasetAggregation(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, global::System.Collections.Generic.HashSet exclusions = null) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.JsonSerializable.FromJson( json, ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IAssociativeArray)this).AdditionalProperties, null ,exclusions ); + AfterFromJson(json); + } + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetAggregation. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetAggregation. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetAggregation FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new ForecastDatasetAggregation(json) : null; + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.JsonSerializable.ToJson( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IAssociativeArray)this).AdditionalProperties, container); + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ForecastDefinition.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/ForecastDefinition.PowerShell.cs new file mode 100644 index 000000000000..7054d0f325ff --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ForecastDefinition.PowerShell.cs @@ -0,0 +1,155 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// The definition of a forecast. + [System.ComponentModel.TypeConverter(typeof(ForecastDefinitionTypeConverter))] + public partial class ForecastDefinition + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinition DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new ForecastDefinition(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinition DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new ForecastDefinition(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal ForecastDefinition(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).Dataset = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDataset) content.GetValueForProperty("Dataset",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).Dataset, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ForecastDatasetTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).TimePeriod = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryTimePeriod) content.GetValueForProperty("TimePeriod",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).TimePeriod, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryTimePeriodTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).Type = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ForecastType) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).Type, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ForecastType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).IncludeActualCost = (bool?) content.GetValueForProperty("IncludeActualCost",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).IncludeActualCost, (__y)=> (bool) global::System.Convert.ChangeType(__y, typeof(bool))); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).IncludeFreshPartialCost = (bool?) content.GetValueForProperty("IncludeFreshPartialCost",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).IncludeFreshPartialCost, (__y)=> (bool) global::System.Convert.ChangeType(__y, typeof(bool))); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).Timeframe = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ForecastTimeframeType) content.GetValueForProperty("Timeframe",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).Timeframe, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ForecastTimeframeType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).DatasetConfiguration = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetConfiguration) content.GetValueForProperty("DatasetConfiguration",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).DatasetConfiguration, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryDatasetConfigurationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).DatasetAggregation = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetAggregation) content.GetValueForProperty("DatasetAggregation",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).DatasetAggregation, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ForecastDatasetAggregationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).DatasetFilter = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter) content.GetValueForProperty("DatasetFilter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).DatasetFilter, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryFilterTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).DatasetGranularity = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType?) content.GetValueForProperty("DatasetGranularity",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).DatasetGranularity, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).TimePeriodFrom = (global::System.DateTime) content.GetValueForProperty("TimePeriodFrom",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).TimePeriodFrom, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).TimePeriodTo = (global::System.DateTime) content.GetValueForProperty("TimePeriodTo",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).TimePeriodTo, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).ConfigurationColumn = (string[]) content.GetValueForProperty("ConfigurationColumn",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).ConfigurationColumn, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal ForecastDefinition(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).Dataset = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDataset) content.GetValueForProperty("Dataset",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).Dataset, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ForecastDatasetTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).TimePeriod = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryTimePeriod) content.GetValueForProperty("TimePeriod",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).TimePeriod, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryTimePeriodTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).Type = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ForecastType) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).Type, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ForecastType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).IncludeActualCost = (bool?) content.GetValueForProperty("IncludeActualCost",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).IncludeActualCost, (__y)=> (bool) global::System.Convert.ChangeType(__y, typeof(bool))); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).IncludeFreshPartialCost = (bool?) content.GetValueForProperty("IncludeFreshPartialCost",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).IncludeFreshPartialCost, (__y)=> (bool) global::System.Convert.ChangeType(__y, typeof(bool))); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).Timeframe = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ForecastTimeframeType) content.GetValueForProperty("Timeframe",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).Timeframe, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ForecastTimeframeType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).DatasetConfiguration = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetConfiguration) content.GetValueForProperty("DatasetConfiguration",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).DatasetConfiguration, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryDatasetConfigurationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).DatasetAggregation = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetAggregation) content.GetValueForProperty("DatasetAggregation",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).DatasetAggregation, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ForecastDatasetAggregationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).DatasetFilter = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter) content.GetValueForProperty("DatasetFilter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).DatasetFilter, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryFilterTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).DatasetGranularity = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType?) content.GetValueForProperty("DatasetGranularity",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).DatasetGranularity, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).TimePeriodFrom = (global::System.DateTime) content.GetValueForProperty("TimePeriodFrom",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).TimePeriodFrom, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).TimePeriodTo = (global::System.DateTime) content.GetValueForProperty("TimePeriodTo",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).TimePeriodTo, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).ConfigurationColumn = (string[]) content.GetValueForProperty("ConfigurationColumn",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal)this).ConfigurationColumn, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + AfterDeserializePSObject(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinition FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// The definition of a forecast. + [System.ComponentModel.TypeConverter(typeof(ForecastDefinitionTypeConverter))] + public partial interface IForecastDefinition + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ForecastDefinition.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/ForecastDefinition.TypeConverter.cs new file mode 100644 index 000000000000..6bf83ddfd087 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ForecastDefinition.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class ForecastDefinitionTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinition ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinition).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return ForecastDefinition.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return ForecastDefinition.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return ForecastDefinition.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ForecastDefinition.cs b/src/CostManagement/generated/api/Models/Api20200601/ForecastDefinition.cs new file mode 100644 index 000000000000..c4fef3005932 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ForecastDefinition.cs @@ -0,0 +1,237 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The definition of a forecast. + public partial class ForecastDefinition : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinition, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal + { + + /// + /// Array of column names to be included in the query. Any valid query column name is allowed. If not provided, then query + /// includes all columns. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string[] ConfigurationColumn { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetInternal)Dataset).ConfigurationColumn; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetInternal)Dataset).ConfigurationColumn = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDataset _dataset; + + /// Has definition for data in this forecast. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + internal Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDataset Dataset { get => (this._dataset = this._dataset ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ForecastDataset()); set => this._dataset = value; } + + /// + /// Dictionary of aggregation expression to use in the forecast. The key of each item in the dictionary is the alias for the + /// aggregated column. forecast can have up to 2 aggregation clauses. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetAggregation DatasetAggregation { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetInternal)Dataset).Aggregation; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetInternal)Dataset).Aggregation = value; } + + /// Has filter expression to use in the forecast. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter DatasetFilter { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetInternal)Dataset).Filter; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetInternal)Dataset).Filter = value; } + + /// The granularity of rows in the forecast. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType? DatasetGranularity { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetInternal)Dataset).Granularity; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetInternal)Dataset).Granularity = value; } + + /// Backing field for property. + private bool? _includeActualCost; + + /// a boolean determining if actualCost will be included + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public bool? IncludeActualCost { get => this._includeActualCost; set => this._includeActualCost = value; } + + /// Backing field for property. + private bool? _includeFreshPartialCost; + + /// a boolean determining if FreshPartialCost will be included + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public bool? IncludeFreshPartialCost { get => this._includeFreshPartialCost; set => this._includeFreshPartialCost = value; } + + /// Internal Acessors for Dataset + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDataset Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal.Dataset { get => (this._dataset = this._dataset ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ForecastDataset()); set { {_dataset = value;} } } + + /// Internal Acessors for DatasetConfiguration + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetConfiguration Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal.DatasetConfiguration { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetInternal)Dataset).Configuration; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetInternal)Dataset).Configuration = value; } + + /// Internal Acessors for TimePeriod + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryTimePeriod Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinitionInternal.TimePeriod { get => (this._timePeriod = this._timePeriod ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryTimePeriod()); set { {_timePeriod = value;} } } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryTimePeriod _timePeriod; + + /// Has time period for pulling data for the forecast. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + internal Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryTimePeriod TimePeriod { get => (this._timePeriod = this._timePeriod ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryTimePeriod()); set => this._timePeriod = value; } + + /// The start date to pull data from. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public global::System.DateTime TimePeriodFrom { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryTimePeriodInternal)TimePeriod).From; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryTimePeriodInternal)TimePeriod).From = value; } + + /// The end date to pull data to. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public global::System.DateTime TimePeriodTo { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryTimePeriodInternal)TimePeriod).To; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryTimePeriodInternal)TimePeriod).To = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ForecastTimeframeType _timeframe; + + /// + /// The time frame for pulling data for the forecast. If custom, then a specific time period must be provided. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ForecastTimeframeType Timeframe { get => this._timeframe; set => this._timeframe = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ForecastType _type; + + /// The type of the forecast. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ForecastType Type { get => this._type; set => this._type = value; } + + /// Creates an new instance. + public ForecastDefinition() + { + + } + } + /// The definition of a forecast. + public partial interface IForecastDefinition : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// + /// Array of column names to be included in the query. Any valid query column name is allowed. If not provided, then query + /// includes all columns. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Array of column names to be included in the query. Any valid query column name is allowed. If not provided, then query includes all columns.", + SerializedName = @"columns", + PossibleTypes = new [] { typeof(string) })] + string[] ConfigurationColumn { get; set; } + /// + /// Dictionary of aggregation expression to use in the forecast. The key of each item in the dictionary is the alias for the + /// aggregated column. forecast can have up to 2 aggregation clauses. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Dictionary of aggregation expression to use in the forecast. The key of each item in the dictionary is the alias for the aggregated column. forecast can have up to 2 aggregation clauses.", + SerializedName = @"aggregation", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetAggregation) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetAggregation DatasetAggregation { get; set; } + /// Has filter expression to use in the forecast. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Has filter expression to use in the forecast.", + SerializedName = @"filter", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter DatasetFilter { get; set; } + /// The granularity of rows in the forecast. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The granularity of rows in the forecast.", + SerializedName = @"granularity", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType? DatasetGranularity { get; set; } + /// a boolean determining if actualCost will be included + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"a boolean determining if actualCost will be included", + SerializedName = @"includeActualCost", + PossibleTypes = new [] { typeof(bool) })] + bool? IncludeActualCost { get; set; } + /// a boolean determining if FreshPartialCost will be included + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"a boolean determining if FreshPartialCost will be included", + SerializedName = @"includeFreshPartialCost", + PossibleTypes = new [] { typeof(bool) })] + bool? IncludeFreshPartialCost { get; set; } + /// The start date to pull data from. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The start date to pull data from.", + SerializedName = @"from", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime TimePeriodFrom { get; set; } + /// The end date to pull data to. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The end date to pull data to.", + SerializedName = @"to", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime TimePeriodTo { get; set; } + /// + /// The time frame for pulling data for the forecast. If custom, then a specific time period must be provided. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The time frame for pulling data for the forecast. If custom, then a specific time period must be provided.", + SerializedName = @"timeframe", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ForecastTimeframeType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ForecastTimeframeType Timeframe { get; set; } + /// The type of the forecast. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The type of the forecast.", + SerializedName = @"type", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ForecastType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ForecastType Type { get; set; } + + } + /// The definition of a forecast. + public partial interface IForecastDefinitionInternal + + { + /// + /// Array of column names to be included in the query. Any valid query column name is allowed. If not provided, then query + /// includes all columns. + /// + string[] ConfigurationColumn { get; set; } + /// Has definition for data in this forecast. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDataset Dataset { get; set; } + /// + /// Dictionary of aggregation expression to use in the forecast. The key of each item in the dictionary is the alias for the + /// aggregated column. forecast can have up to 2 aggregation clauses. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDatasetAggregation DatasetAggregation { get; set; } + /// + /// Has configuration information for the data in the export. The configuration will be ignored if aggregation and grouping + /// are provided. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetConfiguration DatasetConfiguration { get; set; } + /// Has filter expression to use in the forecast. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter DatasetFilter { get; set; } + /// The granularity of rows in the forecast. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType? DatasetGranularity { get; set; } + /// a boolean determining if actualCost will be included + bool? IncludeActualCost { get; set; } + /// a boolean determining if FreshPartialCost will be included + bool? IncludeFreshPartialCost { get; set; } + /// Has time period for pulling data for the forecast. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryTimePeriod TimePeriod { get; set; } + /// The start date to pull data from. + global::System.DateTime TimePeriodFrom { get; set; } + /// The end date to pull data to. + global::System.DateTime TimePeriodTo { get; set; } + /// + /// The time frame for pulling data for the forecast. If custom, then a specific time period must be provided. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ForecastTimeframeType Timeframe { get; set; } + /// The type of the forecast. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ForecastType Type { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ForecastDefinition.json.cs b/src/CostManagement/generated/api/Models/Api20200601/ForecastDefinition.json.cs new file mode 100644 index 000000000000..4724067cb19b --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ForecastDefinition.json.cs @@ -0,0 +1,111 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The definition of a forecast. + public partial class ForecastDefinition + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal ForecastDefinition(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_dataset = If( json?.PropertyT("dataset"), out var __jsonDataset) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ForecastDataset.FromJson(__jsonDataset) : Dataset;} + {_timePeriod = If( json?.PropertyT("timePeriod"), out var __jsonTimePeriod) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryTimePeriod.FromJson(__jsonTimePeriod) : TimePeriod;} + {_type = If( json?.PropertyT("type"), out var __jsonType) ? (string)__jsonType : (string)Type;} + {_includeActualCost = If( json?.PropertyT("includeActualCost"), out var __jsonIncludeActualCost) ? (bool?)__jsonIncludeActualCost : IncludeActualCost;} + {_includeFreshPartialCost = If( json?.PropertyT("includeFreshPartialCost"), out var __jsonIncludeFreshPartialCost) ? (bool?)__jsonIncludeFreshPartialCost : IncludeFreshPartialCost;} + {_timeframe = If( json?.PropertyT("timeframe"), out var __jsonTimeframe) ? (string)__jsonTimeframe : (string)Timeframe;} + AfterFromJson(json); + } + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinition. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinition. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IForecastDefinition FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new ForecastDefinition(json) : null; + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + AddIf( null != this._dataset ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._dataset.ToJson(null,serializationMode) : null, "dataset" ,container.Add ); + AddIf( null != this._timePeriod ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._timePeriod.ToJson(null,serializationMode) : null, "timePeriod" ,container.Add ); + AddIf( null != (((object)this._type)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._type.ToString()) : null, "type" ,container.Add ); + AddIf( null != this._includeActualCost ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode)new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonBoolean((bool)this._includeActualCost) : null, "includeActualCost" ,container.Add ); + AddIf( null != this._includeFreshPartialCost ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode)new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonBoolean((bool)this._includeFreshPartialCost) : null, "includeFreshPartialCost" ,container.Add ); + AddIf( null != (((object)this._timeframe)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._timeframe.ToString()) : null, "timeframe" ,container.Add ); + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/KpiProperties.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/KpiProperties.PowerShell.cs new file mode 100644 index 000000000000..3fcdc060f1e8 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/KpiProperties.PowerShell.cs @@ -0,0 +1,135 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// Each KPI must contain a 'type' and 'enabled' key. + [System.ComponentModel.TypeConverter(typeof(KpiPropertiesTypeConverter))] + public partial class KpiProperties + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IKpiProperties DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new KpiProperties(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IKpiProperties DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new KpiProperties(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IKpiProperties FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal KpiProperties(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IKpiPropertiesInternal)this).Type = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.KpiType?) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IKpiPropertiesInternal)this).Type, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.KpiType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IKpiPropertiesInternal)this).Enabled = (bool?) content.GetValueForProperty("Enabled",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IKpiPropertiesInternal)this).Enabled, (__y)=> (bool) global::System.Convert.ChangeType(__y, typeof(bool))); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IKpiPropertiesInternal)this).Id = (string) content.GetValueForProperty("Id",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IKpiPropertiesInternal)this).Id, global::System.Convert.ToString); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal KpiProperties(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IKpiPropertiesInternal)this).Type = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.KpiType?) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IKpiPropertiesInternal)this).Type, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.KpiType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IKpiPropertiesInternal)this).Enabled = (bool?) content.GetValueForProperty("Enabled",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IKpiPropertiesInternal)this).Enabled, (__y)=> (bool) global::System.Convert.ChangeType(__y, typeof(bool))); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IKpiPropertiesInternal)this).Id = (string) content.GetValueForProperty("Id",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IKpiPropertiesInternal)this).Id, global::System.Convert.ToString); + AfterDeserializePSObject(content); + } + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// Each KPI must contain a 'type' and 'enabled' key. + [System.ComponentModel.TypeConverter(typeof(KpiPropertiesTypeConverter))] + public partial interface IKpiProperties + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/KpiProperties.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/KpiProperties.TypeConverter.cs new file mode 100644 index 000000000000..2a73166f42cd --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/KpiProperties.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class KpiPropertiesTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IKpiProperties ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IKpiProperties).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return KpiProperties.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return KpiProperties.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return KpiProperties.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/KpiProperties.cs b/src/CostManagement/generated/api/Models/Api20200601/KpiProperties.cs new file mode 100644 index 000000000000..7eabe1398618 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/KpiProperties.cs @@ -0,0 +1,80 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// Each KPI must contain a 'type' and 'enabled' key. + public partial class KpiProperties : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IKpiProperties, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IKpiPropertiesInternal + { + + /// Backing field for property. + private bool? _enabled; + + /// show the KPI in the UI? + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public bool? Enabled { get => this._enabled; set => this._enabled = value; } + + /// Backing field for property. + private string _id; + + /// ID of resource related to metric (budget). + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string Id { get => this._id; set => this._id = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.KpiType? _type; + + /// KPI type (Forecast, Budget). + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.KpiType? Type { get => this._type; set => this._type = value; } + + /// Creates an new instance. + public KpiProperties() + { + + } + } + /// Each KPI must contain a 'type' and 'enabled' key. + public partial interface IKpiProperties : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// show the KPI in the UI? + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"show the KPI in the UI?", + SerializedName = @"enabled", + PossibleTypes = new [] { typeof(bool) })] + bool? Enabled { get; set; } + /// ID of resource related to metric (budget). + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"ID of resource related to metric (budget).", + SerializedName = @"id", + PossibleTypes = new [] { typeof(string) })] + string Id { get; set; } + /// KPI type (Forecast, Budget). + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"KPI type (Forecast, Budget).", + SerializedName = @"type", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.KpiType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.KpiType? Type { get; set; } + + } + /// Each KPI must contain a 'type' and 'enabled' key. + public partial interface IKpiPropertiesInternal + + { + /// show the KPI in the UI? + bool? Enabled { get; set; } + /// ID of resource related to metric (budget). + string Id { get; set; } + /// KPI type (Forecast, Budget). + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.KpiType? Type { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/KpiProperties.json.cs b/src/CostManagement/generated/api/Models/Api20200601/KpiProperties.json.cs new file mode 100644 index 000000000000..dd504bcad513 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/KpiProperties.json.cs @@ -0,0 +1,105 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// Each KPI must contain a 'type' and 'enabled' key. + public partial class KpiProperties + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IKpiProperties. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IKpiProperties. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IKpiProperties FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new KpiProperties(json) : null; + } + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal KpiProperties(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_type = If( json?.PropertyT("type"), out var __jsonType) ? (string)__jsonType : (string)Type;} + {_enabled = If( json?.PropertyT("enabled"), out var __jsonEnabled) ? (bool?)__jsonEnabled : Enabled;} + {_id = If( json?.PropertyT("id"), out var __jsonId) ? (string)__jsonId : (string)Id;} + AfterFromJson(json); + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + AddIf( null != (((object)this._type)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._type.ToString()) : null, "type" ,container.Add ); + AddIf( null != this._enabled ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode)new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonBoolean((bool)this._enabled) : null, "enabled" ,container.Add ); + AddIf( null != (((object)this._id)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._id.ToString()) : null, "id" ,container.Add ); + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/Operation.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/Operation.PowerShell.cs new file mode 100644 index 000000000000..c288def77c05 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/Operation.PowerShell.cs @@ -0,0 +1,139 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// A Cost management REST API operation. + [System.ComponentModel.TypeConverter(typeof(OperationTypeConverter))] + public partial class Operation + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperation DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new Operation(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperation DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new Operation(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperation FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal Operation(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationInternal)this).Display = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationDisplay) content.GetValueForProperty("Display",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationInternal)this).Display, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.OperationDisplayTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationInternal)this).Name, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationInternal)this).DisplayOperation = (string) content.GetValueForProperty("DisplayOperation",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationInternal)this).DisplayOperation, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationInternal)this).DisplayProvider = (string) content.GetValueForProperty("DisplayProvider",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationInternal)this).DisplayProvider, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationInternal)this).DisplayResource = (string) content.GetValueForProperty("DisplayResource",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationInternal)this).DisplayResource, global::System.Convert.ToString); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal Operation(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationInternal)this).Display = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationDisplay) content.GetValueForProperty("Display",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationInternal)this).Display, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.OperationDisplayTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationInternal)this).Name, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationInternal)this).DisplayOperation = (string) content.GetValueForProperty("DisplayOperation",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationInternal)this).DisplayOperation, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationInternal)this).DisplayProvider = (string) content.GetValueForProperty("DisplayProvider",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationInternal)this).DisplayProvider, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationInternal)this).DisplayResource = (string) content.GetValueForProperty("DisplayResource",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationInternal)this).DisplayResource, global::System.Convert.ToString); + AfterDeserializePSObject(content); + } + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// A Cost management REST API operation. + [System.ComponentModel.TypeConverter(typeof(OperationTypeConverter))] + public partial interface IOperation + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/Operation.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/Operation.TypeConverter.cs new file mode 100644 index 000000000000..5c67a94b1bb0 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/Operation.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class OperationTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperation ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperation).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return Operation.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return Operation.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return Operation.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/Operation.cs b/src/CostManagement/generated/api/Models/Api20200601/Operation.cs new file mode 100644 index 000000000000..6591fcf5b2b4 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/Operation.cs @@ -0,0 +1,112 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// A Cost management REST API operation. + public partial class Operation : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperation, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationInternal + { + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationDisplay _display; + + /// The object that represents the operation. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + internal Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationDisplay Display { get => (this._display = this._display ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.OperationDisplay()); set => this._display = value; } + + /// Operation type: Read, write, delete, etc. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string DisplayOperation { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationDisplayInternal)Display).Operation; } + + /// Service provider: Microsoft.CostManagement. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string DisplayProvider { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationDisplayInternal)Display).Provider; } + + /// Resource on which the operation is performed: Dimensions, Query. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string DisplayResource { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationDisplayInternal)Display).Resource; } + + /// Internal Acessors for Display + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationDisplay Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationInternal.Display { get => (this._display = this._display ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.OperationDisplay()); set { {_display = value;} } } + + /// Internal Acessors for DisplayOperation + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationInternal.DisplayOperation { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationDisplayInternal)Display).Operation; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationDisplayInternal)Display).Operation = value; } + + /// Internal Acessors for DisplayProvider + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationInternal.DisplayProvider { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationDisplayInternal)Display).Provider; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationDisplayInternal)Display).Provider = value; } + + /// Internal Acessors for DisplayResource + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationInternal.DisplayResource { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationDisplayInternal)Display).Resource; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationDisplayInternal)Display).Resource = value; } + + /// Internal Acessors for Name + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationInternal.Name { get => this._name; set { {_name = value;} } } + + /// Backing field for property. + private string _name; + + /// Operation name: {provider}/{resource}/{operation}. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string Name { get => this._name; } + + /// Creates an new instance. + public Operation() + { + + } + } + /// A Cost management REST API operation. + public partial interface IOperation : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// Operation type: Read, write, delete, etc. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"Operation type: Read, write, delete, etc.", + SerializedName = @"operation", + PossibleTypes = new [] { typeof(string) })] + string DisplayOperation { get; } + /// Service provider: Microsoft.CostManagement. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"Service provider: Microsoft.CostManagement.", + SerializedName = @"provider", + PossibleTypes = new [] { typeof(string) })] + string DisplayProvider { get; } + /// Resource on which the operation is performed: Dimensions, Query. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"Resource on which the operation is performed: Dimensions, Query.", + SerializedName = @"resource", + PossibleTypes = new [] { typeof(string) })] + string DisplayResource { get; } + /// Operation name: {provider}/{resource}/{operation}. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"Operation name: {provider}/{resource}/{operation}.", + SerializedName = @"name", + PossibleTypes = new [] { typeof(string) })] + string Name { get; } + + } + /// A Cost management REST API operation. + public partial interface IOperationInternal + + { + /// The object that represents the operation. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationDisplay Display { get; set; } + /// Operation type: Read, write, delete, etc. + string DisplayOperation { get; set; } + /// Service provider: Microsoft.CostManagement. + string DisplayProvider { get; set; } + /// Resource on which the operation is performed: Dimensions, Query. + string DisplayResource { get; set; } + /// Operation name: {provider}/{resource}/{operation}. + string Name { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/Operation.json.cs b/src/CostManagement/generated/api/Models/Api20200601/Operation.json.cs new file mode 100644 index 000000000000..3e9bdc0df7a6 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/Operation.json.cs @@ -0,0 +1,106 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// A Cost management REST API operation. + public partial class Operation + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperation. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperation. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperation FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new Operation(json) : null; + } + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal Operation(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_display = If( json?.PropertyT("display"), out var __jsonDisplay) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.OperationDisplay.FromJson(__jsonDisplay) : Display;} + {_name = If( json?.PropertyT("name"), out var __jsonName) ? (string)__jsonName : (string)Name;} + AfterFromJson(json); + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + AddIf( null != this._display ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._display.ToJson(null,serializationMode) : null, "display" ,container.Add ); + if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeReadOnly)) + { + AddIf( null != (((object)this._name)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._name.ToString()) : null, "name" ,container.Add ); + } + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/OperationDisplay.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/OperationDisplay.PowerShell.cs new file mode 100644 index 000000000000..89d12fc8ba32 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/OperationDisplay.PowerShell.cs @@ -0,0 +1,135 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// The object that represents the operation. + [System.ComponentModel.TypeConverter(typeof(OperationDisplayTypeConverter))] + public partial class OperationDisplay + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationDisplay DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new OperationDisplay(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationDisplay DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new OperationDisplay(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationDisplay FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal OperationDisplay(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationDisplayInternal)this).Operation = (string) content.GetValueForProperty("Operation",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationDisplayInternal)this).Operation, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationDisplayInternal)this).Provider = (string) content.GetValueForProperty("Provider",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationDisplayInternal)this).Provider, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationDisplayInternal)this).Resource = (string) content.GetValueForProperty("Resource",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationDisplayInternal)this).Resource, global::System.Convert.ToString); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal OperationDisplay(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationDisplayInternal)this).Operation = (string) content.GetValueForProperty("Operation",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationDisplayInternal)this).Operation, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationDisplayInternal)this).Provider = (string) content.GetValueForProperty("Provider",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationDisplayInternal)this).Provider, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationDisplayInternal)this).Resource = (string) content.GetValueForProperty("Resource",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationDisplayInternal)this).Resource, global::System.Convert.ToString); + AfterDeserializePSObject(content); + } + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// The object that represents the operation. + [System.ComponentModel.TypeConverter(typeof(OperationDisplayTypeConverter))] + public partial interface IOperationDisplay + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/OperationDisplay.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/OperationDisplay.TypeConverter.cs new file mode 100644 index 000000000000..f10a8bb45492 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/OperationDisplay.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class OperationDisplayTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationDisplay ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationDisplay).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return OperationDisplay.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return OperationDisplay.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return OperationDisplay.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/OperationDisplay.cs b/src/CostManagement/generated/api/Models/Api20200601/OperationDisplay.cs new file mode 100644 index 000000000000..a6337c28fcf0 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/OperationDisplay.cs @@ -0,0 +1,89 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The object that represents the operation. + public partial class OperationDisplay : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationDisplay, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationDisplayInternal + { + + /// Internal Acessors for Operation + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationDisplayInternal.Operation { get => this._operation; set { {_operation = value;} } } + + /// Internal Acessors for Provider + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationDisplayInternal.Provider { get => this._provider; set { {_provider = value;} } } + + /// Internal Acessors for Resource + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationDisplayInternal.Resource { get => this._resource; set { {_resource = value;} } } + + /// Backing field for property. + private string _operation; + + /// Operation type: Read, write, delete, etc. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string Operation { get => this._operation; } + + /// Backing field for property. + private string _provider; + + /// Service provider: Microsoft.CostManagement. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string Provider { get => this._provider; } + + /// Backing field for property. + private string _resource; + + /// Resource on which the operation is performed: Dimensions, Query. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string Resource { get => this._resource; } + + /// Creates an new instance. + public OperationDisplay() + { + + } + } + /// The object that represents the operation. + public partial interface IOperationDisplay : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// Operation type: Read, write, delete, etc. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"Operation type: Read, write, delete, etc.", + SerializedName = @"operation", + PossibleTypes = new [] { typeof(string) })] + string Operation { get; } + /// Service provider: Microsoft.CostManagement. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"Service provider: Microsoft.CostManagement.", + SerializedName = @"provider", + PossibleTypes = new [] { typeof(string) })] + string Provider { get; } + /// Resource on which the operation is performed: Dimensions, Query. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"Resource on which the operation is performed: Dimensions, Query.", + SerializedName = @"resource", + PossibleTypes = new [] { typeof(string) })] + string Resource { get; } + + } + /// The object that represents the operation. + public partial interface IOperationDisplayInternal + + { + /// Operation type: Read, write, delete, etc. + string Operation { get; set; } + /// Service provider: Microsoft.CostManagement. + string Provider { get; set; } + /// Resource on which the operation is performed: Dimensions, Query. + string Resource { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/OperationDisplay.json.cs b/src/CostManagement/generated/api/Models/Api20200601/OperationDisplay.json.cs new file mode 100644 index 000000000000..c0fc670acf9f --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/OperationDisplay.json.cs @@ -0,0 +1,114 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The object that represents the operation. + public partial class OperationDisplay + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationDisplay. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationDisplay. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationDisplay FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new OperationDisplay(json) : null; + } + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal OperationDisplay(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_operation = If( json?.PropertyT("operation"), out var __jsonOperation) ? (string)__jsonOperation : (string)Operation;} + {_provider = If( json?.PropertyT("provider"), out var __jsonProvider) ? (string)__jsonProvider : (string)Provider;} + {_resource = If( json?.PropertyT("resource"), out var __jsonResource) ? (string)__jsonResource : (string)Resource;} + AfterFromJson(json); + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeReadOnly)) + { + AddIf( null != (((object)this._operation)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._operation.ToString()) : null, "operation" ,container.Add ); + } + if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeReadOnly)) + { + AddIf( null != (((object)this._provider)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._provider.ToString()) : null, "provider" ,container.Add ); + } + if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeReadOnly)) + { + AddIf( null != (((object)this._resource)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._resource.ToString()) : null, "resource" ,container.Add ); + } + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/OperationListResult.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/OperationListResult.PowerShell.cs new file mode 100644 index 000000000000..404de3ba6901 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/OperationListResult.PowerShell.cs @@ -0,0 +1,135 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// Result of listing cost management operations. It contains a list of operations and a URL link to get the next set of results. + /// + [System.ComponentModel.TypeConverter(typeof(OperationListResultTypeConverter))] + public partial class OperationListResult + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationListResult DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new OperationListResult(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationListResult DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new OperationListResult(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationListResult FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal OperationListResult(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationListResultInternal)this).NextLink = (string) content.GetValueForProperty("NextLink",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationListResultInternal)this).NextLink, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationListResultInternal)this).Value = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperation[]) content.GetValueForProperty("Value",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationListResultInternal)this).Value, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.OperationTypeConverter.ConvertFrom)); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal OperationListResult(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationListResultInternal)this).NextLink = (string) content.GetValueForProperty("NextLink",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationListResultInternal)this).NextLink, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationListResultInternal)this).Value = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperation[]) content.GetValueForProperty("Value",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationListResultInternal)this).Value, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.OperationTypeConverter.ConvertFrom)); + AfterDeserializePSObject(content); + } + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// Result of listing cost management operations. It contains a list of operations and a URL link to get the next set of results. + [System.ComponentModel.TypeConverter(typeof(OperationListResultTypeConverter))] + public partial interface IOperationListResult + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/OperationListResult.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/OperationListResult.TypeConverter.cs new file mode 100644 index 000000000000..6dbd1fbf1f86 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/OperationListResult.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class OperationListResultTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationListResult ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationListResult).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return OperationListResult.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return OperationListResult.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return OperationListResult.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/OperationListResult.cs b/src/CostManagement/generated/api/Models/Api20200601/OperationListResult.cs new file mode 100644 index 000000000000..266853673da0 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/OperationListResult.cs @@ -0,0 +1,77 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// + /// Result of listing cost management operations. It contains a list of operations and a URL link to get the next set of results. + /// + public partial class OperationListResult : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationListResult, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationListResultInternal + { + + /// Internal Acessors for NextLink + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationListResultInternal.NextLink { get => this._nextLink; set { {_nextLink = value;} } } + + /// Internal Acessors for Value + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperation[] Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationListResultInternal.Value { get => this._value; set { {_value = value;} } } + + /// Backing field for property. + private string _nextLink; + + /// URL to get the next set of operation list results if there are any. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string NextLink { get => this._nextLink; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperation[] _value; + + /// + /// List of cost management operations supported by the Microsoft.CostManagement resource provider. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperation[] Value { get => this._value; } + + /// Creates an new instance. + public OperationListResult() + { + + } + } + /// Result of listing cost management operations. It contains a list of operations and a URL link to get the next set of results. + public partial interface IOperationListResult : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// URL to get the next set of operation list results if there are any. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"URL to get the next set of operation list results if there are any.", + SerializedName = @"nextLink", + PossibleTypes = new [] { typeof(string) })] + string NextLink { get; } + /// + /// List of cost management operations supported by the Microsoft.CostManagement resource provider. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"List of cost management operations supported by the Microsoft.CostManagement resource provider.", + SerializedName = @"value", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperation) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperation[] Value { get; } + + } + /// Result of listing cost management operations. It contains a list of operations and a URL link to get the next set of results. + public partial interface IOperationListResultInternal + + { + /// URL to get the next set of operation list results if there are any. + string NextLink { get; set; } + /// + /// List of cost management operations supported by the Microsoft.CostManagement resource provider. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperation[] Value { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/OperationListResult.json.cs b/src/CostManagement/generated/api/Models/Api20200601/OperationListResult.json.cs new file mode 100644 index 000000000000..39cda3e590a1 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/OperationListResult.json.cs @@ -0,0 +1,119 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// + /// Result of listing cost management operations. It contains a list of operations and a URL link to get the next set of results. + /// + public partial class OperationListResult + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationListResult. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationListResult. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperationListResult FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new OperationListResult(json) : null; + } + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal OperationListResult(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_nextLink = If( json?.PropertyT("nextLink"), out var __jsonNextLink) ? (string)__jsonNextLink : (string)NextLink;} + {_value = If( json?.PropertyT("value"), out var __jsonValue) ? If( __jsonValue as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonArray, out var __v) ? new global::System.Func(()=> global::System.Linq.Enumerable.ToArray(global::System.Linq.Enumerable.Select(__v, (__u)=>(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperation) (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.Operation.FromJson(__u) )) ))() : null : Value;} + AfterFromJson(json); + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeReadOnly)) + { + AddIf( null != (((object)this._nextLink)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._nextLink.ToString()) : null, "nextLink" ,container.Add ); + } + if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeReadOnly)) + { + if (null != this._value) + { + var __w = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.XNodeArray(); + foreach( var __x in this._value ) + { + AddIf(__x?.ToJson(null, serializationMode) ,__w.Add); + } + container.Add("value",__w); + } + } + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/PivotProperties.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/PivotProperties.PowerShell.cs new file mode 100644 index 000000000000..32134312ba00 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/PivotProperties.PowerShell.cs @@ -0,0 +1,133 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// Each pivot must contain a 'type' and 'name'. + [System.ComponentModel.TypeConverter(typeof(PivotPropertiesTypeConverter))] + public partial class PivotProperties + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IPivotProperties DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new PivotProperties(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IPivotProperties DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new PivotProperties(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IPivotProperties FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal PivotProperties(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IPivotPropertiesInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IPivotPropertiesInternal)this).Name, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IPivotPropertiesInternal)this).Type = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.PivotType?) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IPivotPropertiesInternal)this).Type, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.PivotType.CreateFrom); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal PivotProperties(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IPivotPropertiesInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IPivotPropertiesInternal)this).Name, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IPivotPropertiesInternal)this).Type = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.PivotType?) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IPivotPropertiesInternal)this).Type, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.PivotType.CreateFrom); + AfterDeserializePSObject(content); + } + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// Each pivot must contain a 'type' and 'name'. + [System.ComponentModel.TypeConverter(typeof(PivotPropertiesTypeConverter))] + public partial interface IPivotProperties + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/PivotProperties.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/PivotProperties.TypeConverter.cs new file mode 100644 index 000000000000..9b9f660552f3 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/PivotProperties.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class PivotPropertiesTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IPivotProperties ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IPivotProperties).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return PivotProperties.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return PivotProperties.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return PivotProperties.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/PivotProperties.cs b/src/CostManagement/generated/api/Models/Api20200601/PivotProperties.cs new file mode 100644 index 000000000000..1b6d6afb066b --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/PivotProperties.cs @@ -0,0 +1,63 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// Each pivot must contain a 'type' and 'name'. + public partial class PivotProperties : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IPivotProperties, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IPivotPropertiesInternal + { + + /// Backing field for property. + private string _name; + + /// Data field to show in view. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string Name { get => this._name; set => this._name = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.PivotType? _type; + + /// Data type to show in view. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.PivotType? Type { get => this._type; set => this._type = value; } + + /// Creates an new instance. + public PivotProperties() + { + + } + } + /// Each pivot must contain a 'type' and 'name'. + public partial interface IPivotProperties : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// Data field to show in view. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Data field to show in view.", + SerializedName = @"name", + PossibleTypes = new [] { typeof(string) })] + string Name { get; set; } + /// Data type to show in view. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Data type to show in view.", + SerializedName = @"type", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.PivotType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.PivotType? Type { get; set; } + + } + /// Each pivot must contain a 'type' and 'name'. + public partial interface IPivotPropertiesInternal + + { + /// Data field to show in view. + string Name { get; set; } + /// Data type to show in view. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.PivotType? Type { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/PivotProperties.json.cs b/src/CostManagement/generated/api/Models/Api20200601/PivotProperties.json.cs new file mode 100644 index 000000000000..b14da82f42b1 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/PivotProperties.json.cs @@ -0,0 +1,103 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// Each pivot must contain a 'type' and 'name'. + public partial class PivotProperties + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IPivotProperties. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IPivotProperties. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IPivotProperties FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new PivotProperties(json) : null; + } + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal PivotProperties(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_name = If( json?.PropertyT("name"), out var __jsonName) ? (string)__jsonName : (string)Name;} + {_type = If( json?.PropertyT("type"), out var __jsonType) ? (string)__jsonType : (string)Type;} + AfterFromJson(json); + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + AddIf( null != (((object)this._name)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._name.ToString()) : null, "name" ,container.Add ); + AddIf( null != (((object)this._type)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._type.ToString()) : null, "type" ,container.Add ); + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ProxyResource.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/ProxyResource.PowerShell.cs new file mode 100644 index 000000000000..3c0dfb4da842 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ProxyResource.PowerShell.cs @@ -0,0 +1,137 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// The Resource model definition. + [System.ComponentModel.TypeConverter(typeof(ProxyResourceTypeConverter))] + public partial class ProxyResource + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResource DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new ProxyResource(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResource DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new ProxyResource(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResource FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal ProxyResource(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)this).Name, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)this).Type = (string) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)this).Type, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)this).ETag = (string) content.GetValueForProperty("ETag",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)this).ETag, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)this).Id = (string) content.GetValueForProperty("Id",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)this).Id, global::System.Convert.ToString); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal ProxyResource(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)this).Name, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)this).Type = (string) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)this).Type, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)this).ETag = (string) content.GetValueForProperty("ETag",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)this).ETag, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)this).Id = (string) content.GetValueForProperty("Id",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)this).Id, global::System.Convert.ToString); + AfterDeserializePSObject(content); + } + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// The Resource model definition. + [System.ComponentModel.TypeConverter(typeof(ProxyResourceTypeConverter))] + public partial interface IProxyResource + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ProxyResource.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/ProxyResource.TypeConverter.cs new file mode 100644 index 000000000000..88d74f53c021 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ProxyResource.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class ProxyResourceTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResource ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResource).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return ProxyResource.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return ProxyResource.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return ProxyResource.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ProxyResource.cs b/src/CostManagement/generated/api/Models/Api20200601/ProxyResource.cs new file mode 100644 index 000000000000..eabb0086e29e --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ProxyResource.cs @@ -0,0 +1,115 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The Resource model definition. + public partial class ProxyResource : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResource, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal + { + + /// Backing field for property. + private string _eTag; + + /// + /// eTag of the resource. To handle concurrent update scenario, this field will be used to determine whether the user is updating + /// the latest version or not. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string ETag { get => this._eTag; set => this._eTag = value; } + + /// Backing field for property. + private string _id; + + /// Resource Id. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string Id { get => this._id; } + + /// Internal Acessors for Id + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal.Id { get => this._id; set { {_id = value;} } } + + /// Internal Acessors for Name + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal.Name { get => this._name; set { {_name = value;} } } + + /// Internal Acessors for Type + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal.Type { get => this._type; set { {_type = value;} } } + + /// Backing field for property. + private string _name; + + /// Resource name. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string Name { get => this._name; } + + /// Backing field for property. + private string _type; + + /// Resource type. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string Type { get => this._type; } + + /// Creates an new instance. + public ProxyResource() + { + + } + } + /// The Resource model definition. + public partial interface IProxyResource : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// + /// eTag of the resource. To handle concurrent update scenario, this field will be used to determine whether the user is updating + /// the latest version or not. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"eTag of the resource. To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not.", + SerializedName = @"eTag", + PossibleTypes = new [] { typeof(string) })] + string ETag { get; set; } + /// Resource Id. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"Resource Id.", + SerializedName = @"id", + PossibleTypes = new [] { typeof(string) })] + string Id { get; } + /// Resource name. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"Resource name.", + SerializedName = @"name", + PossibleTypes = new [] { typeof(string) })] + string Name { get; } + /// Resource type. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"Resource type.", + SerializedName = @"type", + PossibleTypes = new [] { typeof(string) })] + string Type { get; } + + } + /// The Resource model definition. + public partial interface IProxyResourceInternal + + { + /// + /// eTag of the resource. To handle concurrent update scenario, this field will be used to determine whether the user is updating + /// the latest version or not. + /// + string ETag { get; set; } + /// Resource Id. + string Id { get; set; } + /// Resource name. + string Name { get; set; } + /// Resource type. + string Type { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ProxyResource.json.cs b/src/CostManagement/generated/api/Models/Api20200601/ProxyResource.json.cs new file mode 100644 index 000000000000..4834fde8f4c8 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ProxyResource.json.cs @@ -0,0 +1,116 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The Resource model definition. + public partial class ProxyResource + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResource. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResource. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResource FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new ProxyResource(json) : null; + } + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal ProxyResource(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_name = If( json?.PropertyT("name"), out var __jsonName) ? (string)__jsonName : (string)Name;} + {_type = If( json?.PropertyT("type"), out var __jsonType) ? (string)__jsonType : (string)Type;} + {_eTag = If( json?.PropertyT("eTag"), out var __jsonETag) ? (string)__jsonETag : (string)ETag;} + {_id = If( json?.PropertyT("id"), out var __jsonId) ? (string)__jsonId : (string)Id;} + AfterFromJson(json); + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeReadOnly)) + { + AddIf( null != (((object)this._name)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._name.ToString()) : null, "name" ,container.Add ); + } + if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeReadOnly)) + { + AddIf( null != (((object)this._type)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._type.ToString()) : null, "type" ,container.Add ); + } + AddIf( null != (((object)this._eTag)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._eTag.ToString()) : null, "eTag" ,container.Add ); + if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeReadOnly)) + { + AddIf( null != (((object)this._id)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._id.ToString()) : null, "id" ,container.Add ); + } + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/QueryAggregation.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/QueryAggregation.PowerShell.cs new file mode 100644 index 000000000000..5fb110e6a087 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/QueryAggregation.PowerShell.cs @@ -0,0 +1,133 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// The aggregation expression to be used in the query. + [System.ComponentModel.TypeConverter(typeof(QueryAggregationTypeConverter))] + public partial class QueryAggregation + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryAggregation DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new QueryAggregation(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryAggregation DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new QueryAggregation(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryAggregation FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal QueryAggregation(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryAggregationInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryAggregationInternal)this).Name, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryAggregationInternal)this).Function = (string) content.GetValueForProperty("Function",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryAggregationInternal)this).Function, global::System.Convert.ToString); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal QueryAggregation(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryAggregationInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryAggregationInternal)this).Name, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryAggregationInternal)this).Function = (string) content.GetValueForProperty("Function",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryAggregationInternal)this).Function, global::System.Convert.ToString); + AfterDeserializePSObject(content); + } + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// The aggregation expression to be used in the query. + [System.ComponentModel.TypeConverter(typeof(QueryAggregationTypeConverter))] + public partial interface IQueryAggregation + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/QueryAggregation.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/QueryAggregation.TypeConverter.cs new file mode 100644 index 000000000000..988e2b9da0d4 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/QueryAggregation.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class QueryAggregationTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryAggregation ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryAggregation).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return QueryAggregation.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return QueryAggregation.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return QueryAggregation.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/QueryAggregation.cs b/src/CostManagement/generated/api/Models/Api20200601/QueryAggregation.cs new file mode 100644 index 000000000000..7ad13501050e --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/QueryAggregation.cs @@ -0,0 +1,66 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The aggregation expression to be used in the query. + public partial class QueryAggregation : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryAggregation, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryAggregationInternal + { + + /// Backing field for property. + private string _function= @"Sum"; + + /// The name of the aggregation function to use. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string Function { get => this._function; } + + /// Internal Acessors for Function + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryAggregationInternal.Function { get => this._function; set { {_function = value;} } } + + /// Backing field for property. + private string _name; + + /// The name of the column to aggregate. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string Name { get => this._name; set => this._name = value; } + + /// Creates an new instance. + public QueryAggregation() + { + + } + } + /// The aggregation expression to be used in the query. + public partial interface IQueryAggregation : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// The name of the aggregation function to use. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = true, + Description = @"The name of the aggregation function to use.", + SerializedName = @"function", + PossibleTypes = new [] { typeof(string) })] + string Function { get; } + /// The name of the column to aggregate. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The name of the column to aggregate.", + SerializedName = @"name", + PossibleTypes = new [] { typeof(string) })] + string Name { get; set; } + + } + /// The aggregation expression to be used in the query. + public partial interface IQueryAggregationInternal + + { + /// The name of the aggregation function to use. + string Function { get; set; } + /// The name of the column to aggregate. + string Name { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/QueryAggregation.json.cs b/src/CostManagement/generated/api/Models/Api20200601/QueryAggregation.json.cs new file mode 100644 index 000000000000..d794951f17c5 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/QueryAggregation.json.cs @@ -0,0 +1,103 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The aggregation expression to be used in the query. + public partial class QueryAggregation + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryAggregation. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryAggregation. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryAggregation FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new QueryAggregation(json) : null; + } + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal QueryAggregation(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_name = If( json?.PropertyT("name"), out var __jsonName) ? (string)__jsonName : (string)Name;} + {_function = If( json?.PropertyT("function"), out var __jsonFunction) ? (string)__jsonFunction : (string)Function;} + AfterFromJson(json); + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + AddIf( null != (((object)this._name)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._name.ToString()) : null, "name" ,container.Add ); + AddIf( null != (((object)this._function)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._function.ToString()) : null, "function" ,container.Add ); + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/QueryColumn.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/QueryColumn.PowerShell.cs new file mode 100644 index 000000000000..f772224803f1 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/QueryColumn.PowerShell.cs @@ -0,0 +1,131 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + [System.ComponentModel.TypeConverter(typeof(QueryColumnTypeConverter))] + public partial class QueryColumn + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryColumn DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new QueryColumn(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryColumn DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new QueryColumn(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryColumn FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal QueryColumn(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryColumnInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryColumnInternal)this).Name, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryColumnInternal)this).Type = (string) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryColumnInternal)this).Type, global::System.Convert.ToString); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal QueryColumn(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryColumnInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryColumnInternal)this).Name, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryColumnInternal)this).Type = (string) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryColumnInternal)this).Type, global::System.Convert.ToString); + AfterDeserializePSObject(content); + } + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + [System.ComponentModel.TypeConverter(typeof(QueryColumnTypeConverter))] + public partial interface IQueryColumn + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/QueryColumn.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/QueryColumn.TypeConverter.cs new file mode 100644 index 000000000000..74ccd85a870f --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/QueryColumn.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class QueryColumnTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryColumn ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryColumn).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return QueryColumn.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return QueryColumn.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return QueryColumn.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/QueryColumn.cs b/src/CostManagement/generated/api/Models/Api20200601/QueryColumn.cs new file mode 100644 index 000000000000..b25dafcbc6cd --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/QueryColumn.cs @@ -0,0 +1,60 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + public partial class QueryColumn : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryColumn, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryColumnInternal + { + + /// Backing field for property. + private string _name; + + /// The name of column. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string Name { get => this._name; set => this._name = value; } + + /// Backing field for property. + private string _type; + + /// The type of column. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string Type { get => this._type; set => this._type = value; } + + /// Creates an new instance. + public QueryColumn() + { + + } + } + public partial interface IQueryColumn : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// The name of column. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The name of column.", + SerializedName = @"name", + PossibleTypes = new [] { typeof(string) })] + string Name { get; set; } + /// The type of column. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The type of column.", + SerializedName = @"type", + PossibleTypes = new [] { typeof(string) })] + string Type { get; set; } + + } + public partial interface IQueryColumnInternal + + { + /// The name of column. + string Name { get; set; } + /// The type of column. + string Type { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/QueryColumn.json.cs b/src/CostManagement/generated/api/Models/Api20200601/QueryColumn.json.cs new file mode 100644 index 000000000000..0349cf034612 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/QueryColumn.json.cs @@ -0,0 +1,102 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + public partial class QueryColumn + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryColumn. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryColumn. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryColumn FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new QueryColumn(json) : null; + } + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal QueryColumn(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_name = If( json?.PropertyT("name"), out var __jsonName) ? (string)__jsonName : (string)Name;} + {_type = If( json?.PropertyT("type"), out var __jsonType) ? (string)__jsonType : (string)Type;} + AfterFromJson(json); + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + AddIf( null != (((object)this._name)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._name.ToString()) : null, "name" ,container.Add ); + AddIf( null != (((object)this._type)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._type.ToString()) : null, "type" ,container.Add ); + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/QueryComparisonExpression.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/QueryComparisonExpression.PowerShell.cs new file mode 100644 index 000000000000..ca9df90863b0 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/QueryComparisonExpression.PowerShell.cs @@ -0,0 +1,137 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// The comparison expression to be used in the query. + [System.ComponentModel.TypeConverter(typeof(QueryComparisonExpressionTypeConverter))] + public partial class QueryComparisonExpression + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryComparisonExpression DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new QueryComparisonExpression(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryComparisonExpression DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new QueryComparisonExpression(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryComparisonExpression FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal QueryComparisonExpression(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryComparisonExpressionInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryComparisonExpressionInternal)this).Name, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryComparisonExpressionInternal)this).Operator = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.OperatorType) content.GetValueForProperty("Operator",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryComparisonExpressionInternal)this).Operator, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.OperatorType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryComparisonExpressionInternal)this).Value = (string[]) content.GetValueForProperty("Value",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryComparisonExpressionInternal)this).Value, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal QueryComparisonExpression(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryComparisonExpressionInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryComparisonExpressionInternal)this).Name, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryComparisonExpressionInternal)this).Operator = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.OperatorType) content.GetValueForProperty("Operator",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryComparisonExpressionInternal)this).Operator, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.OperatorType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryComparisonExpressionInternal)this).Value = (string[]) content.GetValueForProperty("Value",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryComparisonExpressionInternal)this).Value, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + AfterDeserializePSObject(content); + } + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// The comparison expression to be used in the query. + [System.ComponentModel.TypeConverter(typeof(QueryComparisonExpressionTypeConverter))] + public partial interface IQueryComparisonExpression + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/QueryComparisonExpression.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/QueryComparisonExpression.TypeConverter.cs new file mode 100644 index 000000000000..7c0fe286c3db --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/QueryComparisonExpression.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class QueryComparisonExpressionTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryComparisonExpression ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryComparisonExpression).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return QueryComparisonExpression.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return QueryComparisonExpression.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return QueryComparisonExpression.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/QueryComparisonExpression.cs b/src/CostManagement/generated/api/Models/Api20200601/QueryComparisonExpression.cs new file mode 100644 index 000000000000..6b19a2a2cf4e --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/QueryComparisonExpression.cs @@ -0,0 +1,80 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The comparison expression to be used in the query. + public partial class QueryComparisonExpression : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryComparisonExpression, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryComparisonExpressionInternal + { + + /// Backing field for property. + private string _name; + + /// The name of the column to use in comparison. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string Name { get => this._name; set => this._name = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.OperatorType _operator; + + /// The operator to use for comparison. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.OperatorType Operator { get => this._operator; set => this._operator = value; } + + /// Backing field for property. + private string[] _value; + + /// Array of values to use for comparison + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string[] Value { get => this._value; set => this._value = value; } + + /// Creates an new instance. + public QueryComparisonExpression() + { + + } + } + /// The comparison expression to be used in the query. + public partial interface IQueryComparisonExpression : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// The name of the column to use in comparison. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The name of the column to use in comparison.", + SerializedName = @"name", + PossibleTypes = new [] { typeof(string) })] + string Name { get; set; } + /// The operator to use for comparison. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The operator to use for comparison.", + SerializedName = @"operator", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.OperatorType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.OperatorType Operator { get; set; } + /// Array of values to use for comparison + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"Array of values to use for comparison", + SerializedName = @"values", + PossibleTypes = new [] { typeof(string) })] + string[] Value { get; set; } + + } + /// The comparison expression to be used in the query. + public partial interface IQueryComparisonExpressionInternal + + { + /// The name of the column to use in comparison. + string Name { get; set; } + /// The operator to use for comparison. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.OperatorType Operator { get; set; } + /// Array of values to use for comparison + string[] Value { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/QueryComparisonExpression.json.cs b/src/CostManagement/generated/api/Models/Api20200601/QueryComparisonExpression.json.cs new file mode 100644 index 000000000000..3b7ba4a8f57f --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/QueryComparisonExpression.json.cs @@ -0,0 +1,113 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The comparison expression to be used in the query. + public partial class QueryComparisonExpression + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryComparisonExpression. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryComparisonExpression. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryComparisonExpression FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new QueryComparisonExpression(json) : null; + } + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal QueryComparisonExpression(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_name = If( json?.PropertyT("name"), out var __jsonName) ? (string)__jsonName : (string)Name;} + {_operator = If( json?.PropertyT("operator"), out var __jsonOperator) ? (string)__jsonOperator : (string)Operator;} + {_value = If( json?.PropertyT("values"), out var __jsonValues) ? If( __jsonValues as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonArray, out var __v) ? new global::System.Func(()=> global::System.Linq.Enumerable.ToArray(global::System.Linq.Enumerable.Select(__v, (__u)=>(string) (__u is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString __t ? (string)(__t.ToString()) : null)) ))() : null : Value;} + AfterFromJson(json); + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + AddIf( null != (((object)this._name)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._name.ToString()) : null, "name" ,container.Add ); + AddIf( null != (((object)this._operator)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._operator.ToString()) : null, "operator" ,container.Add ); + if (null != this._value) + { + var __w = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.XNodeArray(); + foreach( var __x in this._value ) + { + AddIf(null != (((object)__x)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(__x.ToString()) : null ,__w.Add); + } + container.Add("values",__w); + } + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/QueryDataset.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/QueryDataset.PowerShell.cs new file mode 100644 index 000000000000..16c3c162ba85 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/QueryDataset.PowerShell.cs @@ -0,0 +1,141 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// The definition of data present in the query. + [System.ComponentModel.TypeConverter(typeof(QueryDatasetTypeConverter))] + public partial class QueryDataset + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDataset DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new QueryDataset(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDataset DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new QueryDataset(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDataset FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal QueryDataset(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetInternal)this).Configuration = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetConfiguration) content.GetValueForProperty("Configuration",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetInternal)this).Configuration, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryDatasetConfigurationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetInternal)this).Aggregation = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetAggregation) content.GetValueForProperty("Aggregation",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetInternal)this).Aggregation, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryDatasetAggregationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetInternal)this).Filter = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter) content.GetValueForProperty("Filter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetInternal)this).Filter, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryFilterTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetInternal)this).Granularity = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType?) content.GetValueForProperty("Granularity",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetInternal)this).Granularity, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetInternal)this).Grouping = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryGrouping[]) content.GetValueForProperty("Grouping",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetInternal)this).Grouping, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryGroupingTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetInternal)this).ConfigurationColumn = (string[]) content.GetValueForProperty("ConfigurationColumn",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetInternal)this).ConfigurationColumn, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal QueryDataset(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetInternal)this).Configuration = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetConfiguration) content.GetValueForProperty("Configuration",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetInternal)this).Configuration, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryDatasetConfigurationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetInternal)this).Aggregation = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetAggregation) content.GetValueForProperty("Aggregation",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetInternal)this).Aggregation, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryDatasetAggregationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetInternal)this).Filter = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter) content.GetValueForProperty("Filter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetInternal)this).Filter, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryFilterTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetInternal)this).Granularity = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType?) content.GetValueForProperty("Granularity",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetInternal)this).Granularity, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetInternal)this).Grouping = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryGrouping[]) content.GetValueForProperty("Grouping",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetInternal)this).Grouping, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryGroupingTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetInternal)this).ConfigurationColumn = (string[]) content.GetValueForProperty("ConfigurationColumn",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetInternal)this).ConfigurationColumn, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + AfterDeserializePSObject(content); + } + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// The definition of data present in the query. + [System.ComponentModel.TypeConverter(typeof(QueryDatasetTypeConverter))] + public partial interface IQueryDataset + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/QueryDataset.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/QueryDataset.TypeConverter.cs new file mode 100644 index 000000000000..a79d50f86f70 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/QueryDataset.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class QueryDatasetTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDataset ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDataset).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return QueryDataset.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return QueryDataset.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return QueryDataset.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/QueryDataset.cs b/src/CostManagement/generated/api/Models/Api20200601/QueryDataset.cs new file mode 100644 index 000000000000..1982b61a71a6 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/QueryDataset.cs @@ -0,0 +1,153 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The definition of data present in the query. + public partial class QueryDataset : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDataset, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetInternal + { + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetAggregation _aggregation; + + /// + /// Dictionary of aggregation expression to use in the query. The key of each item in the dictionary is the alias for the + /// aggregated column. Query can have up to 2 aggregation clauses. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetAggregation Aggregation { get => (this._aggregation = this._aggregation ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryDatasetAggregation()); set => this._aggregation = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetConfiguration _configuration; + + /// + /// Has configuration information for the data in the export. The configuration will be ignored if aggregation and grouping + /// are provided. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + internal Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetConfiguration Configuration { get => (this._configuration = this._configuration ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryDatasetConfiguration()); set => this._configuration = value; } + + /// + /// Array of column names to be included in the query. Any valid query column name is allowed. If not provided, then query + /// includes all columns. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string[] ConfigurationColumn { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetConfigurationInternal)Configuration).Column; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetConfigurationInternal)Configuration).Column = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter _filter; + + /// Has filter expression to use in the query. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter Filter { get => (this._filter = this._filter ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryFilter()); set => this._filter = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType? _granularity; + + /// The granularity of rows in the query. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType? Granularity { get => this._granularity; set => this._granularity = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryGrouping[] _grouping; + + /// + /// Array of group by expression to use in the query. Query can have up to 2 group by clauses. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryGrouping[] Grouping { get => this._grouping; set => this._grouping = value; } + + /// Internal Acessors for Configuration + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetConfiguration Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetInternal.Configuration { get => (this._configuration = this._configuration ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryDatasetConfiguration()); set { {_configuration = value;} } } + + /// Creates an new instance. + public QueryDataset() + { + + } + } + /// The definition of data present in the query. + public partial interface IQueryDataset : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// + /// Dictionary of aggregation expression to use in the query. The key of each item in the dictionary is the alias for the + /// aggregated column. Query can have up to 2 aggregation clauses. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Dictionary of aggregation expression to use in the query. The key of each item in the dictionary is the alias for the aggregated column. Query can have up to 2 aggregation clauses.", + SerializedName = @"aggregation", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetAggregation) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetAggregation Aggregation { get; set; } + /// + /// Array of column names to be included in the query. Any valid query column name is allowed. If not provided, then query + /// includes all columns. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Array of column names to be included in the query. Any valid query column name is allowed. If not provided, then query includes all columns.", + SerializedName = @"columns", + PossibleTypes = new [] { typeof(string) })] + string[] ConfigurationColumn { get; set; } + /// Has filter expression to use in the query. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Has filter expression to use in the query.", + SerializedName = @"filter", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter Filter { get; set; } + /// The granularity of rows in the query. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The granularity of rows in the query.", + SerializedName = @"granularity", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType? Granularity { get; set; } + /// + /// Array of group by expression to use in the query. Query can have up to 2 group by clauses. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Array of group by expression to use in the query. Query can have up to 2 group by clauses.", + SerializedName = @"grouping", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryGrouping) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryGrouping[] Grouping { get; set; } + + } + /// The definition of data present in the query. + public partial interface IQueryDatasetInternal + + { + /// + /// Dictionary of aggregation expression to use in the query. The key of each item in the dictionary is the alias for the + /// aggregated column. Query can have up to 2 aggregation clauses. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetAggregation Aggregation { get; set; } + /// + /// Has configuration information for the data in the export. The configuration will be ignored if aggregation and grouping + /// are provided. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetConfiguration Configuration { get; set; } + /// + /// Array of column names to be included in the query. Any valid query column name is allowed. If not provided, then query + /// includes all columns. + /// + string[] ConfigurationColumn { get; set; } + /// Has filter expression to use in the query. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter Filter { get; set; } + /// The granularity of rows in the query. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType? Granularity { get; set; } + /// + /// Array of group by expression to use in the query. Query can have up to 2 group by clauses. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryGrouping[] Grouping { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/QueryDataset.json.cs b/src/CostManagement/generated/api/Models/Api20200601/QueryDataset.json.cs new file mode 100644 index 000000000000..1252d701a70a --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/QueryDataset.json.cs @@ -0,0 +1,117 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The definition of data present in the query. + public partial class QueryDataset + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDataset. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDataset. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDataset FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new QueryDataset(json) : null; + } + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal QueryDataset(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_configuration = If( json?.PropertyT("configuration"), out var __jsonConfiguration) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryDatasetConfiguration.FromJson(__jsonConfiguration) : Configuration;} + {_aggregation = If( json?.PropertyT("aggregation"), out var __jsonAggregation) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryDatasetAggregation.FromJson(__jsonAggregation) : Aggregation;} + {_filter = If( json?.PropertyT("filter"), out var __jsonFilter) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryFilter.FromJson(__jsonFilter) : Filter;} + {_granularity = If( json?.PropertyT("granularity"), out var __jsonGranularity) ? (string)__jsonGranularity : (string)Granularity;} + {_grouping = If( json?.PropertyT("grouping"), out var __jsonGrouping) ? If( __jsonGrouping as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonArray, out var __v) ? new global::System.Func(()=> global::System.Linq.Enumerable.ToArray(global::System.Linq.Enumerable.Select(__v, (__u)=>(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryGrouping) (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryGrouping.FromJson(__u) )) ))() : null : Grouping;} + AfterFromJson(json); + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + AddIf( null != this._configuration ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._configuration.ToJson(null,serializationMode) : null, "configuration" ,container.Add ); + AddIf( null != this._aggregation ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._aggregation.ToJson(null,serializationMode) : null, "aggregation" ,container.Add ); + AddIf( null != this._filter ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._filter.ToJson(null,serializationMode) : null, "filter" ,container.Add ); + AddIf( null != (((object)this._granularity)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._granularity.ToString()) : null, "granularity" ,container.Add ); + if (null != this._grouping) + { + var __w = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.XNodeArray(); + foreach( var __x in this._grouping ) + { + AddIf(__x?.ToJson(null, serializationMode) ,__w.Add); + } + container.Add("grouping",__w); + } + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/QueryDatasetAggregation.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/QueryDatasetAggregation.PowerShell.cs new file mode 100644 index 000000000000..f0d9237e2446 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/QueryDatasetAggregation.PowerShell.cs @@ -0,0 +1,139 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// Dictionary of aggregation expression to use in the query. The key of each item in the dictionary is the alias for the + /// aggregated column. Query can have up to 2 aggregation clauses. + /// + [System.ComponentModel.TypeConverter(typeof(QueryDatasetAggregationTypeConverter))] + public partial class QueryDatasetAggregation + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetAggregation DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new QueryDatasetAggregation(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetAggregation DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new QueryDatasetAggregation(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetAggregation FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal QueryDatasetAggregation(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + // this type is a dictionary; copy elements from source to here. + CopyFrom(content); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal QueryDatasetAggregation(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + // this type is a dictionary; copy elements from source to here. + CopyFrom(content); + AfterDeserializePSObject(content); + } + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// Dictionary of aggregation expression to use in the query. The key of each item in the dictionary is the alias for the + /// aggregated column. Query can have up to 2 aggregation clauses. + [System.ComponentModel.TypeConverter(typeof(QueryDatasetAggregationTypeConverter))] + public partial interface IQueryDatasetAggregation + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/QueryDatasetAggregation.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/QueryDatasetAggregation.TypeConverter.cs new file mode 100644 index 000000000000..aedfd88f2bd5 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/QueryDatasetAggregation.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class QueryDatasetAggregationTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetAggregation ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetAggregation).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return QueryDatasetAggregation.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return QueryDatasetAggregation.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return QueryDatasetAggregation.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/QueryDatasetAggregation.cs b/src/CostManagement/generated/api/Models/Api20200601/QueryDatasetAggregation.cs new file mode 100644 index 000000000000..e41e3644b232 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/QueryDatasetAggregation.cs @@ -0,0 +1,35 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// + /// Dictionary of aggregation expression to use in the query. The key of each item in the dictionary is the alias for the + /// aggregated column. Query can have up to 2 aggregation clauses. + /// + public partial class QueryDatasetAggregation : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetAggregation, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetAggregationInternal + { + + /// Creates an new instance. + public QueryDatasetAggregation() + { + + } + } + /// Dictionary of aggregation expression to use in the query. The key of each item in the dictionary is the alias for the + /// aggregated column. Query can have up to 2 aggregation clauses. + public partial interface IQueryDatasetAggregation : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IAssociativeArray + { + + } + /// Dictionary of aggregation expression to use in the query. The key of each item in the dictionary is the alias for the + /// aggregated column. Query can have up to 2 aggregation clauses. + public partial interface IQueryDatasetAggregationInternal + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/QueryDatasetAggregation.dictionary.cs b/src/CostManagement/generated/api/Models/Api20200601/QueryDatasetAggregation.dictionary.cs new file mode 100644 index 000000000000..86293ab5b131 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/QueryDatasetAggregation.dictionary.cs @@ -0,0 +1,70 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + public partial class QueryDatasetAggregation : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IAssociativeArray + { + protected global::System.Collections.Generic.Dictionary __additionalProperties = new global::System.Collections.Generic.Dictionary(); + + global::System.Collections.Generic.IDictionary Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IAssociativeArray.AdditionalProperties { get => __additionalProperties; } + + int Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IAssociativeArray.Count { get => __additionalProperties.Count; } + + global::System.Collections.Generic.IEnumerable Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IAssociativeArray.Keys { get => __additionalProperties.Keys; } + + global::System.Collections.Generic.IEnumerable Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IAssociativeArray.Values { get => __additionalProperties.Values; } + + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryAggregation this[global::System.String index] { get => __additionalProperties[index]; set => __additionalProperties[index] = value; } + + /// + /// + public void Add(global::System.String key, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryAggregation value) => __additionalProperties.Add( key, value); + + public void Clear() => __additionalProperties.Clear(); + + /// + public bool ContainsKey(global::System.String key) => __additionalProperties.ContainsKey( key); + + /// + public void CopyFrom(global::System.Collections.IDictionary source) + { + if (null != source) + { + foreach( var property in Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.TypeConverterExtensions.GetFilteredProperties(source, new global::System.Collections.Generic.HashSet() { } ) ) + { + if ((null != property.Key && null != property.Value)) + { + this.__additionalProperties.Add(property.Key.ToString(), global::System.Management.Automation.LanguagePrimitives.ConvertTo( property.Value)); + } + } + } + } + + /// + public void CopyFrom(global::System.Management.Automation.PSObject source) + { + if (null != source) + { + foreach( var property in Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.TypeConverterExtensions.GetFilteredProperties(source, new global::System.Collections.Generic.HashSet() { } ) ) + { + if ((null != property.Key && null != property.Value)) + { + this.__additionalProperties.Add(property.Key.ToString(), global::System.Management.Automation.LanguagePrimitives.ConvertTo( property.Value)); + } + } + } + } + + /// + public bool Remove(global::System.String key) => __additionalProperties.Remove( key); + + /// + /// + public bool TryGetValue(global::System.String key, out Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryAggregation value) => __additionalProperties.TryGetValue( key, out value); + + /// + + public static implicit operator global::System.Collections.Generic.Dictionary(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryDatasetAggregation source) => source.__additionalProperties; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/QueryDatasetAggregation.json.cs b/src/CostManagement/generated/api/Models/Api20200601/QueryDatasetAggregation.json.cs new file mode 100644 index 000000000000..438e146dc748 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/QueryDatasetAggregation.json.cs @@ -0,0 +1,105 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// + /// Dictionary of aggregation expression to use in the query. The key of each item in the dictionary is the alias for the + /// aggregated column. Query can have up to 2 aggregation clauses. + /// + public partial class QueryDatasetAggregation + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetAggregation. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetAggregation. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetAggregation FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new QueryDatasetAggregation(json) : null; + } + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + /// + internal QueryDatasetAggregation(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, global::System.Collections.Generic.HashSet exclusions = null) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.JsonSerializable.FromJson( json, ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IAssociativeArray)this).AdditionalProperties, null ,exclusions ); + AfterFromJson(json); + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.JsonSerializable.ToJson( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IAssociativeArray)this).AdditionalProperties, container); + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/QueryDatasetConfiguration.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/QueryDatasetConfiguration.PowerShell.cs new file mode 100644 index 000000000000..71af335b9b30 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/QueryDatasetConfiguration.PowerShell.cs @@ -0,0 +1,133 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// The configuration of dataset in the query. + [System.ComponentModel.TypeConverter(typeof(QueryDatasetConfigurationTypeConverter))] + public partial class QueryDatasetConfiguration + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetConfiguration DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new QueryDatasetConfiguration(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetConfiguration DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new QueryDatasetConfiguration(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetConfiguration FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal QueryDatasetConfiguration(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetConfigurationInternal)this).Column = (string[]) content.GetValueForProperty("Column",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetConfigurationInternal)this).Column, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal QueryDatasetConfiguration(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetConfigurationInternal)this).Column = (string[]) content.GetValueForProperty("Column",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetConfigurationInternal)this).Column, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + AfterDeserializePSObject(content); + } + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// The configuration of dataset in the query. + [System.ComponentModel.TypeConverter(typeof(QueryDatasetConfigurationTypeConverter))] + public partial interface IQueryDatasetConfiguration + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/QueryDatasetConfiguration.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/QueryDatasetConfiguration.TypeConverter.cs new file mode 100644 index 000000000000..7c88b896c991 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/QueryDatasetConfiguration.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class QueryDatasetConfigurationTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetConfiguration ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetConfiguration).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return QueryDatasetConfiguration.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return QueryDatasetConfiguration.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return QueryDatasetConfiguration.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/QueryDatasetConfiguration.cs b/src/CostManagement/generated/api/Models/Api20200601/QueryDatasetConfiguration.cs new file mode 100644 index 000000000000..f7eedcfeb8e5 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/QueryDatasetConfiguration.cs @@ -0,0 +1,55 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The configuration of dataset in the query. + public partial class QueryDatasetConfiguration : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetConfiguration, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetConfigurationInternal + { + + /// Backing field for property. + private string[] _column; + + /// + /// Array of column names to be included in the query. Any valid query column name is allowed. If not provided, then query + /// includes all columns. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string[] Column { get => this._column; set => this._column = value; } + + /// Creates an new instance. + public QueryDatasetConfiguration() + { + + } + } + /// The configuration of dataset in the query. + public partial interface IQueryDatasetConfiguration : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// + /// Array of column names to be included in the query. Any valid query column name is allowed. If not provided, then query + /// includes all columns. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Array of column names to be included in the query. Any valid query column name is allowed. If not provided, then query includes all columns.", + SerializedName = @"columns", + PossibleTypes = new [] { typeof(string) })] + string[] Column { get; set; } + + } + /// The configuration of dataset in the query. + public partial interface IQueryDatasetConfigurationInternal + + { + /// + /// Array of column names to be included in the query. Any valid query column name is allowed. If not provided, then query + /// includes all columns. + /// + string[] Column { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/QueryDatasetConfiguration.json.cs b/src/CostManagement/generated/api/Models/Api20200601/QueryDatasetConfiguration.json.cs new file mode 100644 index 000000000000..05bceb29a115 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/QueryDatasetConfiguration.json.cs @@ -0,0 +1,109 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The configuration of dataset in the query. + public partial class QueryDatasetConfiguration + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetConfiguration. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetConfiguration. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetConfiguration FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new QueryDatasetConfiguration(json) : null; + } + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal QueryDatasetConfiguration(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_column = If( json?.PropertyT("columns"), out var __jsonColumns) ? If( __jsonColumns as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonArray, out var __v) ? new global::System.Func(()=> global::System.Linq.Enumerable.ToArray(global::System.Linq.Enumerable.Select(__v, (__u)=>(string) (__u is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString __t ? (string)(__t.ToString()) : null)) ))() : null : Column;} + AfterFromJson(json); + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + if (null != this._column) + { + var __w = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.XNodeArray(); + foreach( var __x in this._column ) + { + AddIf(null != (((object)__x)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(__x.ToString()) : null ,__w.Add); + } + container.Add("columns",__w); + } + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/QueryDefinition.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/QueryDefinition.PowerShell.cs new file mode 100644 index 000000000000..dbdc3842a0fd --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/QueryDefinition.PowerShell.cs @@ -0,0 +1,153 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// The definition of a query. + [System.ComponentModel.TypeConverter(typeof(QueryDefinitionTypeConverter))] + public partial class QueryDefinition + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinition DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new QueryDefinition(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinition DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new QueryDefinition(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinition FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal QueryDefinition(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal)this).Dataset = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDataset) content.GetValueForProperty("Dataset",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal)this).Dataset, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryDatasetTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal)this).TimePeriod = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryTimePeriod) content.GetValueForProperty("TimePeriod",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal)this).TimePeriod, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryTimePeriodTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal)this).Type = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal)this).Type, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal)this).Timeframe = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType) content.GetValueForProperty("Timeframe",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal)this).Timeframe, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal)this).DatasetConfiguration = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetConfiguration) content.GetValueForProperty("DatasetConfiguration",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal)this).DatasetConfiguration, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryDatasetConfigurationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal)this).DatasetAggregation = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetAggregation) content.GetValueForProperty("DatasetAggregation",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal)this).DatasetAggregation, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryDatasetAggregationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal)this).DatasetFilter = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter) content.GetValueForProperty("DatasetFilter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal)this).DatasetFilter, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryFilterTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal)this).DatasetGranularity = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType?) content.GetValueForProperty("DatasetGranularity",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal)this).DatasetGranularity, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal)this).DatasetGrouping = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryGrouping[]) content.GetValueForProperty("DatasetGrouping",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal)this).DatasetGrouping, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryGroupingTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal)this).TimePeriodFrom = (global::System.DateTime) content.GetValueForProperty("TimePeriodFrom",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal)this).TimePeriodFrom, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal)this).TimePeriodTo = (global::System.DateTime) content.GetValueForProperty("TimePeriodTo",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal)this).TimePeriodTo, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal)this).ConfigurationColumn = (string[]) content.GetValueForProperty("ConfigurationColumn",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal)this).ConfigurationColumn, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal QueryDefinition(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal)this).Dataset = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDataset) content.GetValueForProperty("Dataset",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal)this).Dataset, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryDatasetTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal)this).TimePeriod = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryTimePeriod) content.GetValueForProperty("TimePeriod",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal)this).TimePeriod, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryTimePeriodTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal)this).Type = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal)this).Type, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal)this).Timeframe = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType) content.GetValueForProperty("Timeframe",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal)this).Timeframe, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal)this).DatasetConfiguration = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetConfiguration) content.GetValueForProperty("DatasetConfiguration",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal)this).DatasetConfiguration, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryDatasetConfigurationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal)this).DatasetAggregation = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetAggregation) content.GetValueForProperty("DatasetAggregation",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal)this).DatasetAggregation, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryDatasetAggregationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal)this).DatasetFilter = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter) content.GetValueForProperty("DatasetFilter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal)this).DatasetFilter, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryFilterTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal)this).DatasetGranularity = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType?) content.GetValueForProperty("DatasetGranularity",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal)this).DatasetGranularity, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal)this).DatasetGrouping = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryGrouping[]) content.GetValueForProperty("DatasetGrouping",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal)this).DatasetGrouping, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryGroupingTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal)this).TimePeriodFrom = (global::System.DateTime) content.GetValueForProperty("TimePeriodFrom",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal)this).TimePeriodFrom, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal)this).TimePeriodTo = (global::System.DateTime) content.GetValueForProperty("TimePeriodTo",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal)this).TimePeriodTo, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal)this).ConfigurationColumn = (string[]) content.GetValueForProperty("ConfigurationColumn",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal)this).ConfigurationColumn, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + AfterDeserializePSObject(content); + } + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// The definition of a query. + [System.ComponentModel.TypeConverter(typeof(QueryDefinitionTypeConverter))] + public partial interface IQueryDefinition + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/QueryDefinition.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/QueryDefinition.TypeConverter.cs new file mode 100644 index 000000000000..ecf519975034 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/QueryDefinition.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class QueryDefinitionTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinition ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinition).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return QueryDefinition.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return QueryDefinition.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return QueryDefinition.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/QueryDefinition.cs b/src/CostManagement/generated/api/Models/Api20200601/QueryDefinition.cs new file mode 100644 index 000000000000..75e470224bf4 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/QueryDefinition.cs @@ -0,0 +1,223 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The definition of a query. + public partial class QueryDefinition : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinition, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal + { + + /// + /// Array of column names to be included in the query. Any valid query column name is allowed. If not provided, then query + /// includes all columns. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string[] ConfigurationColumn { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetInternal)Dataset).ConfigurationColumn; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetInternal)Dataset).ConfigurationColumn = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDataset _dataset; + + /// Has definition for data in this query. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + internal Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDataset Dataset { get => (this._dataset = this._dataset ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryDataset()); set => this._dataset = value; } + + /// + /// Dictionary of aggregation expression to use in the query. The key of each item in the dictionary is the alias for the + /// aggregated column. Query can have up to 2 aggregation clauses. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetAggregation DatasetAggregation { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetInternal)Dataset).Aggregation; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetInternal)Dataset).Aggregation = value; } + + /// Has filter expression to use in the query. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter DatasetFilter { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetInternal)Dataset).Filter; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetInternal)Dataset).Filter = value; } + + /// The granularity of rows in the query. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType? DatasetGranularity { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetInternal)Dataset).Granularity; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetInternal)Dataset).Granularity = value; } + + /// + /// Array of group by expression to use in the query. Query can have up to 2 group by clauses. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryGrouping[] DatasetGrouping { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetInternal)Dataset).Grouping; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetInternal)Dataset).Grouping = value; } + + /// Internal Acessors for Dataset + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDataset Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal.Dataset { get => (this._dataset = this._dataset ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryDataset()); set { {_dataset = value;} } } + + /// Internal Acessors for DatasetConfiguration + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetConfiguration Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal.DatasetConfiguration { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetInternal)Dataset).Configuration; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetInternal)Dataset).Configuration = value; } + + /// Internal Acessors for TimePeriod + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryTimePeriod Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinitionInternal.TimePeriod { get => (this._timePeriod = this._timePeriod ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryTimePeriod()); set { {_timePeriod = value;} } } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryTimePeriod _timePeriod; + + /// Has time period for pulling data for the query. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + internal Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryTimePeriod TimePeriod { get => (this._timePeriod = this._timePeriod ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryTimePeriod()); set => this._timePeriod = value; } + + /// The start date to pull data from. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public global::System.DateTime TimePeriodFrom { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryTimePeriodInternal)TimePeriod).From; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryTimePeriodInternal)TimePeriod).From = value; } + + /// The end date to pull data to. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public global::System.DateTime TimePeriodTo { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryTimePeriodInternal)TimePeriod).To; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryTimePeriodInternal)TimePeriod).To = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType _timeframe; + + /// + /// The time frame for pulling data for the query. If custom, then a specific time period must be provided. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType Timeframe { get => this._timeframe; set => this._timeframe = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType _type; + + /// The type of the query. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType Type { get => this._type; set => this._type = value; } + + /// Creates an new instance. + public QueryDefinition() + { + + } + } + /// The definition of a query. + public partial interface IQueryDefinition : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// + /// Array of column names to be included in the query. Any valid query column name is allowed. If not provided, then query + /// includes all columns. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Array of column names to be included in the query. Any valid query column name is allowed. If not provided, then query includes all columns.", + SerializedName = @"columns", + PossibleTypes = new [] { typeof(string) })] + string[] ConfigurationColumn { get; set; } + /// + /// Dictionary of aggregation expression to use in the query. The key of each item in the dictionary is the alias for the + /// aggregated column. Query can have up to 2 aggregation clauses. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Dictionary of aggregation expression to use in the query. The key of each item in the dictionary is the alias for the aggregated column. Query can have up to 2 aggregation clauses.", + SerializedName = @"aggregation", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetAggregation) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetAggregation DatasetAggregation { get; set; } + /// Has filter expression to use in the query. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Has filter expression to use in the query.", + SerializedName = @"filter", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter DatasetFilter { get; set; } + /// The granularity of rows in the query. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The granularity of rows in the query.", + SerializedName = @"granularity", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType? DatasetGranularity { get; set; } + /// + /// Array of group by expression to use in the query. Query can have up to 2 group by clauses. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Array of group by expression to use in the query. Query can have up to 2 group by clauses.", + SerializedName = @"grouping", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryGrouping) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryGrouping[] DatasetGrouping { get; set; } + /// The start date to pull data from. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The start date to pull data from.", + SerializedName = @"from", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime TimePeriodFrom { get; set; } + /// The end date to pull data to. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The end date to pull data to.", + SerializedName = @"to", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime TimePeriodTo { get; set; } + /// + /// The time frame for pulling data for the query. If custom, then a specific time period must be provided. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The time frame for pulling data for the query. If custom, then a specific time period must be provided.", + SerializedName = @"timeframe", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType Timeframe { get; set; } + /// The type of the query. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The type of the query.", + SerializedName = @"type", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType Type { get; set; } + + } + /// The definition of a query. + public partial interface IQueryDefinitionInternal + + { + /// + /// Array of column names to be included in the query. Any valid query column name is allowed. If not provided, then query + /// includes all columns. + /// + string[] ConfigurationColumn { get; set; } + /// Has definition for data in this query. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDataset Dataset { get; set; } + /// + /// Dictionary of aggregation expression to use in the query. The key of each item in the dictionary is the alias for the + /// aggregated column. Query can have up to 2 aggregation clauses. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetAggregation DatasetAggregation { get; set; } + /// + /// Has configuration information for the data in the export. The configuration will be ignored if aggregation and grouping + /// are provided. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDatasetConfiguration DatasetConfiguration { get; set; } + /// Has filter expression to use in the query. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter DatasetFilter { get; set; } + /// The granularity of rows in the query. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType? DatasetGranularity { get; set; } + /// + /// Array of group by expression to use in the query. Query can have up to 2 group by clauses. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryGrouping[] DatasetGrouping { get; set; } + /// Has time period for pulling data for the query. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryTimePeriod TimePeriod { get; set; } + /// The start date to pull data from. + global::System.DateTime TimePeriodFrom { get; set; } + /// The end date to pull data to. + global::System.DateTime TimePeriodTo { get; set; } + /// + /// The time frame for pulling data for the query. If custom, then a specific time period must be provided. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType Timeframe { get; set; } + /// The type of the query. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType Type { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/QueryDefinition.json.cs b/src/CostManagement/generated/api/Models/Api20200601/QueryDefinition.json.cs new file mode 100644 index 000000000000..096fbbf72151 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/QueryDefinition.json.cs @@ -0,0 +1,107 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The definition of a query. + public partial class QueryDefinition + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinition. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinition. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryDefinition FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new QueryDefinition(json) : null; + } + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal QueryDefinition(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_dataset = If( json?.PropertyT("dataset"), out var __jsonDataset) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryDataset.FromJson(__jsonDataset) : Dataset;} + {_timePeriod = If( json?.PropertyT("timePeriod"), out var __jsonTimePeriod) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryTimePeriod.FromJson(__jsonTimePeriod) : TimePeriod;} + {_type = If( json?.PropertyT("type"), out var __jsonType) ? (string)__jsonType : (string)Type;} + {_timeframe = If( json?.PropertyT("timeframe"), out var __jsonTimeframe) ? (string)__jsonTimeframe : (string)Timeframe;} + AfterFromJson(json); + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + AddIf( null != this._dataset ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._dataset.ToJson(null,serializationMode) : null, "dataset" ,container.Add ); + AddIf( null != this._timePeriod ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._timePeriod.ToJson(null,serializationMode) : null, "timePeriod" ,container.Add ); + AddIf( null != (((object)this._type)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._type.ToString()) : null, "type" ,container.Add ); + AddIf( null != (((object)this._timeframe)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._timeframe.ToString()) : null, "timeframe" ,container.Add ); + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/QueryFilter.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/QueryFilter.PowerShell.cs new file mode 100644 index 000000000000..aed6690acf9b --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/QueryFilter.PowerShell.cs @@ -0,0 +1,139 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// The filter expression to be used in the export. + [System.ComponentModel.TypeConverter(typeof(QueryFilterTypeConverter))] + public partial class QueryFilter + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new QueryFilter(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new QueryFilter(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal QueryFilter(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilterInternal)this).And = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter[]) content.GetValueForProperty("And",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilterInternal)this).And, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryFilterTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilterInternal)this).Dimensions = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryComparisonExpression) content.GetValueForProperty("Dimensions",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilterInternal)this).Dimensions, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryComparisonExpressionTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilterInternal)this).Not = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter) content.GetValueForProperty("Not",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilterInternal)this).Not, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryFilterTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilterInternal)this).Or = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter[]) content.GetValueForProperty("Or",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilterInternal)this).Or, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryFilterTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilterInternal)this).Tag = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryComparisonExpression) content.GetValueForProperty("Tag",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilterInternal)this).Tag, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryComparisonExpressionTypeConverter.ConvertFrom); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal QueryFilter(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilterInternal)this).And = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter[]) content.GetValueForProperty("And",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilterInternal)this).And, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryFilterTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilterInternal)this).Dimensions = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryComparisonExpression) content.GetValueForProperty("Dimensions",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilterInternal)this).Dimensions, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryComparisonExpressionTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilterInternal)this).Not = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter) content.GetValueForProperty("Not",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilterInternal)this).Not, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryFilterTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilterInternal)this).Or = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter[]) content.GetValueForProperty("Or",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilterInternal)this).Or, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryFilterTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilterInternal)this).Tag = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryComparisonExpression) content.GetValueForProperty("Tag",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilterInternal)this).Tag, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryComparisonExpressionTypeConverter.ConvertFrom); + AfterDeserializePSObject(content); + } + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// The filter expression to be used in the export. + [System.ComponentModel.TypeConverter(typeof(QueryFilterTypeConverter))] + public partial interface IQueryFilter + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/QueryFilter.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/QueryFilter.TypeConverter.cs new file mode 100644 index 000000000000..b266b5574fc1 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/QueryFilter.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class QueryFilterTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return QueryFilter.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return QueryFilter.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return QueryFilter.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/QueryFilter.cs b/src/CostManagement/generated/api/Models/Api20200601/QueryFilter.cs new file mode 100644 index 000000000000..29c6441dcd23 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/QueryFilter.cs @@ -0,0 +1,114 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The filter expression to be used in the export. + public partial class QueryFilter : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilterInternal + { + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter[] _and; + + /// The logical "AND" expression. Must have at least 2 items. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter[] And { get => this._and; set => this._and = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryComparisonExpression _dimensions; + + /// Has comparison expression for a dimension + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryComparisonExpression Dimensions { get => (this._dimensions = this._dimensions ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryComparisonExpression()); set => this._dimensions = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter _not; + + /// The logical "NOT" expression. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter Not { get => (this._not = this._not ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryFilter()); set => this._not = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter[] _or; + + /// The logical "OR" expression. Must have at least 2 items. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter[] Or { get => this._or; set => this._or = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryComparisonExpression _tag; + + /// Has comparison expression for a tag + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryComparisonExpression Tag { get => (this._tag = this._tag ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryComparisonExpression()); set => this._tag = value; } + + /// Creates an new instance. + public QueryFilter() + { + + } + } + /// The filter expression to be used in the export. + public partial interface IQueryFilter : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// The logical "AND" expression. Must have at least 2 items. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The logical ""AND"" expression. Must have at least 2 items.", + SerializedName = @"and", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter[] And { get; set; } + /// Has comparison expression for a dimension + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Has comparison expression for a dimension", + SerializedName = @"dimensions", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryComparisonExpression) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryComparisonExpression Dimensions { get; set; } + /// The logical "NOT" expression. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The logical ""NOT"" expression.", + SerializedName = @"not", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter Not { get; set; } + /// The logical "OR" expression. Must have at least 2 items. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The logical ""OR"" expression. Must have at least 2 items.", + SerializedName = @"or", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter[] Or { get; set; } + /// Has comparison expression for a tag + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Has comparison expression for a tag", + SerializedName = @"tag", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryComparisonExpression) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryComparisonExpression Tag { get; set; } + + } + /// The filter expression to be used in the export. + public partial interface IQueryFilterInternal + + { + /// The logical "AND" expression. Must have at least 2 items. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter[] And { get; set; } + /// Has comparison expression for a dimension + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryComparisonExpression Dimensions { get; set; } + /// The logical "NOT" expression. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter Not { get; set; } + /// The logical "OR" expression. Must have at least 2 items. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter[] Or { get; set; } + /// Has comparison expression for a tag + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryComparisonExpression Tag { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/QueryFilter.json.cs b/src/CostManagement/generated/api/Models/Api20200601/QueryFilter.json.cs new file mode 100644 index 000000000000..7291acb455d9 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/QueryFilter.json.cs @@ -0,0 +1,125 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The filter expression to be used in the export. + public partial class QueryFilter + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new QueryFilter(json) : null; + } + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal QueryFilter(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_and = If( json?.PropertyT("and"), out var __jsonAnd) ? If( __jsonAnd as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonArray, out var __v) ? new global::System.Func(()=> global::System.Linq.Enumerable.ToArray(global::System.Linq.Enumerable.Select(__v, (__u)=>(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter) (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryFilter.FromJson(__u) )) ))() : null : And;} + {_dimensions = If( json?.PropertyT("dimensions"), out var __jsonDimensions) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryComparisonExpression.FromJson(__jsonDimensions) : Dimensions;} + {_not = If( json?.PropertyT("not"), out var __jsonNot) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryFilter.FromJson(__jsonNot) : Not;} + {_or = If( json?.PropertyT("or"), out var __jsonOr) ? If( __jsonOr as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonArray, out var __q) ? new global::System.Func(()=> global::System.Linq.Enumerable.ToArray(global::System.Linq.Enumerable.Select(__q, (__p)=>(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter) (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryFilter.FromJson(__p) )) ))() : null : Or;} + {_tag = If( json?.PropertyT("tag"), out var __jsonTag) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryComparisonExpression.FromJson(__jsonTag) : Tag;} + AfterFromJson(json); + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + if (null != this._and) + { + var __w = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.XNodeArray(); + foreach( var __x in this._and ) + { + AddIf(__x?.ToJson(null, serializationMode) ,__w.Add); + } + container.Add("and",__w); + } + AddIf( null != this._dimensions ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._dimensions.ToJson(null,serializationMode) : null, "dimensions" ,container.Add ); + AddIf( null != this._not ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._not.ToJson(null,serializationMode) : null, "not" ,container.Add ); + if (null != this._or) + { + var __r = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.XNodeArray(); + foreach( var __s in this._or ) + { + AddIf(__s?.ToJson(null, serializationMode) ,__r.Add); + } + container.Add("or",__r); + } + AddIf( null != this._tag ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._tag.ToJson(null,serializationMode) : null, "tag" ,container.Add ); + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/QueryGrouping.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/QueryGrouping.PowerShell.cs new file mode 100644 index 000000000000..c6c68186b83e --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/QueryGrouping.PowerShell.cs @@ -0,0 +1,133 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// The group by expression to be used in the query. + [System.ComponentModel.TypeConverter(typeof(QueryGroupingTypeConverter))] + public partial class QueryGrouping + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryGrouping DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new QueryGrouping(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryGrouping DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new QueryGrouping(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryGrouping FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal QueryGrouping(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryGroupingInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryGroupingInternal)this).Name, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryGroupingInternal)this).Type = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.QueryColumnType) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryGroupingInternal)this).Type, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.QueryColumnType.CreateFrom); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal QueryGrouping(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryGroupingInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryGroupingInternal)this).Name, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryGroupingInternal)this).Type = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.QueryColumnType) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryGroupingInternal)this).Type, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.QueryColumnType.CreateFrom); + AfterDeserializePSObject(content); + } + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// The group by expression to be used in the query. + [System.ComponentModel.TypeConverter(typeof(QueryGroupingTypeConverter))] + public partial interface IQueryGrouping + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/QueryGrouping.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/QueryGrouping.TypeConverter.cs new file mode 100644 index 000000000000..6705c92111db --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/QueryGrouping.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class QueryGroupingTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryGrouping ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryGrouping).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return QueryGrouping.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return QueryGrouping.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return QueryGrouping.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/QueryGrouping.cs b/src/CostManagement/generated/api/Models/Api20200601/QueryGrouping.cs new file mode 100644 index 000000000000..6f66be92526e --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/QueryGrouping.cs @@ -0,0 +1,63 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The group by expression to be used in the query. + public partial class QueryGrouping : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryGrouping, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryGroupingInternal + { + + /// Backing field for property. + private string _name; + + /// The name of the column to group. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string Name { get => this._name; set => this._name = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.QueryColumnType _type; + + /// Has type of the column to group. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.QueryColumnType Type { get => this._type; set => this._type = value; } + + /// Creates an new instance. + public QueryGrouping() + { + + } + } + /// The group by expression to be used in the query. + public partial interface IQueryGrouping : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// The name of the column to group. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The name of the column to group.", + SerializedName = @"name", + PossibleTypes = new [] { typeof(string) })] + string Name { get; set; } + /// Has type of the column to group. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"Has type of the column to group.", + SerializedName = @"type", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.QueryColumnType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.QueryColumnType Type { get; set; } + + } + /// The group by expression to be used in the query. + public partial interface IQueryGroupingInternal + + { + /// The name of the column to group. + string Name { get; set; } + /// Has type of the column to group. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.QueryColumnType Type { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/QueryGrouping.json.cs b/src/CostManagement/generated/api/Models/Api20200601/QueryGrouping.json.cs new file mode 100644 index 000000000000..7139d5936c70 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/QueryGrouping.json.cs @@ -0,0 +1,103 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The group by expression to be used in the query. + public partial class QueryGrouping + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryGrouping. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryGrouping. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryGrouping FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new QueryGrouping(json) : null; + } + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal QueryGrouping(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_name = If( json?.PropertyT("name"), out var __jsonName) ? (string)__jsonName : (string)Name;} + {_type = If( json?.PropertyT("type"), out var __jsonType) ? (string)__jsonType : (string)Type;} + AfterFromJson(json); + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + AddIf( null != (((object)this._name)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._name.ToString()) : null, "name" ,container.Add ); + AddIf( null != (((object)this._type)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._type.ToString()) : null, "type" ,container.Add ); + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/QueryProperties.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/QueryProperties.PowerShell.cs new file mode 100644 index 000000000000..06330bad8329 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/QueryProperties.PowerShell.cs @@ -0,0 +1,133 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + [System.ComponentModel.TypeConverter(typeof(QueryPropertiesTypeConverter))] + public partial class QueryProperties + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryProperties DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new QueryProperties(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryProperties DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new QueryProperties(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryProperties FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal QueryProperties(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryPropertiesInternal)this).Column = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryColumn[]) content.GetValueForProperty("Column",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryPropertiesInternal)this).Column, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryColumnTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryPropertiesInternal)this).NextLink = (string) content.GetValueForProperty("NextLink",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryPropertiesInternal)this).NextLink, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryPropertiesInternal)this).Row = (string[][]) content.GetValueForProperty("Row",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryPropertiesInternal)this).Row, __y => TypeConverterExtensions.SelectToArray(__y, __w => TypeConverterExtensions.SelectToArray(__w, global::System.Convert.ToString))); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal QueryProperties(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryPropertiesInternal)this).Column = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryColumn[]) content.GetValueForProperty("Column",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryPropertiesInternal)this).Column, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryColumnTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryPropertiesInternal)this).NextLink = (string) content.GetValueForProperty("NextLink",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryPropertiesInternal)this).NextLink, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryPropertiesInternal)this).Row = (string[][]) content.GetValueForProperty("Row",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryPropertiesInternal)this).Row, __y => TypeConverterExtensions.SelectToArray(__y, __w => TypeConverterExtensions.SelectToArray(__w, global::System.Convert.ToString))); + AfterDeserializePSObject(content); + } + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + [System.ComponentModel.TypeConverter(typeof(QueryPropertiesTypeConverter))] + public partial interface IQueryProperties + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/QueryProperties.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/QueryProperties.TypeConverter.cs new file mode 100644 index 000000000000..096ef82353b0 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/QueryProperties.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class QueryPropertiesTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryProperties ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryProperties).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return QueryProperties.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return QueryProperties.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return QueryProperties.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/QueryProperties.cs b/src/CostManagement/generated/api/Models/Api20200601/QueryProperties.cs new file mode 100644 index 000000000000..67c7d81eeda6 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/QueryProperties.cs @@ -0,0 +1,77 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + public partial class QueryProperties : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryProperties, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryPropertiesInternal + { + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryColumn[] _column; + + /// Array of columns + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryColumn[] Column { get => this._column; set => this._column = value; } + + /// Backing field for property. + private string _nextLink; + + /// The link (url) to the next page of results. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string NextLink { get => this._nextLink; set => this._nextLink = value; } + + /// Backing field for property. + private string[][] _row; + + /// Array of rows + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string[][] Row { get => this._row; set => this._row = value; } + + /// Creates an new instance. + public QueryProperties() + { + + } + } + public partial interface IQueryProperties : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// Array of columns + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Array of columns", + SerializedName = @"columns", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryColumn) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryColumn[] Column { get; set; } + /// The link (url) to the next page of results. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The link (url) to the next page of results.", + SerializedName = @"nextLink", + PossibleTypes = new [] { typeof(string) })] + string NextLink { get; set; } + /// Array of rows + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Array of rows", + SerializedName = @"rows", + PossibleTypes = new [] { typeof(string) })] + string[][] Row { get; set; } + + } + public partial interface IQueryPropertiesInternal + + { + /// Array of columns + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryColumn[] Column { get; set; } + /// The link (url) to the next page of results. + string NextLink { get; set; } + /// Array of rows + string[][] Row { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/QueryProperties.json.cs b/src/CostManagement/generated/api/Models/Api20200601/QueryProperties.json.cs new file mode 100644 index 000000000000..01b895e447f2 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/QueryProperties.json.cs @@ -0,0 +1,120 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + public partial class QueryProperties + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryProperties. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryProperties. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryProperties FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new QueryProperties(json) : null; + } + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal QueryProperties(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_column = If( json?.PropertyT("columns"), out var __jsonColumns) ? If( __jsonColumns as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonArray, out var __v) ? new global::System.Func(()=> global::System.Linq.Enumerable.ToArray(global::System.Linq.Enumerable.Select(__v, (__u)=>(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryColumn) (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryColumn.FromJson(__u) )) ))() : null : Column;} + {_nextLink = If( json?.PropertyT("nextLink"), out var __jsonNextLink) ? (string)__jsonNextLink : (string)NextLink;} + {_row = If( json?.PropertyT("rows"), out var __jsonRows) ? If( __jsonRows as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonArray, out var __p) ? new global::System.Func(()=> global::System.Linq.Enumerable.ToArray(global::System.Linq.Enumerable.Select(__p, (__o)=>(string[]) (If( __o as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonArray, out var __n) ? new global::System.Func(()=> global::System.Linq.Enumerable.ToArray(global::System.Linq.Enumerable.Select(__n, (__m)=>(string) (__m is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString __l ? (string)(__l.ToString()) : null)) ))() : null /* arrayOf */)) ))() : null : Row;} + AfterFromJson(json); + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + if (null != this._column) + { + var __w = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.XNodeArray(); + foreach( var __x in this._column ) + { + AddIf(__x?.ToJson(null, serializationMode) ,__w.Add); + } + container.Add("columns",__w); + } + AddIf( null != (((object)this._nextLink)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._nextLink.ToString()) : null, "nextLink" ,container.Add ); + if (null != this._row) + { + var __r = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.XNodeArray(); + foreach( var __s in this._row ) + { + AddIf(null != __s ? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.XNodeArray(global::System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(__s, (__q) => null != (((object)__q)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(__q.ToString()) : null))) : null ,__r.Add); + } + container.Add("rows",__r); + } + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/QueryResult.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/QueryResult.PowerShell.cs new file mode 100644 index 000000000000..89efc84e6ef1 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/QueryResult.PowerShell.cs @@ -0,0 +1,147 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// Result of query. It contains all columns listed under groupings and aggregation. + /// + [System.ComponentModel.TypeConverter(typeof(QueryResultTypeConverter))] + public partial class QueryResult + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryResult DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new QueryResult(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryResult DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new QueryResult(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryResult FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal QueryResult(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryResultInternal)this).Property = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryProperties) content.GetValueForProperty("Property",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryResultInternal)this).Property, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryPropertiesTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Name, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Type = (string) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Type, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Id = (string) content.GetValueForProperty("Id",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Id, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Tag = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceTags) content.GetValueForProperty("Tag",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Tag, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ResourceTagsTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryResultInternal)this).Column = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryColumn[]) content.GetValueForProperty("Column",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryResultInternal)this).Column, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryColumnTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryResultInternal)this).NextLink = (string) content.GetValueForProperty("NextLink",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryResultInternal)this).NextLink, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryResultInternal)this).Row = (string[][]) content.GetValueForProperty("Row",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryResultInternal)this).Row, __y => TypeConverterExtensions.SelectToArray(__y, __w => TypeConverterExtensions.SelectToArray(__w, global::System.Convert.ToString))); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal QueryResult(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryResultInternal)this).Property = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryProperties) content.GetValueForProperty("Property",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryResultInternal)this).Property, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryPropertiesTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Name, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Type = (string) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Type, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Id = (string) content.GetValueForProperty("Id",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Id, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Tag = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceTags) content.GetValueForProperty("Tag",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Tag, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ResourceTagsTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryResultInternal)this).Column = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryColumn[]) content.GetValueForProperty("Column",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryResultInternal)this).Column, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryColumnTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryResultInternal)this).NextLink = (string) content.GetValueForProperty("NextLink",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryResultInternal)this).NextLink, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryResultInternal)this).Row = (string[][]) content.GetValueForProperty("Row",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryResultInternal)this).Row, __y => TypeConverterExtensions.SelectToArray(__y, __w => TypeConverterExtensions.SelectToArray(__w, global::System.Convert.ToString))); + AfterDeserializePSObject(content); + } + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// Result of query. It contains all columns listed under groupings and aggregation. + [System.ComponentModel.TypeConverter(typeof(QueryResultTypeConverter))] + public partial interface IQueryResult + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/QueryResult.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/QueryResult.TypeConverter.cs new file mode 100644 index 000000000000..b6ed12566e55 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/QueryResult.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class QueryResultTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryResult ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryResult).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return QueryResult.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return QueryResult.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return QueryResult.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/QueryResult.cs b/src/CostManagement/generated/api/Models/Api20200601/QueryResult.cs new file mode 100644 index 000000000000..ce52961a35e9 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/QueryResult.cs @@ -0,0 +1,140 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// + /// Result of query. It contains all columns listed under groupings and aggregation. + /// + public partial class QueryResult : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryResult, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryResultInternal, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IValidates + { + /// + /// Backing field for Inherited model + /// + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResource __resource = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.Resource(); + + /// Array of columns + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.FormatTable(Index = 0)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryColumn[] Column { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryPropertiesInternal)Property).Column; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryPropertiesInternal)Property).Column = value; } + + /// Resource Id. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inherited)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.DoNotFormat] + public string Id { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)__resource).Id; } + + /// Internal Acessors for Property + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryProperties Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryResultInternal.Property { get => (this._property = this._property ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryProperties()); set { {_property = value;} } } + + /// Internal Acessors for Id + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal.Id { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)__resource).Id; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)__resource).Id = value; } + + /// Internal Acessors for Name + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal.Name { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)__resource).Name; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)__resource).Name = value; } + + /// Internal Acessors for Tag + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceTags Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal.Tag { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)__resource).Tag; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)__resource).Tag = value; } + + /// Internal Acessors for Type + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal.Type { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)__resource).Type; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)__resource).Type = value; } + + /// Resource name. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inherited)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.DoNotFormat] + public string Name { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)__resource).Name; } + + /// The link (url) to the next page of results. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.DoNotFormat] + public string NextLink { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryPropertiesInternal)Property).NextLink; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryPropertiesInternal)Property).NextLink = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryProperties _property; + + /// Query properties + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.DoNotFormat] + internal Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryProperties Property { get => (this._property = this._property ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryProperties()); set => this._property = value; } + + /// Array of rows + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.FormatTable(Index = 1)] + public string[][] Row { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryPropertiesInternal)Property).Row; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryPropertiesInternal)Property).Row = value; } + + /// Resource tags. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inherited)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.DoNotFormat] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceTags Tag { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)__resource).Tag; } + + /// Resource type. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inherited)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.DoNotFormat] + public string Type { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)__resource).Type; } + + /// Creates an new instance. + public QueryResult() + { + + } + + /// Validates that this object meets the validation criteria. + /// an instance that will receive validation + /// events. + /// + /// A < see cref = "global::System.Threading.Tasks.Task" /> that will be complete when validation is completed. + /// + public async global::System.Threading.Tasks.Task Validate(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener) + { + await eventListener.AssertNotNull(nameof(__resource), __resource); + await eventListener.AssertObjectIsValid(nameof(__resource), __resource); + } + } + /// Result of query. It contains all columns listed under groupings and aggregation. + public partial interface IQueryResult : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResource + { + /// Array of columns + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Array of columns", + SerializedName = @"columns", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryColumn) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryColumn[] Column { get; set; } + /// The link (url) to the next page of results. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The link (url) to the next page of results.", + SerializedName = @"nextLink", + PossibleTypes = new [] { typeof(string) })] + string NextLink { get; set; } + /// Array of rows + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Array of rows", + SerializedName = @"rows", + PossibleTypes = new [] { typeof(string) })] + string[][] Row { get; set; } + + } + /// Result of query. It contains all columns listed under groupings and aggregation. + public partial interface IQueryResultInternal : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal + { + /// Array of columns + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryColumn[] Column { get; set; } + /// The link (url) to the next page of results. + string NextLink { get; set; } + /// Query properties + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryProperties Property { get; set; } + /// Array of rows + string[][] Row { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/QueryResult.json.cs b/src/CostManagement/generated/api/Models/Api20200601/QueryResult.json.cs new file mode 100644 index 000000000000..7ad2d1bf878d --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/QueryResult.json.cs @@ -0,0 +1,105 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// + /// Result of query. It contains all columns listed under groupings and aggregation. + /// + public partial class QueryResult + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryResult. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryResult. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryResult FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new QueryResult(json) : null; + } + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal QueryResult(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + __resource = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.Resource(json); + {_property = If( json?.PropertyT("properties"), out var __jsonProperties) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryProperties.FromJson(__jsonProperties) : Property;} + AfterFromJson(json); + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + __resource?.ToJson(container, serializationMode); + AddIf( null != this._property ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._property.ToJson(null,serializationMode) : null, "properties" ,container.Add ); + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/QueryTimePeriod.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/QueryTimePeriod.PowerShell.cs new file mode 100644 index 000000000000..1accf0ba9e23 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/QueryTimePeriod.PowerShell.cs @@ -0,0 +1,133 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// The start and end date for pulling data for the query. + [System.ComponentModel.TypeConverter(typeof(QueryTimePeriodTypeConverter))] + public partial class QueryTimePeriod + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryTimePeriod DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new QueryTimePeriod(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryTimePeriod DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new QueryTimePeriod(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryTimePeriod FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal QueryTimePeriod(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryTimePeriodInternal)this).From = (global::System.DateTime) content.GetValueForProperty("From",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryTimePeriodInternal)this).From, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryTimePeriodInternal)this).To = (global::System.DateTime) content.GetValueForProperty("To",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryTimePeriodInternal)this).To, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal QueryTimePeriod(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryTimePeriodInternal)this).From = (global::System.DateTime) content.GetValueForProperty("From",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryTimePeriodInternal)this).From, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryTimePeriodInternal)this).To = (global::System.DateTime) content.GetValueForProperty("To",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryTimePeriodInternal)this).To, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + AfterDeserializePSObject(content); + } + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// The start and end date for pulling data for the query. + [System.ComponentModel.TypeConverter(typeof(QueryTimePeriodTypeConverter))] + public partial interface IQueryTimePeriod + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/QueryTimePeriod.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/QueryTimePeriod.TypeConverter.cs new file mode 100644 index 000000000000..93a94d43dd8e --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/QueryTimePeriod.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class QueryTimePeriodTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryTimePeriod ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryTimePeriod).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return QueryTimePeriod.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return QueryTimePeriod.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return QueryTimePeriod.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/QueryTimePeriod.cs b/src/CostManagement/generated/api/Models/Api20200601/QueryTimePeriod.cs new file mode 100644 index 000000000000..d5fe3090d18a --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/QueryTimePeriod.cs @@ -0,0 +1,63 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The start and end date for pulling data for the query. + public partial class QueryTimePeriod : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryTimePeriod, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryTimePeriodInternal + { + + /// Backing field for property. + private global::System.DateTime _from; + + /// The start date to pull data from. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public global::System.DateTime From { get => this._from; set => this._from = value; } + + /// Backing field for property. + private global::System.DateTime _to; + + /// The end date to pull data to. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public global::System.DateTime To { get => this._to; set => this._to = value; } + + /// Creates an new instance. + public QueryTimePeriod() + { + + } + } + /// The start and end date for pulling data for the query. + public partial interface IQueryTimePeriod : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// The start date to pull data from. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The start date to pull data from.", + SerializedName = @"from", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime From { get; set; } + /// The end date to pull data to. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The end date to pull data to.", + SerializedName = @"to", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime To { get; set; } + + } + /// The start and end date for pulling data for the query. + public partial interface IQueryTimePeriodInternal + + { + /// The start date to pull data from. + global::System.DateTime From { get; set; } + /// The end date to pull data to. + global::System.DateTime To { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/QueryTimePeriod.json.cs b/src/CostManagement/generated/api/Models/Api20200601/QueryTimePeriod.json.cs new file mode 100644 index 000000000000..2e7b9922231e --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/QueryTimePeriod.json.cs @@ -0,0 +1,103 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The start and end date for pulling data for the query. + public partial class QueryTimePeriod + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryTimePeriod. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryTimePeriod. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryTimePeriod FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new QueryTimePeriod(json) : null; + } + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal QueryTimePeriod(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_from = If( json?.PropertyT("from"), out var __jsonFrom) ? global::System.DateTime.TryParse((string)__jsonFrom, global::System.Globalization.CultureInfo.InvariantCulture, global::System.Globalization.DateTimeStyles.AdjustToUniversal, out var __jsonFromValue) ? __jsonFromValue : From : From;} + {_to = If( json?.PropertyT("to"), out var __jsonTo) ? global::System.DateTime.TryParse((string)__jsonTo, global::System.Globalization.CultureInfo.InvariantCulture, global::System.Globalization.DateTimeStyles.AdjustToUniversal, out var __jsonToValue) ? __jsonToValue : To : To;} + AfterFromJson(json); + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + AddIf( (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._from.ToString(@"yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK",global::System.Globalization.CultureInfo.InvariantCulture)), "from" ,container.Add ); + AddIf( (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._to.ToString(@"yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK",global::System.Globalization.CultureInfo.InvariantCulture)), "to" ,container.Add ); + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigAggregation.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigAggregation.PowerShell.cs new file mode 100644 index 000000000000..d9851882d988 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigAggregation.PowerShell.cs @@ -0,0 +1,135 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// The aggregation expression to be used in the report. + [System.ComponentModel.TypeConverter(typeof(ReportConfigAggregationTypeConverter))] + public partial class ReportConfigAggregation + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigAggregation DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new ReportConfigAggregation(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigAggregation DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new ReportConfigAggregation(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigAggregation FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal ReportConfigAggregation(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigAggregationInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigAggregationInternal)this).Name, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigAggregationInternal)this).Function = (string) content.GetValueForProperty("Function",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigAggregationInternal)this).Function, global::System.Convert.ToString); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal ReportConfigAggregation(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigAggregationInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigAggregationInternal)this).Name, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigAggregationInternal)this).Function = (string) content.GetValueForProperty("Function",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigAggregationInternal)this).Function, global::System.Convert.ToString); + AfterDeserializePSObject(content); + } + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// The aggregation expression to be used in the report. + [System.ComponentModel.TypeConverter(typeof(ReportConfigAggregationTypeConverter))] + public partial interface IReportConfigAggregation + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigAggregation.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigAggregation.TypeConverter.cs new file mode 100644 index 000000000000..72483f4b7e51 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigAggregation.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class ReportConfigAggregationTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigAggregation ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigAggregation).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return ReportConfigAggregation.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return ReportConfigAggregation.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return ReportConfigAggregation.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigAggregation.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigAggregation.cs new file mode 100644 index 000000000000..a05c76853b94 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigAggregation.cs @@ -0,0 +1,66 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The aggregation expression to be used in the report. + public partial class ReportConfigAggregation : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigAggregation, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigAggregationInternal + { + + /// Backing field for property. + private string _function= @"Sum"; + + /// The name of the aggregation function to use. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string Function { get => this._function; } + + /// Internal Acessors for Function + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigAggregationInternal.Function { get => this._function; set { {_function = value;} } } + + /// Backing field for property. + private string _name; + + /// The name of the column to aggregate. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string Name { get => this._name; set => this._name = value; } + + /// Creates an new instance. + public ReportConfigAggregation() + { + + } + } + /// The aggregation expression to be used in the report. + public partial interface IReportConfigAggregation : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// The name of the aggregation function to use. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = true, + Description = @"The name of the aggregation function to use.", + SerializedName = @"function", + PossibleTypes = new [] { typeof(string) })] + string Function { get; } + /// The name of the column to aggregate. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The name of the column to aggregate.", + SerializedName = @"name", + PossibleTypes = new [] { typeof(string) })] + string Name { get; set; } + + } + /// The aggregation expression to be used in the report. + public partial interface IReportConfigAggregationInternal + + { + /// The name of the aggregation function to use. + string Function { get; set; } + /// The name of the column to aggregate. + string Name { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigAggregation.json.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigAggregation.json.cs new file mode 100644 index 000000000000..24bb0bc2973c --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigAggregation.json.cs @@ -0,0 +1,103 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The aggregation expression to be used in the report. + public partial class ReportConfigAggregation + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigAggregation. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigAggregation. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigAggregation FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new ReportConfigAggregation(json) : null; + } + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal ReportConfigAggregation(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_name = If( json?.PropertyT("name"), out var __jsonName) ? (string)__jsonName : (string)Name;} + {_function = If( json?.PropertyT("function"), out var __jsonFunction) ? (string)__jsonFunction : (string)Function;} + AfterFromJson(json); + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + AddIf( null != (((object)this._name)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._name.ToString()) : null, "name" ,container.Add ); + AddIf( null != (((object)this._function)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._function.ToString()) : null, "function" ,container.Add ); + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigComparisonExpression.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigComparisonExpression.PowerShell.cs new file mode 100644 index 000000000000..e1f1e6c4e6eb --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigComparisonExpression.PowerShell.cs @@ -0,0 +1,137 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// The comparison expression to be used in the report. + [System.ComponentModel.TypeConverter(typeof(ReportConfigComparisonExpressionTypeConverter))] + public partial class ReportConfigComparisonExpression + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigComparisonExpression DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new ReportConfigComparisonExpression(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigComparisonExpression DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new ReportConfigComparisonExpression(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigComparisonExpression FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal ReportConfigComparisonExpression(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigComparisonExpressionInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigComparisonExpressionInternal)this).Name, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigComparisonExpressionInternal)this).Operator = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.OperatorType) content.GetValueForProperty("Operator",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigComparisonExpressionInternal)this).Operator, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.OperatorType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigComparisonExpressionInternal)this).Value = (string[]) content.GetValueForProperty("Value",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigComparisonExpressionInternal)this).Value, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal ReportConfigComparisonExpression(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigComparisonExpressionInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigComparisonExpressionInternal)this).Name, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigComparisonExpressionInternal)this).Operator = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.OperatorType) content.GetValueForProperty("Operator",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigComparisonExpressionInternal)this).Operator, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.OperatorType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigComparisonExpressionInternal)this).Value = (string[]) content.GetValueForProperty("Value",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigComparisonExpressionInternal)this).Value, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + AfterDeserializePSObject(content); + } + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// The comparison expression to be used in the report. + [System.ComponentModel.TypeConverter(typeof(ReportConfigComparisonExpressionTypeConverter))] + public partial interface IReportConfigComparisonExpression + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigComparisonExpression.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigComparisonExpression.TypeConverter.cs new file mode 100644 index 000000000000..48d7af59ea9a --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigComparisonExpression.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class ReportConfigComparisonExpressionTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigComparisonExpression ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigComparisonExpression).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return ReportConfigComparisonExpression.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return ReportConfigComparisonExpression.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return ReportConfigComparisonExpression.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigComparisonExpression.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigComparisonExpression.cs new file mode 100644 index 000000000000..14ba5dded3d9 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigComparisonExpression.cs @@ -0,0 +1,80 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The comparison expression to be used in the report. + public partial class ReportConfigComparisonExpression : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigComparisonExpression, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigComparisonExpressionInternal + { + + /// Backing field for property. + private string _name; + + /// The name of the column to use in comparison. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string Name { get => this._name; set => this._name = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.OperatorType _operator; + + /// The operator to use for comparison. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.OperatorType Operator { get => this._operator; set => this._operator = value; } + + /// Backing field for property. + private string[] _value; + + /// Array of values to use for comparison + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string[] Value { get => this._value; set => this._value = value; } + + /// Creates an new instance. + public ReportConfigComparisonExpression() + { + + } + } + /// The comparison expression to be used in the report. + public partial interface IReportConfigComparisonExpression : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// The name of the column to use in comparison. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The name of the column to use in comparison.", + SerializedName = @"name", + PossibleTypes = new [] { typeof(string) })] + string Name { get; set; } + /// The operator to use for comparison. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The operator to use for comparison.", + SerializedName = @"operator", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.OperatorType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.OperatorType Operator { get; set; } + /// Array of values to use for comparison + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"Array of values to use for comparison", + SerializedName = @"values", + PossibleTypes = new [] { typeof(string) })] + string[] Value { get; set; } + + } + /// The comparison expression to be used in the report. + public partial interface IReportConfigComparisonExpressionInternal + + { + /// The name of the column to use in comparison. + string Name { get; set; } + /// The operator to use for comparison. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.OperatorType Operator { get; set; } + /// Array of values to use for comparison + string[] Value { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigComparisonExpression.json.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigComparisonExpression.json.cs new file mode 100644 index 000000000000..abe19a2fbd17 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigComparisonExpression.json.cs @@ -0,0 +1,113 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The comparison expression to be used in the report. + public partial class ReportConfigComparisonExpression + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigComparisonExpression. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigComparisonExpression. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigComparisonExpression FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new ReportConfigComparisonExpression(json) : null; + } + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal ReportConfigComparisonExpression(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_name = If( json?.PropertyT("name"), out var __jsonName) ? (string)__jsonName : (string)Name;} + {_operator = If( json?.PropertyT("operator"), out var __jsonOperator) ? (string)__jsonOperator : (string)Operator;} + {_value = If( json?.PropertyT("values"), out var __jsonValues) ? If( __jsonValues as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonArray, out var __v) ? new global::System.Func(()=> global::System.Linq.Enumerable.ToArray(global::System.Linq.Enumerable.Select(__v, (__u)=>(string) (__u is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString __t ? (string)(__t.ToString()) : null)) ))() : null : Value;} + AfterFromJson(json); + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + AddIf( null != (((object)this._name)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._name.ToString()) : null, "name" ,container.Add ); + AddIf( null != (((object)this._operator)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._operator.ToString()) : null, "operator" ,container.Add ); + if (null != this._value) + { + var __w = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.XNodeArray(); + foreach( var __x in this._value ) + { + AddIf(null != (((object)__x)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(__x.ToString()) : null ,__w.Add); + } + container.Add("values",__w); + } + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDataset.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDataset.PowerShell.cs new file mode 100644 index 000000000000..bfa93664fea6 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDataset.PowerShell.cs @@ -0,0 +1,143 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// The definition of data present in the report. + [System.ComponentModel.TypeConverter(typeof(ReportConfigDatasetTypeConverter))] + public partial class ReportConfigDataset + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new ReportConfigDataset(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new ReportConfigDataset(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal ReportConfigDataset(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetInternal)this).Configuration = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetConfiguration) content.GetValueForProperty("Configuration",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetInternal)this).Configuration, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDatasetConfigurationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetInternal)this).Aggregation = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetAggregation) content.GetValueForProperty("Aggregation",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetInternal)this).Aggregation, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDatasetAggregationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetInternal)this).Filter = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter) content.GetValueForProperty("Filter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetInternal)this).Filter, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigFilterTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetInternal)this).Granularity = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType?) content.GetValueForProperty("Granularity",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetInternal)this).Granularity, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetInternal)this).Grouping = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGrouping[]) content.GetValueForProperty("Grouping",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetInternal)this).Grouping, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigGroupingTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetInternal)this).Sorting = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSorting[]) content.GetValueForProperty("Sorting",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetInternal)this).Sorting, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigSortingTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetInternal)this).ConfigurationColumn = (string[]) content.GetValueForProperty("ConfigurationColumn",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetInternal)this).ConfigurationColumn, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal ReportConfigDataset(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetInternal)this).Configuration = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetConfiguration) content.GetValueForProperty("Configuration",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetInternal)this).Configuration, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDatasetConfigurationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetInternal)this).Aggregation = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetAggregation) content.GetValueForProperty("Aggregation",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetInternal)this).Aggregation, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDatasetAggregationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetInternal)this).Filter = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter) content.GetValueForProperty("Filter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetInternal)this).Filter, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigFilterTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetInternal)this).Granularity = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType?) content.GetValueForProperty("Granularity",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetInternal)this).Granularity, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetInternal)this).Grouping = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGrouping[]) content.GetValueForProperty("Grouping",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetInternal)this).Grouping, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigGroupingTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetInternal)this).Sorting = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSorting[]) content.GetValueForProperty("Sorting",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetInternal)this).Sorting, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigSortingTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetInternal)this).ConfigurationColumn = (string[]) content.GetValueForProperty("ConfigurationColumn",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetInternal)this).ConfigurationColumn, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + AfterDeserializePSObject(content); + } + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// The definition of data present in the report. + [System.ComponentModel.TypeConverter(typeof(ReportConfigDatasetTypeConverter))] + public partial interface IReportConfigDataset + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDataset.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDataset.TypeConverter.cs new file mode 100644 index 000000000000..e738be2bea57 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDataset.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class ReportConfigDatasetTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return ReportConfigDataset.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return ReportConfigDataset.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return ReportConfigDataset.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDataset.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDataset.cs new file mode 100644 index 000000000000..bfc77739db4e --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDataset.cs @@ -0,0 +1,170 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The definition of data present in the report. + public partial class ReportConfigDataset : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetInternal + { + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetAggregation _aggregation; + + /// + /// Dictionary of aggregation expression to use in the report. The key of each item in the dictionary is the alias for the + /// aggregated column. Report can have up to 2 aggregation clauses. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetAggregation Aggregation { get => (this._aggregation = this._aggregation ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDatasetAggregation()); set => this._aggregation = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetConfiguration _configuration; + + /// + /// Has configuration information for the data in the report. The configuration will be ignored if aggregation and grouping + /// are provided. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + internal Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetConfiguration Configuration { get => (this._configuration = this._configuration ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDatasetConfiguration()); set => this._configuration = value; } + + /// + /// Array of column names to be included in the report. Any valid report column name is allowed. If not provided, then report + /// includes all columns. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string[] ConfigurationColumn { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetConfigurationInternal)Configuration).Column; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetConfigurationInternal)Configuration).Column = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter _filter; + + /// Has filter expression to use in the report. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter Filter { get => (this._filter = this._filter ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigFilter()); set => this._filter = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType? _granularity; + + /// The granularity of rows in the report. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType? Granularity { get => this._granularity; set => this._granularity = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGrouping[] _grouping; + + /// + /// Array of group by expression to use in the report. Report can have up to 2 group by clauses. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGrouping[] Grouping { get => this._grouping; set => this._grouping = value; } + + /// Internal Acessors for Configuration + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetConfiguration Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetInternal.Configuration { get => (this._configuration = this._configuration ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDatasetConfiguration()); set { {_configuration = value;} } } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSorting[] _sorting; + + /// Array of order by expression to use in the report. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSorting[] Sorting { get => this._sorting; set => this._sorting = value; } + + /// Creates an new instance. + public ReportConfigDataset() + { + + } + } + /// The definition of data present in the report. + public partial interface IReportConfigDataset : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// + /// Dictionary of aggregation expression to use in the report. The key of each item in the dictionary is the alias for the + /// aggregated column. Report can have up to 2 aggregation clauses. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Dictionary of aggregation expression to use in the report. The key of each item in the dictionary is the alias for the aggregated column. Report can have up to 2 aggregation clauses.", + SerializedName = @"aggregation", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetAggregation) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetAggregation Aggregation { get; set; } + /// + /// Array of column names to be included in the report. Any valid report column name is allowed. If not provided, then report + /// includes all columns. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Array of column names to be included in the report. Any valid report column name is allowed. If not provided, then report includes all columns.", + SerializedName = @"columns", + PossibleTypes = new [] { typeof(string) })] + string[] ConfigurationColumn { get; set; } + /// Has filter expression to use in the report. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Has filter expression to use in the report.", + SerializedName = @"filter", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter Filter { get; set; } + /// The granularity of rows in the report. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The granularity of rows in the report.", + SerializedName = @"granularity", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType? Granularity { get; set; } + /// + /// Array of group by expression to use in the report. Report can have up to 2 group by clauses. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Array of group by expression to use in the report. Report can have up to 2 group by clauses.", + SerializedName = @"grouping", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGrouping) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGrouping[] Grouping { get; set; } + /// Array of order by expression to use in the report. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Array of order by expression to use in the report.", + SerializedName = @"sorting", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSorting) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSorting[] Sorting { get; set; } + + } + /// The definition of data present in the report. + public partial interface IReportConfigDatasetInternal + + { + /// + /// Dictionary of aggregation expression to use in the report. The key of each item in the dictionary is the alias for the + /// aggregated column. Report can have up to 2 aggregation clauses. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetAggregation Aggregation { get; set; } + /// + /// Has configuration information for the data in the report. The configuration will be ignored if aggregation and grouping + /// are provided. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetConfiguration Configuration { get; set; } + /// + /// Array of column names to be included in the report. Any valid report column name is allowed. If not provided, then report + /// includes all columns. + /// + string[] ConfigurationColumn { get; set; } + /// Has filter expression to use in the report. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter Filter { get; set; } + /// The granularity of rows in the report. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType? Granularity { get; set; } + /// + /// Array of group by expression to use in the report. Report can have up to 2 group by clauses. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGrouping[] Grouping { get; set; } + /// Array of order by expression to use in the report. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSorting[] Sorting { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDataset.json.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDataset.json.cs new file mode 100644 index 000000000000..67276cca3e23 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDataset.json.cs @@ -0,0 +1,127 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The definition of data present in the report. + public partial class ReportConfigDataset + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new ReportConfigDataset(json) : null; + } + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal ReportConfigDataset(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_configuration = If( json?.PropertyT("configuration"), out var __jsonConfiguration) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDatasetConfiguration.FromJson(__jsonConfiguration) : Configuration;} + {_aggregation = If( json?.PropertyT("aggregation"), out var __jsonAggregation) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDatasetAggregation.FromJson(__jsonAggregation) : Aggregation;} + {_filter = If( json?.PropertyT("filter"), out var __jsonFilter) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigFilter.FromJson(__jsonFilter) : Filter;} + {_granularity = If( json?.PropertyT("granularity"), out var __jsonGranularity) ? (string)__jsonGranularity : (string)Granularity;} + {_grouping = If( json?.PropertyT("grouping"), out var __jsonGrouping) ? If( __jsonGrouping as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonArray, out var __v) ? new global::System.Func(()=> global::System.Linq.Enumerable.ToArray(global::System.Linq.Enumerable.Select(__v, (__u)=>(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGrouping) (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigGrouping.FromJson(__u) )) ))() : null : Grouping;} + {_sorting = If( json?.PropertyT("sorting"), out var __jsonSorting) ? If( __jsonSorting as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonArray, out var __q) ? new global::System.Func(()=> global::System.Linq.Enumerable.ToArray(global::System.Linq.Enumerable.Select(__q, (__p)=>(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSorting) (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigSorting.FromJson(__p) )) ))() : null : Sorting;} + AfterFromJson(json); + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + AddIf( null != this._configuration ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._configuration.ToJson(null,serializationMode) : null, "configuration" ,container.Add ); + AddIf( null != this._aggregation ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._aggregation.ToJson(null,serializationMode) : null, "aggregation" ,container.Add ); + AddIf( null != this._filter ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._filter.ToJson(null,serializationMode) : null, "filter" ,container.Add ); + AddIf( null != (((object)this._granularity)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._granularity.ToString()) : null, "granularity" ,container.Add ); + if (null != this._grouping) + { + var __w = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.XNodeArray(); + foreach( var __x in this._grouping ) + { + AddIf(__x?.ToJson(null, serializationMode) ,__w.Add); + } + container.Add("grouping",__w); + } + if (null != this._sorting) + { + var __r = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.XNodeArray(); + foreach( var __s in this._sorting ) + { + AddIf(__s?.ToJson(null, serializationMode) ,__r.Add); + } + container.Add("sorting",__r); + } + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDataset1.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDataset1.PowerShell.cs new file mode 100644 index 000000000000..d45eaf53fbb1 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDataset1.PowerShell.cs @@ -0,0 +1,145 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// The definition of data present in the report. + [System.ComponentModel.TypeConverter(typeof(ReportConfigDataset1TypeConverter))] + public partial class ReportConfigDataset1 + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1 DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new ReportConfigDataset1(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1 DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new ReportConfigDataset1(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1 FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal ReportConfigDataset1(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1Internal)this).Configuration = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetConfiguration) content.GetValueForProperty("Configuration",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1Internal)this).Configuration, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDatasetConfigurationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1Internal)this).Aggregation = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetAggregation) content.GetValueForProperty("Aggregation",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1Internal)this).Aggregation, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDatasetAggregationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1Internal)this).Filter = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1) content.GetValueForProperty("Filter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1Internal)this).Filter, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigFilter1TypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1Internal)this).Granularity = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType?) content.GetValueForProperty("Granularity",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1Internal)this).Granularity, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1Internal)this).Grouping = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGrouping[]) content.GetValueForProperty("Grouping",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1Internal)this).Grouping, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigGroupingTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1Internal)this).Sorting = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSorting[]) content.GetValueForProperty("Sorting",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1Internal)this).Sorting, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigSortingTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1Internal)this).ConfigurationColumn = (string[]) content.GetValueForProperty("ConfigurationColumn",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1Internal)this).ConfigurationColumn, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal ReportConfigDataset1(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1Internal)this).Configuration = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetConfiguration) content.GetValueForProperty("Configuration",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1Internal)this).Configuration, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDatasetConfigurationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1Internal)this).Aggregation = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetAggregation) content.GetValueForProperty("Aggregation",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1Internal)this).Aggregation, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDatasetAggregationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1Internal)this).Filter = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1) content.GetValueForProperty("Filter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1Internal)this).Filter, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigFilter1TypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1Internal)this).Granularity = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType?) content.GetValueForProperty("Granularity",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1Internal)this).Granularity, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1Internal)this).Grouping = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGrouping[]) content.GetValueForProperty("Grouping",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1Internal)this).Grouping, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigGroupingTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1Internal)this).Sorting = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSorting[]) content.GetValueForProperty("Sorting",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1Internal)this).Sorting, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigSortingTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1Internal)this).ConfigurationColumn = (string[]) content.GetValueForProperty("ConfigurationColumn",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1Internal)this).ConfigurationColumn, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + AfterDeserializePSObject(content); + } + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// The definition of data present in the report. + [System.ComponentModel.TypeConverter(typeof(ReportConfigDataset1TypeConverter))] + public partial interface IReportConfigDataset1 + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDataset1.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDataset1.TypeConverter.cs new file mode 100644 index 000000000000..28296d721968 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDataset1.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class ReportConfigDataset1TypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1 ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return ReportConfigDataset1.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return ReportConfigDataset1.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return ReportConfigDataset1.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDataset1.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDataset1.cs new file mode 100644 index 000000000000..c603f44aabde --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDataset1.cs @@ -0,0 +1,170 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The definition of data present in the report. + public partial class ReportConfigDataset1 : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1Internal + { + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetAggregation _aggregation; + + /// + /// Dictionary of aggregation expression to use in the report. The key of each item in the dictionary is the alias for the + /// aggregated column. Report can have up to 2 aggregation clauses. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetAggregation Aggregation { get => (this._aggregation = this._aggregation ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDatasetAggregation()); set => this._aggregation = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetConfiguration _configuration; + + /// + /// Has configuration information for the data in the report. The configuration will be ignored if aggregation and grouping + /// are provided. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + internal Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetConfiguration Configuration { get => (this._configuration = this._configuration ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDatasetConfiguration()); set => this._configuration = value; } + + /// + /// Array of column names to be included in the report. Any valid report column name is allowed. If not provided, then report + /// includes all columns. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string[] ConfigurationColumn { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetConfigurationInternal)Configuration).Column; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetConfigurationInternal)Configuration).Column = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1 _filter; + + /// Has filter expression to use in the report. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1 Filter { get => (this._filter = this._filter ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigFilter1()); set => this._filter = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType? _granularity; + + /// The granularity of rows in the report. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType? Granularity { get => this._granularity; set => this._granularity = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGrouping[] _grouping; + + /// + /// Array of group by expression to use in the report. Report can have up to 2 group by clauses. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGrouping[] Grouping { get => this._grouping; set => this._grouping = value; } + + /// Internal Acessors for Configuration + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetConfiguration Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1Internal.Configuration { get => (this._configuration = this._configuration ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDatasetConfiguration()); set { {_configuration = value;} } } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSorting[] _sorting; + + /// Array of order by expression to use in the report. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSorting[] Sorting { get => this._sorting; set => this._sorting = value; } + + /// Creates an new instance. + public ReportConfigDataset1() + { + + } + } + /// The definition of data present in the report. + public partial interface IReportConfigDataset1 : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// + /// Dictionary of aggregation expression to use in the report. The key of each item in the dictionary is the alias for the + /// aggregated column. Report can have up to 2 aggregation clauses. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Dictionary of aggregation expression to use in the report. The key of each item in the dictionary is the alias for the aggregated column. Report can have up to 2 aggregation clauses.", + SerializedName = @"aggregation", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetAggregation) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetAggregation Aggregation { get; set; } + /// + /// Array of column names to be included in the report. Any valid report column name is allowed. If not provided, then report + /// includes all columns. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Array of column names to be included in the report. Any valid report column name is allowed. If not provided, then report includes all columns.", + SerializedName = @"columns", + PossibleTypes = new [] { typeof(string) })] + string[] ConfigurationColumn { get; set; } + /// Has filter expression to use in the report. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Has filter expression to use in the report.", + SerializedName = @"filter", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1 Filter { get; set; } + /// The granularity of rows in the report. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The granularity of rows in the report.", + SerializedName = @"granularity", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType? Granularity { get; set; } + /// + /// Array of group by expression to use in the report. Report can have up to 2 group by clauses. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Array of group by expression to use in the report. Report can have up to 2 group by clauses.", + SerializedName = @"grouping", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGrouping) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGrouping[] Grouping { get; set; } + /// Array of order by expression to use in the report. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Array of order by expression to use in the report.", + SerializedName = @"sorting", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSorting) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSorting[] Sorting { get; set; } + + } + /// The definition of data present in the report. + public partial interface IReportConfigDataset1Internal + + { + /// + /// Dictionary of aggregation expression to use in the report. The key of each item in the dictionary is the alias for the + /// aggregated column. Report can have up to 2 aggregation clauses. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetAggregation Aggregation { get; set; } + /// + /// Has configuration information for the data in the report. The configuration will be ignored if aggregation and grouping + /// are provided. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetConfiguration Configuration { get; set; } + /// + /// Array of column names to be included in the report. Any valid report column name is allowed. If not provided, then report + /// includes all columns. + /// + string[] ConfigurationColumn { get; set; } + /// Has filter expression to use in the report. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1 Filter { get; set; } + /// The granularity of rows in the report. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType? Granularity { get; set; } + /// + /// Array of group by expression to use in the report. Report can have up to 2 group by clauses. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGrouping[] Grouping { get; set; } + /// Array of order by expression to use in the report. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSorting[] Sorting { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDataset1.json.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDataset1.json.cs new file mode 100644 index 000000000000..09cb4a14cc4e --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDataset1.json.cs @@ -0,0 +1,127 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The definition of data present in the report. + public partial class ReportConfigDataset1 + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1 FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new ReportConfigDataset1(json) : null; + } + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal ReportConfigDataset1(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_configuration = If( json?.PropertyT("configuration"), out var __jsonConfiguration) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDatasetConfiguration.FromJson(__jsonConfiguration) : Configuration;} + {_aggregation = If( json?.PropertyT("aggregation"), out var __jsonAggregation) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDatasetAggregation.FromJson(__jsonAggregation) : Aggregation;} + {_filter = If( json?.PropertyT("filter"), out var __jsonFilter) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigFilter1.FromJson(__jsonFilter) : Filter;} + {_granularity = If( json?.PropertyT("granularity"), out var __jsonGranularity) ? (string)__jsonGranularity : (string)Granularity;} + {_grouping = If( json?.PropertyT("grouping"), out var __jsonGrouping) ? If( __jsonGrouping as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonArray, out var __v) ? new global::System.Func(()=> global::System.Linq.Enumerable.ToArray(global::System.Linq.Enumerable.Select(__v, (__u)=>(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGrouping) (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigGrouping.FromJson(__u) )) ))() : null : Grouping;} + {_sorting = If( json?.PropertyT("sorting"), out var __jsonSorting) ? If( __jsonSorting as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonArray, out var __q) ? new global::System.Func(()=> global::System.Linq.Enumerable.ToArray(global::System.Linq.Enumerable.Select(__q, (__p)=>(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSorting) (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigSorting.FromJson(__p) )) ))() : null : Sorting;} + AfterFromJson(json); + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + AddIf( null != this._configuration ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._configuration.ToJson(null,serializationMode) : null, "configuration" ,container.Add ); + AddIf( null != this._aggregation ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._aggregation.ToJson(null,serializationMode) : null, "aggregation" ,container.Add ); + AddIf( null != this._filter ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._filter.ToJson(null,serializationMode) : null, "filter" ,container.Add ); + AddIf( null != (((object)this._granularity)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._granularity.ToString()) : null, "granularity" ,container.Add ); + if (null != this._grouping) + { + var __w = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.XNodeArray(); + foreach( var __x in this._grouping ) + { + AddIf(__x?.ToJson(null, serializationMode) ,__w.Add); + } + container.Add("grouping",__w); + } + if (null != this._sorting) + { + var __r = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.XNodeArray(); + foreach( var __s in this._sorting ) + { + AddIf(__s?.ToJson(null, serializationMode) ,__r.Add); + } + container.Add("sorting",__r); + } + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDatasetAggregation.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDatasetAggregation.PowerShell.cs new file mode 100644 index 000000000000..18272ee0ed2b --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDatasetAggregation.PowerShell.cs @@ -0,0 +1,139 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// Dictionary of aggregation expression to use in the report. The key of each item in the dictionary is the alias for the + /// aggregated column. Report can have up to 2 aggregation clauses. + /// + [System.ComponentModel.TypeConverter(typeof(ReportConfigDatasetAggregationTypeConverter))] + public partial class ReportConfigDatasetAggregation + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetAggregation DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new ReportConfigDatasetAggregation(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetAggregation DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new ReportConfigDatasetAggregation(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetAggregation FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal ReportConfigDatasetAggregation(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + // this type is a dictionary; copy elements from source to here. + CopyFrom(content); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal ReportConfigDatasetAggregation(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + // this type is a dictionary; copy elements from source to here. + CopyFrom(content); + AfterDeserializePSObject(content); + } + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// Dictionary of aggregation expression to use in the report. The key of each item in the dictionary is the alias for the + /// aggregated column. Report can have up to 2 aggregation clauses. + [System.ComponentModel.TypeConverter(typeof(ReportConfigDatasetAggregationTypeConverter))] + public partial interface IReportConfigDatasetAggregation + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDatasetAggregation.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDatasetAggregation.TypeConverter.cs new file mode 100644 index 000000000000..8dd28c5c44ed --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDatasetAggregation.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class ReportConfigDatasetAggregationTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetAggregation ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetAggregation).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return ReportConfigDatasetAggregation.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return ReportConfigDatasetAggregation.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return ReportConfigDatasetAggregation.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDatasetAggregation.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDatasetAggregation.cs new file mode 100644 index 000000000000..819fd733ee41 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDatasetAggregation.cs @@ -0,0 +1,35 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// + /// Dictionary of aggregation expression to use in the report. The key of each item in the dictionary is the alias for the + /// aggregated column. Report can have up to 2 aggregation clauses. + /// + public partial class ReportConfigDatasetAggregation : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetAggregation, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetAggregationInternal + { + + /// Creates an new instance. + public ReportConfigDatasetAggregation() + { + + } + } + /// Dictionary of aggregation expression to use in the report. The key of each item in the dictionary is the alias for the + /// aggregated column. Report can have up to 2 aggregation clauses. + public partial interface IReportConfigDatasetAggregation : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IAssociativeArray + { + + } + /// Dictionary of aggregation expression to use in the report. The key of each item in the dictionary is the alias for the + /// aggregated column. Report can have up to 2 aggregation clauses. + public partial interface IReportConfigDatasetAggregationInternal + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDatasetAggregation.dictionary.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDatasetAggregation.dictionary.cs new file mode 100644 index 000000000000..50b3cc4d6ffd --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDatasetAggregation.dictionary.cs @@ -0,0 +1,70 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + public partial class ReportConfigDatasetAggregation : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IAssociativeArray + { + protected global::System.Collections.Generic.Dictionary __additionalProperties = new global::System.Collections.Generic.Dictionary(); + + global::System.Collections.Generic.IDictionary Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IAssociativeArray.AdditionalProperties { get => __additionalProperties; } + + int Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IAssociativeArray.Count { get => __additionalProperties.Count; } + + global::System.Collections.Generic.IEnumerable Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IAssociativeArray.Keys { get => __additionalProperties.Keys; } + + global::System.Collections.Generic.IEnumerable Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IAssociativeArray.Values { get => __additionalProperties.Values; } + + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigAggregation this[global::System.String index] { get => __additionalProperties[index]; set => __additionalProperties[index] = value; } + + /// + /// + public void Add(global::System.String key, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigAggregation value) => __additionalProperties.Add( key, value); + + public void Clear() => __additionalProperties.Clear(); + + /// + public bool ContainsKey(global::System.String key) => __additionalProperties.ContainsKey( key); + + /// + public void CopyFrom(global::System.Collections.IDictionary source) + { + if (null != source) + { + foreach( var property in Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.TypeConverterExtensions.GetFilteredProperties(source, new global::System.Collections.Generic.HashSet() { } ) ) + { + if ((null != property.Key && null != property.Value)) + { + this.__additionalProperties.Add(property.Key.ToString(), global::System.Management.Automation.LanguagePrimitives.ConvertTo( property.Value)); + } + } + } + } + + /// + public void CopyFrom(global::System.Management.Automation.PSObject source) + { + if (null != source) + { + foreach( var property in Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.TypeConverterExtensions.GetFilteredProperties(source, new global::System.Collections.Generic.HashSet() { } ) ) + { + if ((null != property.Key && null != property.Value)) + { + this.__additionalProperties.Add(property.Key.ToString(), global::System.Management.Automation.LanguagePrimitives.ConvertTo( property.Value)); + } + } + } + } + + /// + public bool Remove(global::System.String key) => __additionalProperties.Remove( key); + + /// + /// + public bool TryGetValue(global::System.String key, out Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigAggregation value) => __additionalProperties.TryGetValue( key, out value); + + /// + + public static implicit operator global::System.Collections.Generic.Dictionary(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDatasetAggregation source) => source.__additionalProperties; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDatasetAggregation.json.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDatasetAggregation.json.cs new file mode 100644 index 000000000000..d9eb52f4ff37 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDatasetAggregation.json.cs @@ -0,0 +1,105 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// + /// Dictionary of aggregation expression to use in the report. The key of each item in the dictionary is the alias for the + /// aggregated column. Report can have up to 2 aggregation clauses. + /// + public partial class ReportConfigDatasetAggregation + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetAggregation. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetAggregation. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetAggregation FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new ReportConfigDatasetAggregation(json) : null; + } + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + /// + internal ReportConfigDatasetAggregation(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, global::System.Collections.Generic.HashSet exclusions = null) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.JsonSerializable.FromJson( json, ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IAssociativeArray)this).AdditionalProperties, null ,exclusions ); + AfterFromJson(json); + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.JsonSerializable.ToJson( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IAssociativeArray)this).AdditionalProperties, container); + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDatasetConfiguration.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDatasetConfiguration.PowerShell.cs new file mode 100644 index 000000000000..c7ea20daa08a --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDatasetConfiguration.PowerShell.cs @@ -0,0 +1,133 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// The configuration of dataset in the report. + [System.ComponentModel.TypeConverter(typeof(ReportConfigDatasetConfigurationTypeConverter))] + public partial class ReportConfigDatasetConfiguration + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetConfiguration DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new ReportConfigDatasetConfiguration(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetConfiguration DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new ReportConfigDatasetConfiguration(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetConfiguration FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal ReportConfigDatasetConfiguration(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetConfigurationInternal)this).Column = (string[]) content.GetValueForProperty("Column",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetConfigurationInternal)this).Column, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal ReportConfigDatasetConfiguration(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetConfigurationInternal)this).Column = (string[]) content.GetValueForProperty("Column",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetConfigurationInternal)this).Column, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + AfterDeserializePSObject(content); + } + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// The configuration of dataset in the report. + [System.ComponentModel.TypeConverter(typeof(ReportConfigDatasetConfigurationTypeConverter))] + public partial interface IReportConfigDatasetConfiguration + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDatasetConfiguration.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDatasetConfiguration.TypeConverter.cs new file mode 100644 index 000000000000..447b9ffd4e75 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDatasetConfiguration.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class ReportConfigDatasetConfigurationTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetConfiguration ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetConfiguration).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return ReportConfigDatasetConfiguration.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return ReportConfigDatasetConfiguration.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return ReportConfigDatasetConfiguration.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDatasetConfiguration.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDatasetConfiguration.cs new file mode 100644 index 000000000000..7fb2105472dd --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDatasetConfiguration.cs @@ -0,0 +1,55 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The configuration of dataset in the report. + public partial class ReportConfigDatasetConfiguration : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetConfiguration, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetConfigurationInternal + { + + /// Backing field for property. + private string[] _column; + + /// + /// Array of column names to be included in the report. Any valid report column name is allowed. If not provided, then report + /// includes all columns. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string[] Column { get => this._column; set => this._column = value; } + + /// Creates an new instance. + public ReportConfigDatasetConfiguration() + { + + } + } + /// The configuration of dataset in the report. + public partial interface IReportConfigDatasetConfiguration : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// + /// Array of column names to be included in the report. Any valid report column name is allowed. If not provided, then report + /// includes all columns. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Array of column names to be included in the report. Any valid report column name is allowed. If not provided, then report includes all columns.", + SerializedName = @"columns", + PossibleTypes = new [] { typeof(string) })] + string[] Column { get; set; } + + } + /// The configuration of dataset in the report. + public partial interface IReportConfigDatasetConfigurationInternal + + { + /// + /// Array of column names to be included in the report. Any valid report column name is allowed. If not provided, then report + /// includes all columns. + /// + string[] Column { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDatasetConfiguration.json.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDatasetConfiguration.json.cs new file mode 100644 index 000000000000..e22b7e18a7c3 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDatasetConfiguration.json.cs @@ -0,0 +1,109 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The configuration of dataset in the report. + public partial class ReportConfigDatasetConfiguration + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetConfiguration. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetConfiguration. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetConfiguration FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new ReportConfigDatasetConfiguration(json) : null; + } + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal ReportConfigDatasetConfiguration(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_column = If( json?.PropertyT("columns"), out var __jsonColumns) ? If( __jsonColumns as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonArray, out var __v) ? new global::System.Func(()=> global::System.Linq.Enumerable.ToArray(global::System.Linq.Enumerable.Select(__v, (__u)=>(string) (__u is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString __t ? (string)(__t.ToString()) : null)) ))() : null : Column;} + AfterFromJson(json); + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + if (null != this._column) + { + var __w = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.XNodeArray(); + foreach( var __x in this._column ) + { + AddIf(null != (((object)__x)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(__x.ToString()) : null ,__w.Add); + } + container.Add("columns",__w); + } + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDefinition.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDefinition.PowerShell.cs new file mode 100644 index 000000000000..214a24f03d8f --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDefinition.PowerShell.cs @@ -0,0 +1,157 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// The definition of a report config. + [System.ComponentModel.TypeConverter(typeof(ReportConfigDefinitionTypeConverter))] + public partial class ReportConfigDefinition + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new ReportConfigDefinition(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new ReportConfigDefinition(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal ReportConfigDefinition(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).Dataset = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1) content.GetValueForProperty("Dataset",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).Dataset, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDataset1TypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).TimePeriod = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigTimePeriod) content.GetValueForProperty("TimePeriod",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).TimePeriod, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigTimePeriodTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).Type = (string) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).Type, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).Timeframe = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportTimeframeType) content.GetValueForProperty("Timeframe",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).Timeframe, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportTimeframeType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).DatasetConfiguration = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetConfiguration) content.GetValueForProperty("DatasetConfiguration",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).DatasetConfiguration, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDatasetConfigurationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).DatasetAggregation = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetAggregation) content.GetValueForProperty("DatasetAggregation",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).DatasetAggregation, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDatasetAggregationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).DatasetFilter = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1) content.GetValueForProperty("DatasetFilter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).DatasetFilter, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigFilter1TypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).DatasetGranularity = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType?) content.GetValueForProperty("DatasetGranularity",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).DatasetGranularity, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).DatasetGrouping = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGrouping[]) content.GetValueForProperty("DatasetGrouping",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).DatasetGrouping, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigGroupingTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).DatasetSorting = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSorting[]) content.GetValueForProperty("DatasetSorting",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).DatasetSorting, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigSortingTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).TimePeriodFrom = (global::System.DateTime) content.GetValueForProperty("TimePeriodFrom",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).TimePeriodFrom, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).TimePeriodTo = (global::System.DateTime) content.GetValueForProperty("TimePeriodTo",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).TimePeriodTo, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).ConfigurationColumn = (string[]) content.GetValueForProperty("ConfigurationColumn",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).ConfigurationColumn, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal ReportConfigDefinition(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).Dataset = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1) content.GetValueForProperty("Dataset",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).Dataset, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDataset1TypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).TimePeriod = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigTimePeriod) content.GetValueForProperty("TimePeriod",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).TimePeriod, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigTimePeriodTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).Type = (string) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).Type, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).Timeframe = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportTimeframeType) content.GetValueForProperty("Timeframe",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).Timeframe, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportTimeframeType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).DatasetConfiguration = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetConfiguration) content.GetValueForProperty("DatasetConfiguration",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).DatasetConfiguration, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDatasetConfigurationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).DatasetAggregation = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetAggregation) content.GetValueForProperty("DatasetAggregation",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).DatasetAggregation, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDatasetAggregationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).DatasetFilter = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1) content.GetValueForProperty("DatasetFilter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).DatasetFilter, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigFilter1TypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).DatasetGranularity = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType?) content.GetValueForProperty("DatasetGranularity",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).DatasetGranularity, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).DatasetGrouping = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGrouping[]) content.GetValueForProperty("DatasetGrouping",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).DatasetGrouping, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigGroupingTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).DatasetSorting = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSorting[]) content.GetValueForProperty("DatasetSorting",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).DatasetSorting, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigSortingTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).TimePeriodFrom = (global::System.DateTime) content.GetValueForProperty("TimePeriodFrom",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).TimePeriodFrom, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).TimePeriodTo = (global::System.DateTime) content.GetValueForProperty("TimePeriodTo",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).TimePeriodTo, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).ConfigurationColumn = (string[]) content.GetValueForProperty("ConfigurationColumn",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)this).ConfigurationColumn, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + AfterDeserializePSObject(content); + } + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// The definition of a report config. + [System.ComponentModel.TypeConverter(typeof(ReportConfigDefinitionTypeConverter))] + public partial interface IReportConfigDefinition + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDefinition.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDefinition.TypeConverter.cs new file mode 100644 index 000000000000..0f02c0134706 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDefinition.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class ReportConfigDefinitionTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return ReportConfigDefinition.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return ReportConfigDefinition.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return ReportConfigDefinition.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDefinition.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDefinition.cs new file mode 100644 index 000000000000..7a268818c078 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDefinition.cs @@ -0,0 +1,249 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The definition of a report config. + public partial class ReportConfigDefinition : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal + { + + /// + /// Array of column names to be included in the report. Any valid report column name is allowed. If not provided, then report + /// includes all columns. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string[] ConfigurationColumn { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1Internal)Dataset).ConfigurationColumn; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1Internal)Dataset).ConfigurationColumn = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1 _dataset; + + /// Has definition for data in this report config. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + internal Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1 Dataset { get => (this._dataset = this._dataset ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDataset1()); set => this._dataset = value; } + + /// + /// Dictionary of aggregation expression to use in the report. The key of each item in the dictionary is the alias for the + /// aggregated column. Report can have up to 2 aggregation clauses. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetAggregation DatasetAggregation { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1Internal)Dataset).Aggregation; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1Internal)Dataset).Aggregation = value; } + + /// Has filter expression to use in the report. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1 DatasetFilter { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1Internal)Dataset).Filter; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1Internal)Dataset).Filter = value; } + + /// The granularity of rows in the report. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType? DatasetGranularity { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1Internal)Dataset).Granularity; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1Internal)Dataset).Granularity = value; } + + /// + /// Array of group by expression to use in the report. Report can have up to 2 group by clauses. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGrouping[] DatasetGrouping { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1Internal)Dataset).Grouping; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1Internal)Dataset).Grouping = value; } + + /// Array of order by expression to use in the report. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSorting[] DatasetSorting { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1Internal)Dataset).Sorting; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1Internal)Dataset).Sorting = value; } + + /// Internal Acessors for Dataset + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1 Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal.Dataset { get => (this._dataset = this._dataset ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDataset1()); set { {_dataset = value;} } } + + /// Internal Acessors for DatasetConfiguration + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetConfiguration Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal.DatasetConfiguration { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1Internal)Dataset).Configuration; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1Internal)Dataset).Configuration = value; } + + /// Internal Acessors for TimePeriod + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigTimePeriod Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal.TimePeriod { get => (this._timePeriod = this._timePeriod ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigTimePeriod()); set { {_timePeriod = value;} } } + + /// Internal Acessors for Type + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal.Type { get => this._type; set { {_type = value;} } } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigTimePeriod _timePeriod; + + /// Has time period for pulling data for the report. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + internal Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigTimePeriod TimePeriod { get => (this._timePeriod = this._timePeriod ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigTimePeriod()); set => this._timePeriod = value; } + + /// The start date to pull data from. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public global::System.DateTime TimePeriodFrom { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigTimePeriodInternal)TimePeriod).From; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigTimePeriodInternal)TimePeriod).From = value; } + + /// The end date to pull data to. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public global::System.DateTime TimePeriodTo { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigTimePeriodInternal)TimePeriod).To; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigTimePeriodInternal)TimePeriod).To = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportTimeframeType _timeframe; + + /// + /// The time frame for pulling data for the report. If custom, then a specific time period must be provided. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportTimeframeType Timeframe { get => this._timeframe; set => this._timeframe = value; } + + /// Backing field for property. + private string _type= @"Usage"; + + /// + /// The type of the report. Usage represents actual usage, forecast represents forecasted data and UsageAndForecast represents + /// both usage and forecasted data. Actual usage and forecasted data can be differentiated based on dates. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string Type { get => this._type; } + + /// Creates an new instance. + public ReportConfigDefinition() + { + + } + } + /// The definition of a report config. + public partial interface IReportConfigDefinition : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// + /// Array of column names to be included in the report. Any valid report column name is allowed. If not provided, then report + /// includes all columns. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Array of column names to be included in the report. Any valid report column name is allowed. If not provided, then report includes all columns.", + SerializedName = @"columns", + PossibleTypes = new [] { typeof(string) })] + string[] ConfigurationColumn { get; set; } + /// + /// Dictionary of aggregation expression to use in the report. The key of each item in the dictionary is the alias for the + /// aggregated column. Report can have up to 2 aggregation clauses. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Dictionary of aggregation expression to use in the report. The key of each item in the dictionary is the alias for the aggregated column. Report can have up to 2 aggregation clauses.", + SerializedName = @"aggregation", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetAggregation) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetAggregation DatasetAggregation { get; set; } + /// Has filter expression to use in the report. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Has filter expression to use in the report.", + SerializedName = @"filter", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1 DatasetFilter { get; set; } + /// The granularity of rows in the report. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The granularity of rows in the report.", + SerializedName = @"granularity", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType? DatasetGranularity { get; set; } + /// + /// Array of group by expression to use in the report. Report can have up to 2 group by clauses. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Array of group by expression to use in the report. Report can have up to 2 group by clauses.", + SerializedName = @"grouping", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGrouping) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGrouping[] DatasetGrouping { get; set; } + /// Array of order by expression to use in the report. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Array of order by expression to use in the report.", + SerializedName = @"sorting", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSorting) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSorting[] DatasetSorting { get; set; } + /// The start date to pull data from. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The start date to pull data from.", + SerializedName = @"from", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime TimePeriodFrom { get; set; } + /// The end date to pull data to. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The end date to pull data to.", + SerializedName = @"to", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime TimePeriodTo { get; set; } + /// + /// The time frame for pulling data for the report. If custom, then a specific time period must be provided. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The time frame for pulling data for the report. If custom, then a specific time period must be provided.", + SerializedName = @"timeframe", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportTimeframeType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportTimeframeType Timeframe { get; set; } + /// + /// The type of the report. Usage represents actual usage, forecast represents forecasted data and UsageAndForecast represents + /// both usage and forecasted data. Actual usage and forecasted data can be differentiated based on dates. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = true, + Description = @"The type of the report. Usage represents actual usage, forecast represents forecasted data and UsageAndForecast represents both usage and forecasted data. Actual usage and forecasted data can be differentiated based on dates.", + SerializedName = @"type", + PossibleTypes = new [] { typeof(string) })] + string Type { get; } + + } + /// The definition of a report config. + public partial interface IReportConfigDefinitionInternal + + { + /// + /// Array of column names to be included in the report. Any valid report column name is allowed. If not provided, then report + /// includes all columns. + /// + string[] ConfigurationColumn { get; set; } + /// Has definition for data in this report config. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1 Dataset { get; set; } + /// + /// Dictionary of aggregation expression to use in the report. The key of each item in the dictionary is the alias for the + /// aggregated column. Report can have up to 2 aggregation clauses. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetAggregation DatasetAggregation { get; set; } + /// + /// Has configuration information for the data in the report. The configuration will be ignored if aggregation and grouping + /// are provided. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetConfiguration DatasetConfiguration { get; set; } + /// Has filter expression to use in the report. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1 DatasetFilter { get; set; } + /// The granularity of rows in the report. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType? DatasetGranularity { get; set; } + /// + /// Array of group by expression to use in the report. Report can have up to 2 group by clauses. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGrouping[] DatasetGrouping { get; set; } + /// Array of order by expression to use in the report. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSorting[] DatasetSorting { get; set; } + /// Has time period for pulling data for the report. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigTimePeriod TimePeriod { get; set; } + /// The start date to pull data from. + global::System.DateTime TimePeriodFrom { get; set; } + /// The end date to pull data to. + global::System.DateTime TimePeriodTo { get; set; } + /// + /// The time frame for pulling data for the report. If custom, then a specific time period must be provided. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportTimeframeType Timeframe { get; set; } + /// + /// The type of the report. Usage represents actual usage, forecast represents forecasted data and UsageAndForecast represents + /// both usage and forecasted data. Actual usage and forecasted data can be differentiated based on dates. + /// + string Type { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDefinition.json.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDefinition.json.cs new file mode 100644 index 000000000000..def5847e0bb5 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDefinition.json.cs @@ -0,0 +1,107 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The definition of a report config. + public partial class ReportConfigDefinition + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new ReportConfigDefinition(json) : null; + } + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal ReportConfigDefinition(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_dataset = If( json?.PropertyT("dataset"), out var __jsonDataset) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDataset1.FromJson(__jsonDataset) : Dataset;} + {_timePeriod = If( json?.PropertyT("timePeriod"), out var __jsonTimePeriod) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigTimePeriod.FromJson(__jsonTimePeriod) : TimePeriod;} + {_type = If( json?.PropertyT("type"), out var __jsonType) ? (string)__jsonType : (string)Type;} + {_timeframe = If( json?.PropertyT("timeframe"), out var __jsonTimeframe) ? (string)__jsonTimeframe : (string)Timeframe;} + AfterFromJson(json); + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + AddIf( null != this._dataset ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._dataset.ToJson(null,serializationMode) : null, "dataset" ,container.Add ); + AddIf( null != this._timePeriod ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._timePeriod.ToJson(null,serializationMode) : null, "timePeriod" ,container.Add ); + AddIf( null != (((object)this._type)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._type.ToString()) : null, "type" ,container.Add ); + AddIf( null != (((object)this._timeframe)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._timeframe.ToString()) : null, "timeframe" ,container.Add ); + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDefinition1.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDefinition1.PowerShell.cs new file mode 100644 index 000000000000..d3d8e72d1a34 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDefinition1.PowerShell.cs @@ -0,0 +1,157 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// The definition of a report config. + [System.ComponentModel.TypeConverter(typeof(ReportConfigDefinition1TypeConverter))] + public partial class ReportConfigDefinition1 + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1 DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new ReportConfigDefinition1(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1 DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new ReportConfigDefinition1(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1 FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal ReportConfigDefinition1(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).Dataset = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset) content.GetValueForProperty("Dataset",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).Dataset, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDatasetTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).TimePeriod = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigTimePeriod) content.GetValueForProperty("TimePeriod",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).TimePeriod, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigTimePeriodTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).Type = (string) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).Type, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).Timeframe = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportTimeframeType) content.GetValueForProperty("Timeframe",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).Timeframe, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportTimeframeType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).DatasetConfiguration = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetConfiguration) content.GetValueForProperty("DatasetConfiguration",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).DatasetConfiguration, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDatasetConfigurationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).DatasetAggregation = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetAggregation) content.GetValueForProperty("DatasetAggregation",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).DatasetAggregation, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDatasetAggregationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).DatasetFilter = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter) content.GetValueForProperty("DatasetFilter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).DatasetFilter, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigFilterTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).DatasetGranularity = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType?) content.GetValueForProperty("DatasetGranularity",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).DatasetGranularity, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).DatasetGrouping = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGrouping[]) content.GetValueForProperty("DatasetGrouping",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).DatasetGrouping, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigGroupingTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).DatasetSorting = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSorting[]) content.GetValueForProperty("DatasetSorting",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).DatasetSorting, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigSortingTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).TimePeriodFrom = (global::System.DateTime) content.GetValueForProperty("TimePeriodFrom",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).TimePeriodFrom, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).TimePeriodTo = (global::System.DateTime) content.GetValueForProperty("TimePeriodTo",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).TimePeriodTo, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).ConfigurationColumn = (string[]) content.GetValueForProperty("ConfigurationColumn",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).ConfigurationColumn, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal ReportConfigDefinition1(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).Dataset = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset) content.GetValueForProperty("Dataset",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).Dataset, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDatasetTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).TimePeriod = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigTimePeriod) content.GetValueForProperty("TimePeriod",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).TimePeriod, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigTimePeriodTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).Type = (string) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).Type, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).Timeframe = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportTimeframeType) content.GetValueForProperty("Timeframe",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).Timeframe, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportTimeframeType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).DatasetConfiguration = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetConfiguration) content.GetValueForProperty("DatasetConfiguration",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).DatasetConfiguration, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDatasetConfigurationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).DatasetAggregation = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetAggregation) content.GetValueForProperty("DatasetAggregation",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).DatasetAggregation, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDatasetAggregationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).DatasetFilter = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter) content.GetValueForProperty("DatasetFilter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).DatasetFilter, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigFilterTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).DatasetGranularity = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType?) content.GetValueForProperty("DatasetGranularity",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).DatasetGranularity, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).DatasetGrouping = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGrouping[]) content.GetValueForProperty("DatasetGrouping",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).DatasetGrouping, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigGroupingTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).DatasetSorting = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSorting[]) content.GetValueForProperty("DatasetSorting",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).DatasetSorting, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigSortingTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).TimePeriodFrom = (global::System.DateTime) content.GetValueForProperty("TimePeriodFrom",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).TimePeriodFrom, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).TimePeriodTo = (global::System.DateTime) content.GetValueForProperty("TimePeriodTo",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).TimePeriodTo, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).ConfigurationColumn = (string[]) content.GetValueForProperty("ConfigurationColumn",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal)this).ConfigurationColumn, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + AfterDeserializePSObject(content); + } + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// The definition of a report config. + [System.ComponentModel.TypeConverter(typeof(ReportConfigDefinition1TypeConverter))] + public partial interface IReportConfigDefinition1 + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDefinition1.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDefinition1.TypeConverter.cs new file mode 100644 index 000000000000..d0a134a00f32 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDefinition1.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class ReportConfigDefinition1TypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1 ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return ReportConfigDefinition1.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return ReportConfigDefinition1.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return ReportConfigDefinition1.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDefinition1.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDefinition1.cs new file mode 100644 index 000000000000..a4d133b82f28 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDefinition1.cs @@ -0,0 +1,249 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The definition of a report config. + public partial class ReportConfigDefinition1 : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal + { + + /// + /// Array of column names to be included in the report. Any valid report column name is allowed. If not provided, then report + /// includes all columns. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string[] ConfigurationColumn { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetInternal)Dataset).ConfigurationColumn; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetInternal)Dataset).ConfigurationColumn = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset _dataset; + + /// Has definition for data in this report config. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + internal Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset Dataset { get => (this._dataset = this._dataset ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDataset()); set => this._dataset = value; } + + /// + /// Dictionary of aggregation expression to use in the report. The key of each item in the dictionary is the alias for the + /// aggregated column. Report can have up to 2 aggregation clauses. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetAggregation DatasetAggregation { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetInternal)Dataset).Aggregation; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetInternal)Dataset).Aggregation = value; } + + /// Has filter expression to use in the report. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter DatasetFilter { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetInternal)Dataset).Filter; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetInternal)Dataset).Filter = value; } + + /// The granularity of rows in the report. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType? DatasetGranularity { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetInternal)Dataset).Granularity; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetInternal)Dataset).Granularity = value; } + + /// + /// Array of group by expression to use in the report. Report can have up to 2 group by clauses. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGrouping[] DatasetGrouping { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetInternal)Dataset).Grouping; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetInternal)Dataset).Grouping = value; } + + /// Array of order by expression to use in the report. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSorting[] DatasetSorting { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetInternal)Dataset).Sorting; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetInternal)Dataset).Sorting = value; } + + /// Internal Acessors for Dataset + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal.Dataset { get => (this._dataset = this._dataset ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDataset()); set { {_dataset = value;} } } + + /// Internal Acessors for DatasetConfiguration + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetConfiguration Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal.DatasetConfiguration { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetInternal)Dataset).Configuration; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetInternal)Dataset).Configuration = value; } + + /// Internal Acessors for TimePeriod + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigTimePeriod Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal.TimePeriod { get => (this._timePeriod = this._timePeriod ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigTimePeriod()); set { {_timePeriod = value;} } } + + /// Internal Acessors for Type + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1Internal.Type { get => this._type; set { {_type = value;} } } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigTimePeriod _timePeriod; + + /// Has time period for pulling data for the report. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + internal Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigTimePeriod TimePeriod { get => (this._timePeriod = this._timePeriod ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigTimePeriod()); set => this._timePeriod = value; } + + /// The start date to pull data from. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public global::System.DateTime TimePeriodFrom { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigTimePeriodInternal)TimePeriod).From; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigTimePeriodInternal)TimePeriod).From = value; } + + /// The end date to pull data to. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public global::System.DateTime TimePeriodTo { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigTimePeriodInternal)TimePeriod).To; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigTimePeriodInternal)TimePeriod).To = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportTimeframeType _timeframe; + + /// + /// The time frame for pulling data for the report. If custom, then a specific time period must be provided. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportTimeframeType Timeframe { get => this._timeframe; set => this._timeframe = value; } + + /// Backing field for property. + private string _type= @"Usage"; + + /// + /// The type of the report. Usage represents actual usage, forecast represents forecasted data and UsageAndForecast represents + /// both usage and forecasted data. Actual usage and forecasted data can be differentiated based on dates. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string Type { get => this._type; } + + /// Creates an new instance. + public ReportConfigDefinition1() + { + + } + } + /// The definition of a report config. + public partial interface IReportConfigDefinition1 : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// + /// Array of column names to be included in the report. Any valid report column name is allowed. If not provided, then report + /// includes all columns. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Array of column names to be included in the report. Any valid report column name is allowed. If not provided, then report includes all columns.", + SerializedName = @"columns", + PossibleTypes = new [] { typeof(string) })] + string[] ConfigurationColumn { get; set; } + /// + /// Dictionary of aggregation expression to use in the report. The key of each item in the dictionary is the alias for the + /// aggregated column. Report can have up to 2 aggregation clauses. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Dictionary of aggregation expression to use in the report. The key of each item in the dictionary is the alias for the aggregated column. Report can have up to 2 aggregation clauses.", + SerializedName = @"aggregation", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetAggregation) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetAggregation DatasetAggregation { get; set; } + /// Has filter expression to use in the report. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Has filter expression to use in the report.", + SerializedName = @"filter", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter DatasetFilter { get; set; } + /// The granularity of rows in the report. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The granularity of rows in the report.", + SerializedName = @"granularity", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType? DatasetGranularity { get; set; } + /// + /// Array of group by expression to use in the report. Report can have up to 2 group by clauses. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Array of group by expression to use in the report. Report can have up to 2 group by clauses.", + SerializedName = @"grouping", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGrouping) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGrouping[] DatasetGrouping { get; set; } + /// Array of order by expression to use in the report. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Array of order by expression to use in the report.", + SerializedName = @"sorting", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSorting) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSorting[] DatasetSorting { get; set; } + /// The start date to pull data from. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The start date to pull data from.", + SerializedName = @"from", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime TimePeriodFrom { get; set; } + /// The end date to pull data to. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The end date to pull data to.", + SerializedName = @"to", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime TimePeriodTo { get; set; } + /// + /// The time frame for pulling data for the report. If custom, then a specific time period must be provided. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The time frame for pulling data for the report. If custom, then a specific time period must be provided.", + SerializedName = @"timeframe", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportTimeframeType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportTimeframeType Timeframe { get; set; } + /// + /// The type of the report. Usage represents actual usage, forecast represents forecasted data and UsageAndForecast represents + /// both usage and forecasted data. Actual usage and forecasted data can be differentiated based on dates. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = true, + Description = @"The type of the report. Usage represents actual usage, forecast represents forecasted data and UsageAndForecast represents both usage and forecasted data. Actual usage and forecasted data can be differentiated based on dates.", + SerializedName = @"type", + PossibleTypes = new [] { typeof(string) })] + string Type { get; } + + } + /// The definition of a report config. + public partial interface IReportConfigDefinition1Internal + + { + /// + /// Array of column names to be included in the report. Any valid report column name is allowed. If not provided, then report + /// includes all columns. + /// + string[] ConfigurationColumn { get; set; } + /// Has definition for data in this report config. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset Dataset { get; set; } + /// + /// Dictionary of aggregation expression to use in the report. The key of each item in the dictionary is the alias for the + /// aggregated column. Report can have up to 2 aggregation clauses. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetAggregation DatasetAggregation { get; set; } + /// + /// Has configuration information for the data in the report. The configuration will be ignored if aggregation and grouping + /// are provided. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetConfiguration DatasetConfiguration { get; set; } + /// Has filter expression to use in the report. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter DatasetFilter { get; set; } + /// The granularity of rows in the report. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType? DatasetGranularity { get; set; } + /// + /// Array of group by expression to use in the report. Report can have up to 2 group by clauses. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGrouping[] DatasetGrouping { get; set; } + /// Array of order by expression to use in the report. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSorting[] DatasetSorting { get; set; } + /// Has time period for pulling data for the report. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigTimePeriod TimePeriod { get; set; } + /// The start date to pull data from. + global::System.DateTime TimePeriodFrom { get; set; } + /// The end date to pull data to. + global::System.DateTime TimePeriodTo { get; set; } + /// + /// The time frame for pulling data for the report. If custom, then a specific time period must be provided. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportTimeframeType Timeframe { get; set; } + /// + /// The type of the report. Usage represents actual usage, forecast represents forecasted data and UsageAndForecast represents + /// both usage and forecasted data. Actual usage and forecasted data can be differentiated based on dates. + /// + string Type { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDefinition1.json.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDefinition1.json.cs new file mode 100644 index 000000000000..0d5c249aeb0c --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigDefinition1.json.cs @@ -0,0 +1,107 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The definition of a report config. + public partial class ReportConfigDefinition1 + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition1 FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new ReportConfigDefinition1(json) : null; + } + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal ReportConfigDefinition1(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_dataset = If( json?.PropertyT("dataset"), out var __jsonDataset) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDataset.FromJson(__jsonDataset) : Dataset;} + {_timePeriod = If( json?.PropertyT("timePeriod"), out var __jsonTimePeriod) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigTimePeriod.FromJson(__jsonTimePeriod) : TimePeriod;} + {_type = If( json?.PropertyT("type"), out var __jsonType) ? (string)__jsonType : (string)Type;} + {_timeframe = If( json?.PropertyT("timeframe"), out var __jsonTimeframe) ? (string)__jsonTimeframe : (string)Timeframe;} + AfterFromJson(json); + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + AddIf( null != this._dataset ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._dataset.ToJson(null,serializationMode) : null, "dataset" ,container.Add ); + AddIf( null != this._timePeriod ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._timePeriod.ToJson(null,serializationMode) : null, "timePeriod" ,container.Add ); + AddIf( null != (((object)this._type)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._type.ToString()) : null, "type" ,container.Add ); + AddIf( null != (((object)this._timeframe)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._timeframe.ToString()) : null, "timeframe" ,container.Add ); + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigFilter.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigFilter.PowerShell.cs new file mode 100644 index 000000000000..17d5c3be6857 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigFilter.PowerShell.cs @@ -0,0 +1,139 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// The filter expression to be used in the report. + [System.ComponentModel.TypeConverter(typeof(ReportConfigFilterTypeConverter))] + public partial class ReportConfigFilter + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new ReportConfigFilter(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new ReportConfigFilter(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal ReportConfigFilter(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilterInternal)this).And = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter[]) content.GetValueForProperty("And",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilterInternal)this).And, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigFilterTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilterInternal)this).Dimension = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigComparisonExpression) content.GetValueForProperty("Dimension",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilterInternal)this).Dimension, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigComparisonExpressionTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilterInternal)this).Not = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter) content.GetValueForProperty("Not",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilterInternal)this).Not, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigFilterTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilterInternal)this).Or = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter[]) content.GetValueForProperty("Or",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilterInternal)this).Or, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigFilterTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilterInternal)this).Tag = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigComparisonExpression) content.GetValueForProperty("Tag",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilterInternal)this).Tag, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigComparisonExpressionTypeConverter.ConvertFrom); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal ReportConfigFilter(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilterInternal)this).And = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter[]) content.GetValueForProperty("And",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilterInternal)this).And, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigFilterTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilterInternal)this).Dimension = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigComparisonExpression) content.GetValueForProperty("Dimension",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilterInternal)this).Dimension, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigComparisonExpressionTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilterInternal)this).Not = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter) content.GetValueForProperty("Not",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilterInternal)this).Not, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigFilterTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilterInternal)this).Or = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter[]) content.GetValueForProperty("Or",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilterInternal)this).Or, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigFilterTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilterInternal)this).Tag = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigComparisonExpression) content.GetValueForProperty("Tag",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilterInternal)this).Tag, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigComparisonExpressionTypeConverter.ConvertFrom); + AfterDeserializePSObject(content); + } + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// The filter expression to be used in the report. + [System.ComponentModel.TypeConverter(typeof(ReportConfigFilterTypeConverter))] + public partial interface IReportConfigFilter + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigFilter.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigFilter.TypeConverter.cs new file mode 100644 index 000000000000..79bc84dee6af --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigFilter.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class ReportConfigFilterTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return ReportConfigFilter.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return ReportConfigFilter.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return ReportConfigFilter.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigFilter.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigFilter.cs new file mode 100644 index 000000000000..95e9b18f55a8 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigFilter.cs @@ -0,0 +1,114 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The filter expression to be used in the report. + public partial class ReportConfigFilter : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilterInternal + { + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter[] _and; + + /// The logical "AND" expression. Must have at least 2 items. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter[] And { get => this._and; set => this._and = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigComparisonExpression _dimension; + + /// Has comparison expression for a dimension + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigComparisonExpression Dimension { get => (this._dimension = this._dimension ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigComparisonExpression()); set => this._dimension = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter _not; + + /// The logical "NOT" expression. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter Not { get => (this._not = this._not ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigFilter()); set => this._not = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter[] _or; + + /// The logical "OR" expression. Must have at least 2 items. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter[] Or { get => this._or; set => this._or = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigComparisonExpression _tag; + + /// Has comparison expression for a tag + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigComparisonExpression Tag { get => (this._tag = this._tag ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigComparisonExpression()); set => this._tag = value; } + + /// Creates an new instance. + public ReportConfigFilter() + { + + } + } + /// The filter expression to be used in the report. + public partial interface IReportConfigFilter : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// The logical "AND" expression. Must have at least 2 items. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The logical ""AND"" expression. Must have at least 2 items.", + SerializedName = @"and", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter[] And { get; set; } + /// Has comparison expression for a dimension + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Has comparison expression for a dimension", + SerializedName = @"dimension", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigComparisonExpression) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigComparisonExpression Dimension { get; set; } + /// The logical "NOT" expression. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The logical ""NOT"" expression.", + SerializedName = @"not", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter Not { get; set; } + /// The logical "OR" expression. Must have at least 2 items. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The logical ""OR"" expression. Must have at least 2 items.", + SerializedName = @"or", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter[] Or { get; set; } + /// Has comparison expression for a tag + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Has comparison expression for a tag", + SerializedName = @"tag", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigComparisonExpression) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigComparisonExpression Tag { get; set; } + + } + /// The filter expression to be used in the report. + public partial interface IReportConfigFilterInternal + + { + /// The logical "AND" expression. Must have at least 2 items. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter[] And { get; set; } + /// Has comparison expression for a dimension + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigComparisonExpression Dimension { get; set; } + /// The logical "NOT" expression. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter Not { get; set; } + /// The logical "OR" expression. Must have at least 2 items. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter[] Or { get; set; } + /// Has comparison expression for a tag + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigComparisonExpression Tag { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigFilter.json.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigFilter.json.cs new file mode 100644 index 000000000000..2b02e0d3713c --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigFilter.json.cs @@ -0,0 +1,125 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The filter expression to be used in the report. + public partial class ReportConfigFilter + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new ReportConfigFilter(json) : null; + } + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal ReportConfigFilter(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_and = If( json?.PropertyT("and"), out var __jsonAnd) ? If( __jsonAnd as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonArray, out var __v) ? new global::System.Func(()=> global::System.Linq.Enumerable.ToArray(global::System.Linq.Enumerable.Select(__v, (__u)=>(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter) (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigFilter.FromJson(__u) )) ))() : null : And;} + {_dimension = If( json?.PropertyT("dimension"), out var __jsonDimension) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigComparisonExpression.FromJson(__jsonDimension) : Dimension;} + {_not = If( json?.PropertyT("not"), out var __jsonNot) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigFilter.FromJson(__jsonNot) : Not;} + {_or = If( json?.PropertyT("or"), out var __jsonOr) ? If( __jsonOr as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonArray, out var __q) ? new global::System.Func(()=> global::System.Linq.Enumerable.ToArray(global::System.Linq.Enumerable.Select(__q, (__p)=>(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter) (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigFilter.FromJson(__p) )) ))() : null : Or;} + {_tag = If( json?.PropertyT("tag"), out var __jsonTag) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigComparisonExpression.FromJson(__jsonTag) : Tag;} + AfterFromJson(json); + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + if (null != this._and) + { + var __w = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.XNodeArray(); + foreach( var __x in this._and ) + { + AddIf(__x?.ToJson(null, serializationMode) ,__w.Add); + } + container.Add("and",__w); + } + AddIf( null != this._dimension ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._dimension.ToJson(null,serializationMode) : null, "dimension" ,container.Add ); + AddIf( null != this._not ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._not.ToJson(null,serializationMode) : null, "not" ,container.Add ); + if (null != this._or) + { + var __r = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.XNodeArray(); + foreach( var __s in this._or ) + { + AddIf(__s?.ToJson(null, serializationMode) ,__r.Add); + } + container.Add("or",__r); + } + AddIf( null != this._tag ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._tag.ToJson(null,serializationMode) : null, "tag" ,container.Add ); + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigFilter1.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigFilter1.PowerShell.cs new file mode 100644 index 000000000000..242c7785e1a7 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigFilter1.PowerShell.cs @@ -0,0 +1,139 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// The filter expression to be used in the report. + [System.ComponentModel.TypeConverter(typeof(ReportConfigFilter1TypeConverter))] + public partial class ReportConfigFilter1 + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1 DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new ReportConfigFilter1(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1 DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new ReportConfigFilter1(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1 FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal ReportConfigFilter1(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1Internal)this).And = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1[]) content.GetValueForProperty("And",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1Internal)this).And, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigFilter1TypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1Internal)this).Dimension = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigComparisonExpression) content.GetValueForProperty("Dimension",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1Internal)this).Dimension, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigComparisonExpressionTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1Internal)this).Not = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1) content.GetValueForProperty("Not",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1Internal)this).Not, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigFilter1TypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1Internal)this).Or = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1[]) content.GetValueForProperty("Or",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1Internal)this).Or, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigFilter1TypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1Internal)this).Tag = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigComparisonExpression) content.GetValueForProperty("Tag",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1Internal)this).Tag, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigComparisonExpressionTypeConverter.ConvertFrom); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal ReportConfigFilter1(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1Internal)this).And = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1[]) content.GetValueForProperty("And",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1Internal)this).And, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigFilter1TypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1Internal)this).Dimension = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigComparisonExpression) content.GetValueForProperty("Dimension",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1Internal)this).Dimension, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigComparisonExpressionTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1Internal)this).Not = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1) content.GetValueForProperty("Not",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1Internal)this).Not, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigFilter1TypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1Internal)this).Or = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1[]) content.GetValueForProperty("Or",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1Internal)this).Or, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigFilter1TypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1Internal)this).Tag = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigComparisonExpression) content.GetValueForProperty("Tag",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1Internal)this).Tag, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigComparisonExpressionTypeConverter.ConvertFrom); + AfterDeserializePSObject(content); + } + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// The filter expression to be used in the report. + [System.ComponentModel.TypeConverter(typeof(ReportConfigFilter1TypeConverter))] + public partial interface IReportConfigFilter1 + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigFilter1.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigFilter1.TypeConverter.cs new file mode 100644 index 000000000000..25b3f6a0b229 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigFilter1.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class ReportConfigFilter1TypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1 ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return ReportConfigFilter1.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return ReportConfigFilter1.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return ReportConfigFilter1.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigFilter1.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigFilter1.cs new file mode 100644 index 000000000000..74aedc0d7dd5 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigFilter1.cs @@ -0,0 +1,114 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The filter expression to be used in the report. + public partial class ReportConfigFilter1 : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1Internal + { + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1[] _and; + + /// The logical "AND" expression. Must have at least 2 items. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1[] And { get => this._and; set => this._and = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigComparisonExpression _dimension; + + /// Has comparison expression for a dimension + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigComparisonExpression Dimension { get => (this._dimension = this._dimension ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigComparisonExpression()); set => this._dimension = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1 _not; + + /// The logical "NOT" expression. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1 Not { get => (this._not = this._not ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigFilter1()); set => this._not = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1[] _or; + + /// The logical "OR" expression. Must have at least 2 items. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1[] Or { get => this._or; set => this._or = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigComparisonExpression _tag; + + /// Has comparison expression for a tag + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigComparisonExpression Tag { get => (this._tag = this._tag ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigComparisonExpression()); set => this._tag = value; } + + /// Creates an new instance. + public ReportConfigFilter1() + { + + } + } + /// The filter expression to be used in the report. + public partial interface IReportConfigFilter1 : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// The logical "AND" expression. Must have at least 2 items. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The logical ""AND"" expression. Must have at least 2 items.", + SerializedName = @"and", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1[] And { get; set; } + /// Has comparison expression for a dimension + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Has comparison expression for a dimension", + SerializedName = @"dimension", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigComparisonExpression) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigComparisonExpression Dimension { get; set; } + /// The logical "NOT" expression. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The logical ""NOT"" expression.", + SerializedName = @"not", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1 Not { get; set; } + /// The logical "OR" expression. Must have at least 2 items. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The logical ""OR"" expression. Must have at least 2 items.", + SerializedName = @"or", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1[] Or { get; set; } + /// Has comparison expression for a tag + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Has comparison expression for a tag", + SerializedName = @"tag", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigComparisonExpression) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigComparisonExpression Tag { get; set; } + + } + /// The filter expression to be used in the report. + public partial interface IReportConfigFilter1Internal + + { + /// The logical "AND" expression. Must have at least 2 items. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1[] And { get; set; } + /// Has comparison expression for a dimension + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigComparisonExpression Dimension { get; set; } + /// The logical "NOT" expression. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1 Not { get; set; } + /// The logical "OR" expression. Must have at least 2 items. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1[] Or { get; set; } + /// Has comparison expression for a tag + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigComparisonExpression Tag { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigFilter1.json.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigFilter1.json.cs new file mode 100644 index 000000000000..579facb82d3d --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigFilter1.json.cs @@ -0,0 +1,125 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The filter expression to be used in the report. + public partial class ReportConfigFilter1 + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1 FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new ReportConfigFilter1(json) : null; + } + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal ReportConfigFilter1(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_and = If( json?.PropertyT("and"), out var __jsonAnd) ? If( __jsonAnd as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonArray, out var __v) ? new global::System.Func(()=> global::System.Linq.Enumerable.ToArray(global::System.Linq.Enumerable.Select(__v, (__u)=>(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1) (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigFilter1.FromJson(__u) )) ))() : null : And;} + {_dimension = If( json?.PropertyT("dimension"), out var __jsonDimension) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigComparisonExpression.FromJson(__jsonDimension) : Dimension;} + {_not = If( json?.PropertyT("not"), out var __jsonNot) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigFilter1.FromJson(__jsonNot) : Not;} + {_or = If( json?.PropertyT("or"), out var __jsonOr) ? If( __jsonOr as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonArray, out var __q) ? new global::System.Func(()=> global::System.Linq.Enumerable.ToArray(global::System.Linq.Enumerable.Select(__q, (__p)=>(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1) (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigFilter1.FromJson(__p) )) ))() : null : Or;} + {_tag = If( json?.PropertyT("tag"), out var __jsonTag) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigComparisonExpression.FromJson(__jsonTag) : Tag;} + AfterFromJson(json); + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + if (null != this._and) + { + var __w = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.XNodeArray(); + foreach( var __x in this._and ) + { + AddIf(__x?.ToJson(null, serializationMode) ,__w.Add); + } + container.Add("and",__w); + } + AddIf( null != this._dimension ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._dimension.ToJson(null,serializationMode) : null, "dimension" ,container.Add ); + AddIf( null != this._not ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._not.ToJson(null,serializationMode) : null, "not" ,container.Add ); + if (null != this._or) + { + var __r = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.XNodeArray(); + foreach( var __s in this._or ) + { + AddIf(__s?.ToJson(null, serializationMode) ,__r.Add); + } + container.Add("or",__r); + } + AddIf( null != this._tag ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._tag.ToJson(null,serializationMode) : null, "tag" ,container.Add ); + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigGrouping.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigGrouping.PowerShell.cs new file mode 100644 index 000000000000..7be9e8764710 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigGrouping.PowerShell.cs @@ -0,0 +1,135 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// The group by expression to be used in the report. + [System.ComponentModel.TypeConverter(typeof(ReportConfigGroupingTypeConverter))] + public partial class ReportConfigGrouping + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGrouping DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new ReportConfigGrouping(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGrouping DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new ReportConfigGrouping(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGrouping FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal ReportConfigGrouping(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGroupingInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGroupingInternal)this).Name, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGroupingInternal)this).Type = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportConfigColumnType) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGroupingInternal)this).Type, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportConfigColumnType.CreateFrom); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal ReportConfigGrouping(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGroupingInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGroupingInternal)this).Name, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGroupingInternal)this).Type = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportConfigColumnType) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGroupingInternal)this).Type, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportConfigColumnType.CreateFrom); + AfterDeserializePSObject(content); + } + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// The group by expression to be used in the report. + [System.ComponentModel.TypeConverter(typeof(ReportConfigGroupingTypeConverter))] + public partial interface IReportConfigGrouping + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigGrouping.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigGrouping.TypeConverter.cs new file mode 100644 index 000000000000..8683ef3ce818 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigGrouping.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class ReportConfigGroupingTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGrouping ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGrouping).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return ReportConfigGrouping.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return ReportConfigGrouping.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return ReportConfigGrouping.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigGrouping.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigGrouping.cs new file mode 100644 index 000000000000..054c07d1dd6d --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigGrouping.cs @@ -0,0 +1,69 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The group by expression to be used in the report. + public partial class ReportConfigGrouping : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGrouping, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGroupingInternal + { + + /// Backing field for property. + private string _name; + + /// + /// The name of the column to group. This version supports subscription lowest possible grain. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string Name { get => this._name; set => this._name = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportConfigColumnType _type; + + /// Has type of the column to group. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportConfigColumnType Type { get => this._type; set => this._type = value; } + + /// Creates an new instance. + public ReportConfigGrouping() + { + + } + } + /// The group by expression to be used in the report. + public partial interface IReportConfigGrouping : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// + /// The name of the column to group. This version supports subscription lowest possible grain. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The name of the column to group. This version supports subscription lowest possible grain.", + SerializedName = @"name", + PossibleTypes = new [] { typeof(string) })] + string Name { get; set; } + /// Has type of the column to group. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"Has type of the column to group.", + SerializedName = @"type", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportConfigColumnType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportConfigColumnType Type { get; set; } + + } + /// The group by expression to be used in the report. + public partial interface IReportConfigGroupingInternal + + { + /// + /// The name of the column to group. This version supports subscription lowest possible grain. + /// + string Name { get; set; } + /// Has type of the column to group. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportConfigColumnType Type { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigGrouping.json.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigGrouping.json.cs new file mode 100644 index 000000000000..81531a8fd94c --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigGrouping.json.cs @@ -0,0 +1,103 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The group by expression to be used in the report. + public partial class ReportConfigGrouping + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGrouping. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGrouping. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGrouping FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new ReportConfigGrouping(json) : null; + } + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal ReportConfigGrouping(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_name = If( json?.PropertyT("name"), out var __jsonName) ? (string)__jsonName : (string)Name;} + {_type = If( json?.PropertyT("type"), out var __jsonType) ? (string)__jsonType : (string)Type;} + AfterFromJson(json); + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + AddIf( null != (((object)this._name)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._name.ToString()) : null, "name" ,container.Add ); + AddIf( null != (((object)this._type)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._type.ToString()) : null, "type" ,container.Add ); + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigSorting.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigSorting.PowerShell.cs new file mode 100644 index 000000000000..6de2796e77f3 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigSorting.PowerShell.cs @@ -0,0 +1,133 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// The order by expression to be used in the report. + [System.ComponentModel.TypeConverter(typeof(ReportConfigSortingTypeConverter))] + public partial class ReportConfigSorting + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSorting DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new ReportConfigSorting(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSorting DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new ReportConfigSorting(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSorting FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal ReportConfigSorting(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSortingInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSortingInternal)this).Name, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSortingInternal)this).Direction = (string) content.GetValueForProperty("Direction",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSortingInternal)this).Direction, global::System.Convert.ToString); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal ReportConfigSorting(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSortingInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSortingInternal)this).Name, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSortingInternal)this).Direction = (string) content.GetValueForProperty("Direction",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSortingInternal)this).Direction, global::System.Convert.ToString); + AfterDeserializePSObject(content); + } + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// The order by expression to be used in the report. + [System.ComponentModel.TypeConverter(typeof(ReportConfigSortingTypeConverter))] + public partial interface IReportConfigSorting + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigSorting.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigSorting.TypeConverter.cs new file mode 100644 index 000000000000..2215be22c41a --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigSorting.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class ReportConfigSortingTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSorting ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSorting).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return ReportConfigSorting.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return ReportConfigSorting.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return ReportConfigSorting.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigSorting.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigSorting.cs new file mode 100644 index 000000000000..c7f706097087 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigSorting.cs @@ -0,0 +1,63 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The order by expression to be used in the report. + public partial class ReportConfigSorting : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSorting, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSortingInternal + { + + /// Backing field for property. + private string _direction; + + /// Direction of sort. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string Direction { get => this._direction; set => this._direction = value; } + + /// Backing field for property. + private string _name; + + /// The name of the column to sort. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string Name { get => this._name; set => this._name = value; } + + /// Creates an new instance. + public ReportConfigSorting() + { + + } + } + /// The order by expression to be used in the report. + public partial interface IReportConfigSorting : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// Direction of sort. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Direction of sort.", + SerializedName = @"direction", + PossibleTypes = new [] { typeof(string) })] + string Direction { get; set; } + /// The name of the column to sort. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The name of the column to sort.", + SerializedName = @"name", + PossibleTypes = new [] { typeof(string) })] + string Name { get; set; } + + } + /// The order by expression to be used in the report. + public partial interface IReportConfigSortingInternal + + { + /// Direction of sort. + string Direction { get; set; } + /// The name of the column to sort. + string Name { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigSorting.json.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigSorting.json.cs new file mode 100644 index 000000000000..04bed20e709f --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigSorting.json.cs @@ -0,0 +1,103 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The order by expression to be used in the report. + public partial class ReportConfigSorting + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSorting. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSorting. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSorting FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new ReportConfigSorting(json) : null; + } + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal ReportConfigSorting(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_name = If( json?.PropertyT("name"), out var __jsonName) ? (string)__jsonName : (string)Name;} + {_direction = If( json?.PropertyT("direction"), out var __jsonDirection) ? (string)__jsonDirection : (string)Direction;} + AfterFromJson(json); + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + AddIf( null != (((object)this._name)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._name.ToString()) : null, "name" ,container.Add ); + AddIf( null != (((object)this._direction)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._direction.ToString()) : null, "direction" ,container.Add ); + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigTimePeriod.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigTimePeriod.PowerShell.cs new file mode 100644 index 000000000000..c224752f7f6c --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigTimePeriod.PowerShell.cs @@ -0,0 +1,135 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// The start and end date for pulling data for the report. + [System.ComponentModel.TypeConverter(typeof(ReportConfigTimePeriodTypeConverter))] + public partial class ReportConfigTimePeriod + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigTimePeriod DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new ReportConfigTimePeriod(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigTimePeriod DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new ReportConfigTimePeriod(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigTimePeriod FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal ReportConfigTimePeriod(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigTimePeriodInternal)this).From = (global::System.DateTime) content.GetValueForProperty("From",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigTimePeriodInternal)this).From, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigTimePeriodInternal)this).To = (global::System.DateTime) content.GetValueForProperty("To",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigTimePeriodInternal)this).To, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal ReportConfigTimePeriod(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigTimePeriodInternal)this).From = (global::System.DateTime) content.GetValueForProperty("From",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigTimePeriodInternal)this).From, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigTimePeriodInternal)this).To = (global::System.DateTime) content.GetValueForProperty("To",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigTimePeriodInternal)this).To, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + AfterDeserializePSObject(content); + } + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// The start and end date for pulling data for the report. + [System.ComponentModel.TypeConverter(typeof(ReportConfigTimePeriodTypeConverter))] + public partial interface IReportConfigTimePeriod + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigTimePeriod.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigTimePeriod.TypeConverter.cs new file mode 100644 index 000000000000..613c8253adae --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigTimePeriod.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class ReportConfigTimePeriodTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigTimePeriod ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigTimePeriod).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return ReportConfigTimePeriod.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return ReportConfigTimePeriod.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return ReportConfigTimePeriod.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigTimePeriod.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigTimePeriod.cs new file mode 100644 index 000000000000..379441927467 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigTimePeriod.cs @@ -0,0 +1,63 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The start and end date for pulling data for the report. + public partial class ReportConfigTimePeriod : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigTimePeriod, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigTimePeriodInternal + { + + /// Backing field for property. + private global::System.DateTime _from; + + /// The start date to pull data from. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public global::System.DateTime From { get => this._from; set => this._from = value; } + + /// Backing field for property. + private global::System.DateTime _to; + + /// The end date to pull data to. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public global::System.DateTime To { get => this._to; set => this._to = value; } + + /// Creates an new instance. + public ReportConfigTimePeriod() + { + + } + } + /// The start and end date for pulling data for the report. + public partial interface IReportConfigTimePeriod : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// The start date to pull data from. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The start date to pull data from.", + SerializedName = @"from", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime From { get; set; } + /// The end date to pull data to. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The end date to pull data to.", + SerializedName = @"to", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime To { get; set; } + + } + /// The start and end date for pulling data for the report. + public partial interface IReportConfigTimePeriodInternal + + { + /// The start date to pull data from. + global::System.DateTime From { get; set; } + /// The end date to pull data to. + global::System.DateTime To { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ReportConfigTimePeriod.json.cs b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigTimePeriod.json.cs new file mode 100644 index 000000000000..34660ba5580e --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ReportConfigTimePeriod.json.cs @@ -0,0 +1,103 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The start and end date for pulling data for the report. + public partial class ReportConfigTimePeriod + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigTimePeriod. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigTimePeriod. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigTimePeriod FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new ReportConfigTimePeriod(json) : null; + } + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal ReportConfigTimePeriod(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_from = If( json?.PropertyT("from"), out var __jsonFrom) ? global::System.DateTime.TryParse((string)__jsonFrom, global::System.Globalization.CultureInfo.InvariantCulture, global::System.Globalization.DateTimeStyles.AdjustToUniversal, out var __jsonFromValue) ? __jsonFromValue : From : From;} + {_to = If( json?.PropertyT("to"), out var __jsonTo) ? global::System.DateTime.TryParse((string)__jsonTo, global::System.Globalization.CultureInfo.InvariantCulture, global::System.Globalization.DateTimeStyles.AdjustToUniversal, out var __jsonToValue) ? __jsonToValue : To : To;} + AfterFromJson(json); + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + AddIf( (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._from.ToString(@"yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK",global::System.Globalization.CultureInfo.InvariantCulture)), "from" ,container.Add ); + AddIf( (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._to.ToString(@"yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK",global::System.Globalization.CultureInfo.InvariantCulture)), "to" ,container.Add ); + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/Resource.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/Resource.PowerShell.cs new file mode 100644 index 000000000000..c87e5838bef8 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/Resource.PowerShell.cs @@ -0,0 +1,137 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// The Resource model definition. + [System.ComponentModel.TypeConverter(typeof(ResourceTypeConverter))] + public partial class Resource + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResource DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new Resource(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResource DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new Resource(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResource FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal Resource(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Name, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Type = (string) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Type, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Id = (string) content.GetValueForProperty("Id",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Id, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Tag = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceTags) content.GetValueForProperty("Tag",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Tag, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ResourceTagsTypeConverter.ConvertFrom); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal Resource(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Name, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Type = (string) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Type, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Id = (string) content.GetValueForProperty("Id",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Id, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Tag = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceTags) content.GetValueForProperty("Tag",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal)this).Tag, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ResourceTagsTypeConverter.ConvertFrom); + AfterDeserializePSObject(content); + } + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// The Resource model definition. + [System.ComponentModel.TypeConverter(typeof(ResourceTypeConverter))] + public partial interface IResource + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/Resource.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/Resource.TypeConverter.cs new file mode 100644 index 000000000000..2d4491c19460 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/Resource.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class ResourceTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResource ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResource).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return Resource.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return Resource.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return Resource.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/Resource.cs b/src/CostManagement/generated/api/Models/Api20200601/Resource.cs new file mode 100644 index 000000000000..8aece54acb1d --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/Resource.cs @@ -0,0 +1,109 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The Resource model definition. + public partial class Resource : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResource, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal + { + + /// Backing field for property. + private string _id; + + /// Resource Id. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string Id { get => this._id; } + + /// Internal Acessors for Id + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal.Id { get => this._id; set { {_id = value;} } } + + /// Internal Acessors for Name + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal.Name { get => this._name; set { {_name = value;} } } + + /// Internal Acessors for Tag + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceTags Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal.Tag { get => (this._tag = this._tag ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ResourceTags()); set { {_tag = value;} } } + + /// Internal Acessors for Type + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceInternal.Type { get => this._type; set { {_type = value;} } } + + /// Backing field for property. + private string _name; + + /// Resource name. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string Name { get => this._name; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceTags _tag; + + /// Resource tags. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceTags Tag { get => (this._tag = this._tag ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ResourceTags()); } + + /// Backing field for property. + private string _type; + + /// Resource type. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string Type { get => this._type; } + + /// Creates an new instance. + public Resource() + { + + } + } + /// The Resource model definition. + public partial interface IResource : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// Resource Id. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"Resource Id.", + SerializedName = @"id", + PossibleTypes = new [] { typeof(string) })] + string Id { get; } + /// Resource name. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"Resource name.", + SerializedName = @"name", + PossibleTypes = new [] { typeof(string) })] + string Name { get; } + /// Resource tags. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"Resource tags.", + SerializedName = @"tags", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceTags) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceTags Tag { get; } + /// Resource type. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"Resource type.", + SerializedName = @"type", + PossibleTypes = new [] { typeof(string) })] + string Type { get; } + + } + /// The Resource model definition. + public partial interface IResourceInternal + + { + /// Resource Id. + string Id { get; set; } + /// Resource name. + string Name { get; set; } + /// Resource tags. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceTags Tag { get; set; } + /// Resource type. + string Type { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/Resource.json.cs b/src/CostManagement/generated/api/Models/Api20200601/Resource.json.cs new file mode 100644 index 000000000000..7ecebf0fe7ff --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/Resource.json.cs @@ -0,0 +1,119 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The Resource model definition. + public partial class Resource + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResource. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResource. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResource FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new Resource(json) : null; + } + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal Resource(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_name = If( json?.PropertyT("name"), out var __jsonName) ? (string)__jsonName : (string)Name;} + {_type = If( json?.PropertyT("type"), out var __jsonType) ? (string)__jsonType : (string)Type;} + {_id = If( json?.PropertyT("id"), out var __jsonId) ? (string)__jsonId : (string)Id;} + {_tag = If( json?.PropertyT("tags"), out var __jsonTags) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ResourceTags.FromJson(__jsonTags) : Tag;} + AfterFromJson(json); + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeReadOnly)) + { + AddIf( null != (((object)this._name)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._name.ToString()) : null, "name" ,container.Add ); + } + if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeReadOnly)) + { + AddIf( null != (((object)this._type)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._type.ToString()) : null, "type" ,container.Add ); + } + if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeReadOnly)) + { + AddIf( null != (((object)this._id)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._id.ToString()) : null, "id" ,container.Add ); + } + if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeReadOnly)) + { + AddIf( null != this._tag ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._tag.ToJson(null,serializationMode) : null, "tags" ,container.Add ); + } + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ResourceTags.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/ResourceTags.PowerShell.cs new file mode 100644 index 000000000000..ab967e8a9c8a --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ResourceTags.PowerShell.cs @@ -0,0 +1,133 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// Resource tags. + [System.ComponentModel.TypeConverter(typeof(ResourceTagsTypeConverter))] + public partial class ResourceTags + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceTags DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new ResourceTags(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceTags DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new ResourceTags(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceTags FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal ResourceTags(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + // this type is a dictionary; copy elements from source to here. + CopyFrom(content); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal ResourceTags(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + // this type is a dictionary; copy elements from source to here. + CopyFrom(content); + AfterDeserializePSObject(content); + } + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + /// Resource tags. + [System.ComponentModel.TypeConverter(typeof(ResourceTagsTypeConverter))] + public partial interface IResourceTags + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ResourceTags.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/ResourceTags.TypeConverter.cs new file mode 100644 index 000000000000..8bca98af1333 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ResourceTags.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class ResourceTagsTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceTags ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceTags).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return ResourceTags.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return ResourceTags.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return ResourceTags.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ResourceTags.cs b/src/CostManagement/generated/api/Models/Api20200601/ResourceTags.cs new file mode 100644 index 000000000000..c9f67011c2da --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ResourceTags.cs @@ -0,0 +1,30 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// Resource tags. + public partial class ResourceTags : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceTags, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceTagsInternal + { + + /// Creates an new instance. + public ResourceTags() + { + + } + } + /// Resource tags. + public partial interface IResourceTags : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IAssociativeArray + { + + } + /// Resource tags. + public partial interface IResourceTagsInternal + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ResourceTags.dictionary.cs b/src/CostManagement/generated/api/Models/Api20200601/ResourceTags.dictionary.cs new file mode 100644 index 000000000000..bba3d8b22156 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ResourceTags.dictionary.cs @@ -0,0 +1,70 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + public partial class ResourceTags : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IAssociativeArray + { + protected global::System.Collections.Generic.Dictionary __additionalProperties = new global::System.Collections.Generic.Dictionary(); + + global::System.Collections.Generic.IDictionary Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IAssociativeArray.AdditionalProperties { get => __additionalProperties; } + + int Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IAssociativeArray.Count { get => __additionalProperties.Count; } + + global::System.Collections.Generic.IEnumerable Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IAssociativeArray.Keys { get => __additionalProperties.Keys; } + + global::System.Collections.Generic.IEnumerable Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IAssociativeArray.Values { get => __additionalProperties.Values; } + + public string this[global::System.String index] { get => __additionalProperties[index]; set => __additionalProperties[index] = value; } + + /// + /// + public void Add(global::System.String key, string value) => __additionalProperties.Add( key, value); + + public void Clear() => __additionalProperties.Clear(); + + /// + public bool ContainsKey(global::System.String key) => __additionalProperties.ContainsKey( key); + + /// + public void CopyFrom(global::System.Collections.IDictionary source) + { + if (null != source) + { + foreach( var property in Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.TypeConverterExtensions.GetFilteredProperties(source, new global::System.Collections.Generic.HashSet() { } ) ) + { + if ((null != property.Key && null != property.Value)) + { + this.__additionalProperties.Add(property.Key.ToString(), global::System.Management.Automation.LanguagePrimitives.ConvertTo( property.Value)); + } + } + } + } + + /// + public void CopyFrom(global::System.Management.Automation.PSObject source) + { + if (null != source) + { + foreach( var property in Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.TypeConverterExtensions.GetFilteredProperties(source, new global::System.Collections.Generic.HashSet() { } ) ) + { + if ((null != property.Key && null != property.Value)) + { + this.__additionalProperties.Add(property.Key.ToString(), global::System.Management.Automation.LanguagePrimitives.ConvertTo( property.Value)); + } + } + } + } + + /// + public bool Remove(global::System.String key) => __additionalProperties.Remove( key); + + /// + /// + public bool TryGetValue(global::System.String key, out string value) => __additionalProperties.TryGetValue( key, out value); + + /// + + public static implicit operator global::System.Collections.Generic.Dictionary(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ResourceTags source) => source.__additionalProperties; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ResourceTags.json.cs b/src/CostManagement/generated/api/Models/Api20200601/ResourceTags.json.cs new file mode 100644 index 000000000000..601d87e0a6c4 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ResourceTags.json.cs @@ -0,0 +1,102 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// Resource tags. + public partial class ResourceTags + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceTags. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceTags. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IResourceTags FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new ResourceTags(json) : null; + } + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + /// + internal ResourceTags(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, global::System.Collections.Generic.HashSet exclusions = null) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.JsonSerializable.FromJson( json, ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IAssociativeArray)this).AdditionalProperties, null ,exclusions ); + AfterFromJson(json); + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.JsonSerializable.ToJson( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IAssociativeArray)this).AdditionalProperties, container); + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/View.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/View.PowerShell.cs new file mode 100644 index 000000000000..cba31ffbbe60 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/View.PowerShell.cs @@ -0,0 +1,185 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// States and configurations of Cost Analysis. + [System.ComponentModel.TypeConverter(typeof(ViewTypeConverter))] + public partial class View + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IView DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new View(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IView DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new View(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IView FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal View(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).Property = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewProperties) content.GetValueForProperty("Property",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).Property, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ViewPropertiesTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)this).Name, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)this).Type = (string) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)this).Type, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)this).ETag = (string) content.GetValueForProperty("ETag",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)this).ETag, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)this).Id = (string) content.GetValueForProperty("Id",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)this).Id, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).Query = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition) content.GetValueForProperty("Query",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).Query, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDefinitionTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).Chart = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ChartType?) content.GetValueForProperty("Chart",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).Chart, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ChartType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).CreatedOn = (global::System.DateTime?) content.GetValueForProperty("CreatedOn",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).CreatedOn, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).DisplayName = (string) content.GetValueForProperty("DisplayName",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).DisplayName, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).Kpi = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IKpiProperties[]) content.GetValueForProperty("Kpi",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).Kpi, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.KpiPropertiesTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).Metric = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.MetricType?) content.GetValueForProperty("Metric",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).Metric, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.MetricType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).ModifiedOn = (global::System.DateTime?) content.GetValueForProperty("ModifiedOn",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).ModifiedOn, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).Pivot = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IPivotProperties[]) content.GetValueForProperty("Pivot",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).Pivot, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.PivotPropertiesTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).Scope = (string) content.GetValueForProperty("Scope",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).Scope, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).Accumulated = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AccumulatedType?) content.GetValueForProperty("Accumulated",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).Accumulated, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AccumulatedType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).QueryDataset = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1) content.GetValueForProperty("QueryDataset",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).QueryDataset, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDataset1TypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).QueryType = (string) content.GetValueForProperty("QueryType",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).QueryType, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).QueryTimeframe = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportTimeframeType) content.GetValueForProperty("QueryTimeframe",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).QueryTimeframe, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportTimeframeType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).QueryTimePeriod = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigTimePeriod) content.GetValueForProperty("QueryTimePeriod",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).QueryTimePeriod, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigTimePeriodTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).DatasetConfiguration = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetConfiguration) content.GetValueForProperty("DatasetConfiguration",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).DatasetConfiguration, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDatasetConfigurationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).DatasetAggregation = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetAggregation) content.GetValueForProperty("DatasetAggregation",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).DatasetAggregation, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDatasetAggregationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).DatasetFilter = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1) content.GetValueForProperty("DatasetFilter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).DatasetFilter, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigFilter1TypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).DatasetGranularity = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType?) content.GetValueForProperty("DatasetGranularity",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).DatasetGranularity, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).DatasetGrouping = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGrouping[]) content.GetValueForProperty("DatasetGrouping",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).DatasetGrouping, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigGroupingTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).DatasetSorting = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSorting[]) content.GetValueForProperty("DatasetSorting",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).DatasetSorting, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigSortingTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).TimePeriodFrom = (global::System.DateTime) content.GetValueForProperty("TimePeriodFrom",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).TimePeriodFrom, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).TimePeriodTo = (global::System.DateTime) content.GetValueForProperty("TimePeriodTo",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).TimePeriodTo, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).ConfigurationColumn = (string[]) content.GetValueForProperty("ConfigurationColumn",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).ConfigurationColumn, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal View(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).Property = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewProperties) content.GetValueForProperty("Property",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).Property, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ViewPropertiesTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)this).Name, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)this).Type = (string) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)this).Type, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)this).ETag = (string) content.GetValueForProperty("ETag",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)this).ETag, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)this).Id = (string) content.GetValueForProperty("Id",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)this).Id, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).Query = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition) content.GetValueForProperty("Query",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).Query, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDefinitionTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).Chart = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ChartType?) content.GetValueForProperty("Chart",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).Chart, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ChartType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).CreatedOn = (global::System.DateTime?) content.GetValueForProperty("CreatedOn",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).CreatedOn, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).DisplayName = (string) content.GetValueForProperty("DisplayName",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).DisplayName, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).Kpi = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IKpiProperties[]) content.GetValueForProperty("Kpi",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).Kpi, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.KpiPropertiesTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).Metric = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.MetricType?) content.GetValueForProperty("Metric",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).Metric, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.MetricType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).ModifiedOn = (global::System.DateTime?) content.GetValueForProperty("ModifiedOn",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).ModifiedOn, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).Pivot = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IPivotProperties[]) content.GetValueForProperty("Pivot",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).Pivot, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.PivotPropertiesTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).Scope = (string) content.GetValueForProperty("Scope",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).Scope, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).Accumulated = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AccumulatedType?) content.GetValueForProperty("Accumulated",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).Accumulated, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AccumulatedType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).QueryDataset = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1) content.GetValueForProperty("QueryDataset",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).QueryDataset, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDataset1TypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).QueryType = (string) content.GetValueForProperty("QueryType",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).QueryType, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).QueryTimeframe = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportTimeframeType) content.GetValueForProperty("QueryTimeframe",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).QueryTimeframe, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportTimeframeType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).QueryTimePeriod = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigTimePeriod) content.GetValueForProperty("QueryTimePeriod",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).QueryTimePeriod, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigTimePeriodTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).DatasetConfiguration = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetConfiguration) content.GetValueForProperty("DatasetConfiguration",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).DatasetConfiguration, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDatasetConfigurationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).DatasetAggregation = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetAggregation) content.GetValueForProperty("DatasetAggregation",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).DatasetAggregation, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDatasetAggregationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).DatasetFilter = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1) content.GetValueForProperty("DatasetFilter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).DatasetFilter, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigFilter1TypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).DatasetGranularity = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType?) content.GetValueForProperty("DatasetGranularity",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).DatasetGranularity, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).DatasetGrouping = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGrouping[]) content.GetValueForProperty("DatasetGrouping",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).DatasetGrouping, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigGroupingTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).DatasetSorting = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSorting[]) content.GetValueForProperty("DatasetSorting",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).DatasetSorting, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigSortingTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).TimePeriodFrom = (global::System.DateTime) content.GetValueForProperty("TimePeriodFrom",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).TimePeriodFrom, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).TimePeriodTo = (global::System.DateTime) content.GetValueForProperty("TimePeriodTo",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).TimePeriodTo, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).ConfigurationColumn = (string[]) content.GetValueForProperty("ConfigurationColumn",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal)this).ConfigurationColumn, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + AfterDeserializePSObject(content); + } + } + /// States and configurations of Cost Analysis. + [System.ComponentModel.TypeConverter(typeof(ViewTypeConverter))] + public partial interface IView + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/View.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/View.TypeConverter.cs new file mode 100644 index 000000000000..c26fba9624e7 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/View.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class ViewTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IView ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IView).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return View.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return View.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return View.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/View.cs b/src/CostManagement/generated/api/Models/Api20200601/View.cs new file mode 100644 index 000000000000..1fd553abed07 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/View.cs @@ -0,0 +1,455 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// States and configurations of Cost Analysis. + public partial class View : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IView, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IValidates + { + /// + /// Backing field for Inherited model + /// + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResource __proxyResource = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ProxyResource(); + + /// Show costs accumulated over time. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AccumulatedType? Accumulated { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)Property).Accumulated; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)Property).Accumulated = value; } + + /// Chart type of the main view in Cost Analysis. Required. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ChartType? Chart { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)Property).Chart; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)Property).Chart = value; } + + /// + /// Array of column names to be included in the report. Any valid report column name is allowed. If not provided, then report + /// includes all columns. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string[] ConfigurationColumn { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)Property).ConfigurationColumn; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)Property).ConfigurationColumn = value; } + + /// Date the user created this view. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public global::System.DateTime? CreatedOn { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)Property).CreatedOn; } + + /// + /// Dictionary of aggregation expression to use in the report. The key of each item in the dictionary is the alias for the + /// aggregated column. Report can have up to 2 aggregation clauses. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetAggregation DatasetAggregation { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)Property).DatasetAggregation; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)Property).DatasetAggregation = value; } + + /// Has filter expression to use in the report. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1 DatasetFilter { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)Property).DatasetFilter; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)Property).DatasetFilter = value; } + + /// The granularity of rows in the report. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType? DatasetGranularity { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)Property).DatasetGranularity; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)Property).DatasetGranularity = value; } + + /// + /// Array of group by expression to use in the report. Report can have up to 2 group by clauses. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGrouping[] DatasetGrouping { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)Property).DatasetGrouping; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)Property).DatasetGrouping = value; } + + /// Array of order by expression to use in the report. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSorting[] DatasetSorting { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)Property).DatasetSorting; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)Property).DatasetSorting = value; } + + /// User input name of the view. Required. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string DisplayName { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)Property).DisplayName; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)Property).DisplayName = value; } + + /// + /// eTag of the resource. To handle concurrent update scenario, this field will be used to determine whether the user is updating + /// the latest version or not. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inherited)] + public string ETag { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)__proxyResource).ETag; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)__proxyResource).ETag = value; } + + /// Resource Id. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inherited)] + public string Id { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)__proxyResource).Id; } + + /// List of KPIs to show in Cost Analysis UI. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IKpiProperties[] Kpi { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)Property).Kpi; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)Property).Kpi = value; } + + /// Metric to use when displaying costs. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.MetricType? Metric { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)Property).Metric; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)Property).Metric = value; } + + /// Internal Acessors for Id + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal.Id { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)__proxyResource).Id; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)__proxyResource).Id = value; } + + /// Internal Acessors for Name + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal.Name { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)__proxyResource).Name; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)__proxyResource).Name = value; } + + /// Internal Acessors for Type + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal.Type { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)__proxyResource).Type; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)__proxyResource).Type = value; } + + /// Internal Acessors for CreatedOn + global::System.DateTime? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal.CreatedOn { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)Property).CreatedOn; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)Property).CreatedOn = value; } + + /// Internal Acessors for DatasetConfiguration + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetConfiguration Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal.DatasetConfiguration { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)Property).DatasetConfiguration; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)Property).DatasetConfiguration = value; } + + /// Internal Acessors for ModifiedOn + global::System.DateTime? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal.ModifiedOn { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)Property).ModifiedOn; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)Property).ModifiedOn = value; } + + /// Internal Acessors for Property + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewProperties Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal.Property { get => (this._property = this._property ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ViewProperties()); set { {_property = value;} } } + + /// Internal Acessors for Query + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal.Query { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)Property).Query; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)Property).Query = value; } + + /// Internal Acessors for QueryDataset + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1 Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal.QueryDataset { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)Property).QueryDataset; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)Property).QueryDataset = value; } + + /// Internal Acessors for QueryTimePeriod + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigTimePeriod Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal.QueryTimePeriod { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)Property).QueryTimePeriod; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)Property).QueryTimePeriod = value; } + + /// Internal Acessors for QueryType + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewInternal.QueryType { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)Property).QueryType; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)Property).QueryType = value; } + + /// Date when the user last modified this view. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public global::System.DateTime? ModifiedOn { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)Property).ModifiedOn; } + + /// Resource name. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inherited)] + public string Name { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)__proxyResource).Name; } + + /// Configuration of 3 sub-views in the Cost Analysis UI. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IPivotProperties[] Pivot { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)Property).Pivot; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)Property).Pivot = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewProperties _property; + + /// View properties + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + internal Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewProperties Property { get => (this._property = this._property ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ViewProperties()); set => this._property = value; } + + /// + /// The time frame for pulling data for the report. If custom, then a specific time period must be provided. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportTimeframeType QueryTimeframe { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)Property).QueryTimeframe; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)Property).QueryTimeframe = value; } + + /// + /// The type of the report. Usage represents actual usage, forecast represents forecasted data and UsageAndForecast represents + /// both usage and forecasted data. Actual usage and forecasted data can be differentiated based on dates. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string QueryType { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)Property).QueryType; } + + /// + /// Cost Management scope to save the view on. This includes 'subscriptions/{subscriptionId}' for subscription scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' + /// for resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope, + /// '/providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for ExternalBillingAccount + /// scope, and '/providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for ExternalSubscription + /// scope. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string Scope { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)Property).Scope; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)Property).Scope = value; } + + /// The start date to pull data from. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public global::System.DateTime TimePeriodFrom { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)Property).TimePeriodFrom; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)Property).TimePeriodFrom = value; } + + /// The end date to pull data to. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public global::System.DateTime TimePeriodTo { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)Property).TimePeriodTo; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)Property).TimePeriodTo = value; } + + /// Resource type. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inherited)] + public string Type { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal)__proxyResource).Type; } + + /// Validates that this object meets the validation criteria. + /// an instance that will receive validation + /// events. + /// + /// A < see cref = "global::System.Threading.Tasks.Task" /> that will be complete when validation is completed. + /// + public async global::System.Threading.Tasks.Task Validate(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener eventListener) + { + await eventListener.AssertNotNull(nameof(__proxyResource), __proxyResource); + await eventListener.AssertObjectIsValid(nameof(__proxyResource), __proxyResource); + } + + /// Creates an new instance. + public View() + { + + } + } + /// States and configurations of Cost Analysis. + public partial interface IView : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResource + { + /// Show costs accumulated over time. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Show costs accumulated over time.", + SerializedName = @"accumulated", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AccumulatedType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AccumulatedType? Accumulated { get; set; } + /// Chart type of the main view in Cost Analysis. Required. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Chart type of the main view in Cost Analysis. Required.", + SerializedName = @"chart", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ChartType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ChartType? Chart { get; set; } + /// + /// Array of column names to be included in the report. Any valid report column name is allowed. If not provided, then report + /// includes all columns. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Array of column names to be included in the report. Any valid report column name is allowed. If not provided, then report includes all columns.", + SerializedName = @"columns", + PossibleTypes = new [] { typeof(string) })] + string[] ConfigurationColumn { get; set; } + /// Date the user created this view. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"Date the user created this view.", + SerializedName = @"createdOn", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime? CreatedOn { get; } + /// + /// Dictionary of aggregation expression to use in the report. The key of each item in the dictionary is the alias for the + /// aggregated column. Report can have up to 2 aggregation clauses. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Dictionary of aggregation expression to use in the report. The key of each item in the dictionary is the alias for the aggregated column. Report can have up to 2 aggregation clauses.", + SerializedName = @"aggregation", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetAggregation) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetAggregation DatasetAggregation { get; set; } + /// Has filter expression to use in the report. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Has filter expression to use in the report.", + SerializedName = @"filter", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1 DatasetFilter { get; set; } + /// The granularity of rows in the report. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The granularity of rows in the report.", + SerializedName = @"granularity", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType? DatasetGranularity { get; set; } + /// + /// Array of group by expression to use in the report. Report can have up to 2 group by clauses. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Array of group by expression to use in the report. Report can have up to 2 group by clauses.", + SerializedName = @"grouping", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGrouping) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGrouping[] DatasetGrouping { get; set; } + /// Array of order by expression to use in the report. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Array of order by expression to use in the report.", + SerializedName = @"sorting", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSorting) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSorting[] DatasetSorting { get; set; } + /// User input name of the view. Required. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"User input name of the view. Required.", + SerializedName = @"displayName", + PossibleTypes = new [] { typeof(string) })] + string DisplayName { get; set; } + /// List of KPIs to show in Cost Analysis UI. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"List of KPIs to show in Cost Analysis UI.", + SerializedName = @"kpis", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IKpiProperties) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IKpiProperties[] Kpi { get; set; } + /// Metric to use when displaying costs. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Metric to use when displaying costs.", + SerializedName = @"metric", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.MetricType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.MetricType? Metric { get; set; } + /// Date when the user last modified this view. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"Date when the user last modified this view.", + SerializedName = @"modifiedOn", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime? ModifiedOn { get; } + /// Configuration of 3 sub-views in the Cost Analysis UI. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Configuration of 3 sub-views in the Cost Analysis UI.", + SerializedName = @"pivots", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IPivotProperties) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IPivotProperties[] Pivot { get; set; } + /// + /// The time frame for pulling data for the report. If custom, then a specific time period must be provided. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The time frame for pulling data for the report. If custom, then a specific time period must be provided.", + SerializedName = @"timeframe", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportTimeframeType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportTimeframeType QueryTimeframe { get; set; } + /// + /// The type of the report. Usage represents actual usage, forecast represents forecasted data and UsageAndForecast represents + /// both usage and forecasted data. Actual usage and forecasted data can be differentiated based on dates. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = true, + Description = @"The type of the report. Usage represents actual usage, forecast represents forecasted data and UsageAndForecast represents both usage and forecasted data. Actual usage and forecasted data can be differentiated based on dates.", + SerializedName = @"type", + PossibleTypes = new [] { typeof(string) })] + string QueryType { get; } + /// + /// Cost Management scope to save the view on. This includes 'subscriptions/{subscriptionId}' for subscription scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' + /// for resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope, + /// '/providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for ExternalBillingAccount + /// scope, and '/providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for ExternalSubscription + /// scope. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Cost Management scope to save the view on. This includes 'subscriptions/{subscriptionId}' for subscription scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for BillingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' for InvoiceSection scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope, '/providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for ExternalBillingAccount scope, and '/providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for ExternalSubscription scope.", + SerializedName = @"scope", + PossibleTypes = new [] { typeof(string) })] + string Scope { get; set; } + /// The start date to pull data from. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The start date to pull data from.", + SerializedName = @"from", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime TimePeriodFrom { get; set; } + /// The end date to pull data to. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The end date to pull data to.", + SerializedName = @"to", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime TimePeriodTo { get; set; } + + } + /// States and configurations of Cost Analysis. + public partial interface IViewInternal : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IProxyResourceInternal + { + /// Show costs accumulated over time. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AccumulatedType? Accumulated { get; set; } + /// Chart type of the main view in Cost Analysis. Required. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ChartType? Chart { get; set; } + /// + /// Array of column names to be included in the report. Any valid report column name is allowed. If not provided, then report + /// includes all columns. + /// + string[] ConfigurationColumn { get; set; } + /// Date the user created this view. + global::System.DateTime? CreatedOn { get; set; } + /// + /// Dictionary of aggregation expression to use in the report. The key of each item in the dictionary is the alias for the + /// aggregated column. Report can have up to 2 aggregation clauses. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetAggregation DatasetAggregation { get; set; } + /// + /// Has configuration information for the data in the report. The configuration will be ignored if aggregation and grouping + /// are provided. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetConfiguration DatasetConfiguration { get; set; } + /// Has filter expression to use in the report. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1 DatasetFilter { get; set; } + /// The granularity of rows in the report. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType? DatasetGranularity { get; set; } + /// + /// Array of group by expression to use in the report. Report can have up to 2 group by clauses. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGrouping[] DatasetGrouping { get; set; } + /// Array of order by expression to use in the report. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSorting[] DatasetSorting { get; set; } + /// User input name of the view. Required. + string DisplayName { get; set; } + /// List of KPIs to show in Cost Analysis UI. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IKpiProperties[] Kpi { get; set; } + /// Metric to use when displaying costs. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.MetricType? Metric { get; set; } + /// Date when the user last modified this view. + global::System.DateTime? ModifiedOn { get; set; } + /// Configuration of 3 sub-views in the Cost Analysis UI. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IPivotProperties[] Pivot { get; set; } + /// View properties + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewProperties Property { get; set; } + /// Query body configuration. Required. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition Query { get; set; } + /// Has definition for data in this report config. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1 QueryDataset { get; set; } + /// Has time period for pulling data for the report. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigTimePeriod QueryTimePeriod { get; set; } + /// + /// The time frame for pulling data for the report. If custom, then a specific time period must be provided. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportTimeframeType QueryTimeframe { get; set; } + /// + /// The type of the report. Usage represents actual usage, forecast represents forecasted data and UsageAndForecast represents + /// both usage and forecasted data. Actual usage and forecasted data can be differentiated based on dates. + /// + string QueryType { get; set; } + /// + /// Cost Management scope to save the view on. This includes 'subscriptions/{subscriptionId}' for subscription scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' + /// for resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope, + /// '/providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for ExternalBillingAccount + /// scope, and '/providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for ExternalSubscription + /// scope. + /// + string Scope { get; set; } + /// The start date to pull data from. + global::System.DateTime TimePeriodFrom { get; set; } + /// The end date to pull data to. + global::System.DateTime TimePeriodTo { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/View.json.cs b/src/CostManagement/generated/api/Models/Api20200601/View.json.cs new file mode 100644 index 000000000000..a41c8410d8db --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/View.json.cs @@ -0,0 +1,103 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// States and configurations of Cost Analysis. + public partial class View + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IView. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IView. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IView FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new View(json) : null; + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + __proxyResource?.ToJson(container, serializationMode); + AddIf( null != this._property ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._property.ToJson(null,serializationMode) : null, "properties" ,container.Add ); + AfterToJson(ref container); + return container; + } + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal View(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + __proxyResource = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ProxyResource(json); + {_property = If( json?.PropertyT("properties"), out var __jsonProperties) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ViewProperties.FromJson(__jsonProperties) : Property;} + AfterFromJson(json); + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ViewListResult.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/ViewListResult.PowerShell.cs new file mode 100644 index 000000000000..d3d1d4f9ae8f --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ViewListResult.PowerShell.cs @@ -0,0 +1,133 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// Result of listing views. It contains a list of available views. + [System.ComponentModel.TypeConverter(typeof(ViewListResultTypeConverter))] + public partial class ViewListResult + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewListResult DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new ViewListResult(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewListResult DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new ViewListResult(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewListResult FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal ViewListResult(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewListResultInternal)this).NextLink = (string) content.GetValueForProperty("NextLink",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewListResultInternal)this).NextLink, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewListResultInternal)this).Value = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IView[]) content.GetValueForProperty("Value",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewListResultInternal)this).Value, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ViewTypeConverter.ConvertFrom)); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal ViewListResult(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewListResultInternal)this).NextLink = (string) content.GetValueForProperty("NextLink",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewListResultInternal)this).NextLink, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewListResultInternal)this).Value = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IView[]) content.GetValueForProperty("Value",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewListResultInternal)this).Value, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ViewTypeConverter.ConvertFrom)); + AfterDeserializePSObject(content); + } + } + /// Result of listing views. It contains a list of available views. + [System.ComponentModel.TypeConverter(typeof(ViewListResultTypeConverter))] + public partial interface IViewListResult + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ViewListResult.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/ViewListResult.TypeConverter.cs new file mode 100644 index 000000000000..39de9efe306f --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ViewListResult.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class ViewListResultTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewListResult ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewListResult).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return ViewListResult.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return ViewListResult.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return ViewListResult.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ViewListResult.cs b/src/CostManagement/generated/api/Models/Api20200601/ViewListResult.cs new file mode 100644 index 000000000000..5040beecc28a --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ViewListResult.cs @@ -0,0 +1,69 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// Result of listing views. It contains a list of available views. + public partial class ViewListResult : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewListResult, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewListResultInternal + { + + /// Internal Acessors for NextLink + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewListResultInternal.NextLink { get => this._nextLink; set { {_nextLink = value;} } } + + /// Internal Acessors for Value + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IView[] Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewListResultInternal.Value { get => this._value; set { {_value = value;} } } + + /// Backing field for property. + private string _nextLink; + + /// The link (url) to the next page of results. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string NextLink { get => this._nextLink; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IView[] _value; + + /// The list of views. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IView[] Value { get => this._value; } + + /// Creates an new instance. + public ViewListResult() + { + + } + } + /// Result of listing views. It contains a list of available views. + public partial interface IViewListResult : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// The link (url) to the next page of results. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"The link (url) to the next page of results.", + SerializedName = @"nextLink", + PossibleTypes = new [] { typeof(string) })] + string NextLink { get; } + /// The list of views. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"The list of views.", + SerializedName = @"value", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IView) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IView[] Value { get; } + + } + /// Result of listing views. It contains a list of available views. + public partial interface IViewListResultInternal + + { + /// The link (url) to the next page of results. + string NextLink { get; set; } + /// The list of views. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IView[] Value { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ViewListResult.json.cs b/src/CostManagement/generated/api/Models/Api20200601/ViewListResult.json.cs new file mode 100644 index 000000000000..5a434f8e2906 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ViewListResult.json.cs @@ -0,0 +1,117 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// Result of listing views. It contains a list of available views. + public partial class ViewListResult + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewListResult. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewListResult. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewListResult FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new ViewListResult(json) : null; + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeReadOnly)) + { + AddIf( null != (((object)this._nextLink)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._nextLink.ToString()) : null, "nextLink" ,container.Add ); + } + if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeReadOnly)) + { + if (null != this._value) + { + var __w = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.XNodeArray(); + foreach( var __x in this._value ) + { + AddIf(__x?.ToJson(null, serializationMode) ,__w.Add); + } + container.Add("value",__w); + } + } + AfterToJson(ref container); + return container; + } + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal ViewListResult(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_nextLink = If( json?.PropertyT("nextLink"), out var __jsonNextLink) ? (string)__jsonNextLink : (string)NextLink;} + {_value = If( json?.PropertyT("value"), out var __jsonValue) ? If( __jsonValue as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonArray, out var __v) ? new global::System.Func(()=> global::System.Linq.Enumerable.ToArray(global::System.Linq.Enumerable.Select(__v, (__u)=>(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IView) (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.View.FromJson(__u) )) ))() : null : Value;} + AfterFromJson(json); + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ViewProperties.PowerShell.cs b/src/CostManagement/generated/api/Models/Api20200601/ViewProperties.PowerShell.cs new file mode 100644 index 000000000000..daaa3adae029 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ViewProperties.PowerShell.cs @@ -0,0 +1,175 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// The properties of the view. + [System.ComponentModel.TypeConverter(typeof(ViewPropertiesTypeConverter))] + public partial class ViewProperties + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewProperties DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new ViewProperties(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewProperties DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new ViewProperties(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewProperties FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal ViewProperties(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).Query = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition) content.GetValueForProperty("Query",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).Query, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDefinitionTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).Accumulated = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AccumulatedType?) content.GetValueForProperty("Accumulated",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).Accumulated, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AccumulatedType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).Chart = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ChartType?) content.GetValueForProperty("Chart",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).Chart, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ChartType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).CreatedOn = (global::System.DateTime?) content.GetValueForProperty("CreatedOn",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).CreatedOn, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).DisplayName = (string) content.GetValueForProperty("DisplayName",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).DisplayName, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).Kpi = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IKpiProperties[]) content.GetValueForProperty("Kpi",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).Kpi, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.KpiPropertiesTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).Metric = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.MetricType?) content.GetValueForProperty("Metric",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).Metric, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.MetricType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).ModifiedOn = (global::System.DateTime?) content.GetValueForProperty("ModifiedOn",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).ModifiedOn, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).Pivot = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IPivotProperties[]) content.GetValueForProperty("Pivot",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).Pivot, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.PivotPropertiesTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).Scope = (string) content.GetValueForProperty("Scope",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).Scope, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).QueryDataset = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1) content.GetValueForProperty("QueryDataset",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).QueryDataset, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDataset1TypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).QueryType = (string) content.GetValueForProperty("QueryType",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).QueryType, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).QueryTimeframe = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportTimeframeType) content.GetValueForProperty("QueryTimeframe",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).QueryTimeframe, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportTimeframeType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).QueryTimePeriod = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigTimePeriod) content.GetValueForProperty("QueryTimePeriod",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).QueryTimePeriod, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigTimePeriodTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).DatasetConfiguration = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetConfiguration) content.GetValueForProperty("DatasetConfiguration",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).DatasetConfiguration, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDatasetConfigurationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).DatasetAggregation = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetAggregation) content.GetValueForProperty("DatasetAggregation",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).DatasetAggregation, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDatasetAggregationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).DatasetFilter = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1) content.GetValueForProperty("DatasetFilter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).DatasetFilter, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigFilter1TypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).DatasetGranularity = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType?) content.GetValueForProperty("DatasetGranularity",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).DatasetGranularity, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).DatasetGrouping = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGrouping[]) content.GetValueForProperty("DatasetGrouping",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).DatasetGrouping, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigGroupingTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).DatasetSorting = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSorting[]) content.GetValueForProperty("DatasetSorting",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).DatasetSorting, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigSortingTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).TimePeriodFrom = (global::System.DateTime) content.GetValueForProperty("TimePeriodFrom",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).TimePeriodFrom, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).TimePeriodTo = (global::System.DateTime) content.GetValueForProperty("TimePeriodTo",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).TimePeriodTo, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).ConfigurationColumn = (string[]) content.GetValueForProperty("ConfigurationColumn",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).ConfigurationColumn, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal ViewProperties(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).Query = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition) content.GetValueForProperty("Query",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).Query, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDefinitionTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).Accumulated = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AccumulatedType?) content.GetValueForProperty("Accumulated",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).Accumulated, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AccumulatedType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).Chart = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ChartType?) content.GetValueForProperty("Chart",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).Chart, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ChartType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).CreatedOn = (global::System.DateTime?) content.GetValueForProperty("CreatedOn",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).CreatedOn, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).DisplayName = (string) content.GetValueForProperty("DisplayName",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).DisplayName, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).Kpi = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IKpiProperties[]) content.GetValueForProperty("Kpi",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).Kpi, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.KpiPropertiesTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).Metric = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.MetricType?) content.GetValueForProperty("Metric",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).Metric, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.MetricType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).ModifiedOn = (global::System.DateTime?) content.GetValueForProperty("ModifiedOn",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).ModifiedOn, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).Pivot = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IPivotProperties[]) content.GetValueForProperty("Pivot",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).Pivot, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.PivotPropertiesTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).Scope = (string) content.GetValueForProperty("Scope",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).Scope, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).QueryDataset = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1) content.GetValueForProperty("QueryDataset",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).QueryDataset, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDataset1TypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).QueryType = (string) content.GetValueForProperty("QueryType",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).QueryType, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).QueryTimeframe = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportTimeframeType) content.GetValueForProperty("QueryTimeframe",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).QueryTimeframe, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportTimeframeType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).QueryTimePeriod = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigTimePeriod) content.GetValueForProperty("QueryTimePeriod",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).QueryTimePeriod, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigTimePeriodTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).DatasetConfiguration = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetConfiguration) content.GetValueForProperty("DatasetConfiguration",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).DatasetConfiguration, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDatasetConfigurationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).DatasetAggregation = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetAggregation) content.GetValueForProperty("DatasetAggregation",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).DatasetAggregation, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDatasetAggregationTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).DatasetFilter = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1) content.GetValueForProperty("DatasetFilter",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).DatasetFilter, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigFilter1TypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).DatasetGranularity = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType?) content.GetValueForProperty("DatasetGranularity",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).DatasetGranularity, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).DatasetGrouping = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGrouping[]) content.GetValueForProperty("DatasetGrouping",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).DatasetGrouping, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigGroupingTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).DatasetSorting = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSorting[]) content.GetValueForProperty("DatasetSorting",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).DatasetSorting, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigSortingTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).TimePeriodFrom = (global::System.DateTime) content.GetValueForProperty("TimePeriodFrom",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).TimePeriodFrom, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).TimePeriodTo = (global::System.DateTime) content.GetValueForProperty("TimePeriodTo",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).TimePeriodTo, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified)); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).ConfigurationColumn = (string[]) content.GetValueForProperty("ConfigurationColumn",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal)this).ConfigurationColumn, __y => TypeConverterExtensions.SelectToArray(__y, global::System.Convert.ToString)); + AfterDeserializePSObject(content); + } + } + /// The properties of the view. + [System.ComponentModel.TypeConverter(typeof(ViewPropertiesTypeConverter))] + public partial interface IViewProperties + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ViewProperties.TypeConverter.cs b/src/CostManagement/generated/api/Models/Api20200601/ViewProperties.TypeConverter.cs new file mode 100644 index 000000000000..1cd2d9172da1 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ViewProperties.TypeConverter.cs @@ -0,0 +1,142 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class ViewPropertiesTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewProperties ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewProperties).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return ViewProperties.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return ViewProperties.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return ViewProperties.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ViewProperties.cs b/src/CostManagement/generated/api/Models/Api20200601/ViewProperties.cs new file mode 100644 index 000000000000..fc1b59a08ec6 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ViewProperties.cs @@ -0,0 +1,430 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The properties of the view. + public partial class ViewProperties : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewProperties, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal + { + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AccumulatedType? _accumulated; + + /// Show costs accumulated over time. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AccumulatedType? Accumulated { get => this._accumulated; set => this._accumulated = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ChartType? _chart; + + /// Chart type of the main view in Cost Analysis. Required. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ChartType? Chart { get => this._chart; set => this._chart = value; } + + /// + /// Array of column names to be included in the report. Any valid report column name is allowed. If not provided, then report + /// includes all columns. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string[] ConfigurationColumn { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)Query).ConfigurationColumn; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)Query).ConfigurationColumn = value; } + + /// Backing field for property. + private global::System.DateTime? _createdOn; + + /// Date the user created this view. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public global::System.DateTime? CreatedOn { get => this._createdOn; } + + /// + /// Dictionary of aggregation expression to use in the report. The key of each item in the dictionary is the alias for the + /// aggregated column. Report can have up to 2 aggregation clauses. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetAggregation DatasetAggregation { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)Query).DatasetAggregation; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)Query).DatasetAggregation = value; } + + /// Has filter expression to use in the report. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1 DatasetFilter { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)Query).DatasetFilter; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)Query).DatasetFilter = value; } + + /// The granularity of rows in the report. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType? DatasetGranularity { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)Query).DatasetGranularity; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)Query).DatasetGranularity = value; } + + /// + /// Array of group by expression to use in the report. Report can have up to 2 group by clauses. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGrouping[] DatasetGrouping { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)Query).DatasetGrouping; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)Query).DatasetGrouping = value; } + + /// Array of order by expression to use in the report. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSorting[] DatasetSorting { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)Query).DatasetSorting; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)Query).DatasetSorting = value; } + + /// Backing field for property. + private string _displayName; + + /// User input name of the view. Required. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string DisplayName { get => this._displayName; set => this._displayName = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IKpiProperties[] _kpi; + + /// List of KPIs to show in Cost Analysis UI. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IKpiProperties[] Kpi { get => this._kpi; set => this._kpi = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.MetricType? _metric; + + /// Metric to use when displaying costs. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.MetricType? Metric { get => this._metric; set => this._metric = value; } + + /// Internal Acessors for CreatedOn + global::System.DateTime? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal.CreatedOn { get => this._createdOn; set { {_createdOn = value;} } } + + /// Internal Acessors for DatasetConfiguration + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetConfiguration Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal.DatasetConfiguration { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)Query).DatasetConfiguration; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)Query).DatasetConfiguration = value; } + + /// Internal Acessors for ModifiedOn + global::System.DateTime? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal.ModifiedOn { get => this._modifiedOn; set { {_modifiedOn = value;} } } + + /// Internal Acessors for Query + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal.Query { get => (this._query = this._query ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDefinition()); set { {_query = value;} } } + + /// Internal Acessors for QueryDataset + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1 Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal.QueryDataset { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)Query).Dataset; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)Query).Dataset = value; } + + /// Internal Acessors for QueryTimePeriod + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigTimePeriod Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal.QueryTimePeriod { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)Query).TimePeriod; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)Query).TimePeriod = value; } + + /// Internal Acessors for QueryType + string Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewPropertiesInternal.QueryType { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)Query).Type; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)Query).Type = value; } + + /// Backing field for property. + private global::System.DateTime? _modifiedOn; + + /// Date when the user last modified this view. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public global::System.DateTime? ModifiedOn { get => this._modifiedOn; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IPivotProperties[] _pivot; + + /// Configuration of 3 sub-views in the Cost Analysis UI. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IPivotProperties[] Pivot { get => this._pivot; set => this._pivot = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition _query; + + /// Query body configuration. Required. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + internal Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition Query { get => (this._query = this._query ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDefinition()); set => this._query = value; } + + /// + /// The time frame for pulling data for the report. If custom, then a specific time period must be provided. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportTimeframeType QueryTimeframe { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)Query).Timeframe; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)Query).Timeframe = value; } + + /// + /// The type of the report. Usage represents actual usage, forecast represents forecasted data and UsageAndForecast represents + /// both usage and forecasted data. Actual usage and forecasted data can be differentiated based on dates. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public string QueryType { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)Query).Type; } + + /// Backing field for property. + private string _scope; + + /// + /// Cost Management scope to save the view on. This includes 'subscriptions/{subscriptionId}' for subscription scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' + /// for resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope, + /// '/providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for ExternalBillingAccount + /// scope, and '/providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for ExternalSubscription + /// scope. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string Scope { get => this._scope; set => this._scope = value; } + + /// The start date to pull data from. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public global::System.DateTime TimePeriodFrom { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)Query).TimePeriodFrom; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)Query).TimePeriodFrom = value; } + + /// The end date to pull data to. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Inlined)] + public global::System.DateTime TimePeriodTo { get => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)Query).TimePeriodTo; set => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinitionInternal)Query).TimePeriodTo = value; } + + /// Creates an new instance. + public ViewProperties() + { + + } + } + /// The properties of the view. + public partial interface IViewProperties : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// Show costs accumulated over time. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Show costs accumulated over time.", + SerializedName = @"accumulated", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AccumulatedType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AccumulatedType? Accumulated { get; set; } + /// Chart type of the main view in Cost Analysis. Required. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Chart type of the main view in Cost Analysis. Required.", + SerializedName = @"chart", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ChartType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ChartType? Chart { get; set; } + /// + /// Array of column names to be included in the report. Any valid report column name is allowed. If not provided, then report + /// includes all columns. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Array of column names to be included in the report. Any valid report column name is allowed. If not provided, then report includes all columns.", + SerializedName = @"columns", + PossibleTypes = new [] { typeof(string) })] + string[] ConfigurationColumn { get; set; } + /// Date the user created this view. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"Date the user created this view.", + SerializedName = @"createdOn", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime? CreatedOn { get; } + /// + /// Dictionary of aggregation expression to use in the report. The key of each item in the dictionary is the alias for the + /// aggregated column. Report can have up to 2 aggregation clauses. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Dictionary of aggregation expression to use in the report. The key of each item in the dictionary is the alias for the aggregated column. Report can have up to 2 aggregation clauses.", + SerializedName = @"aggregation", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetAggregation) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetAggregation DatasetAggregation { get; set; } + /// Has filter expression to use in the report. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Has filter expression to use in the report.", + SerializedName = @"filter", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1 DatasetFilter { get; set; } + /// The granularity of rows in the report. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The granularity of rows in the report.", + SerializedName = @"granularity", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType? DatasetGranularity { get; set; } + /// + /// Array of group by expression to use in the report. Report can have up to 2 group by clauses. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Array of group by expression to use in the report. Report can have up to 2 group by clauses.", + SerializedName = @"grouping", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGrouping) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGrouping[] DatasetGrouping { get; set; } + /// Array of order by expression to use in the report. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Array of order by expression to use in the report.", + SerializedName = @"sorting", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSorting) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSorting[] DatasetSorting { get; set; } + /// User input name of the view. Required. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"User input name of the view. Required.", + SerializedName = @"displayName", + PossibleTypes = new [] { typeof(string) })] + string DisplayName { get; set; } + /// List of KPIs to show in Cost Analysis UI. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"List of KPIs to show in Cost Analysis UI.", + SerializedName = @"kpis", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IKpiProperties) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IKpiProperties[] Kpi { get; set; } + /// Metric to use when displaying costs. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Metric to use when displaying costs.", + SerializedName = @"metric", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.MetricType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.MetricType? Metric { get; set; } + /// Date when the user last modified this view. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = true, + Description = @"Date when the user last modified this view.", + SerializedName = @"modifiedOn", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime? ModifiedOn { get; } + /// Configuration of 3 sub-views in the Cost Analysis UI. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Configuration of 3 sub-views in the Cost Analysis UI.", + SerializedName = @"pivots", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IPivotProperties) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IPivotProperties[] Pivot { get; set; } + /// + /// The time frame for pulling data for the report. If custom, then a specific time period must be provided. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The time frame for pulling data for the report. If custom, then a specific time period must be provided.", + SerializedName = @"timeframe", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportTimeframeType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportTimeframeType QueryTimeframe { get; set; } + /// + /// The type of the report. Usage represents actual usage, forecast represents forecasted data and UsageAndForecast represents + /// both usage and forecasted data. Actual usage and forecasted data can be differentiated based on dates. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = true, + Description = @"The type of the report. Usage represents actual usage, forecast represents forecasted data and UsageAndForecast represents both usage and forecasted data. Actual usage and forecasted data can be differentiated based on dates.", + SerializedName = @"type", + PossibleTypes = new [] { typeof(string) })] + string QueryType { get; } + /// + /// Cost Management scope to save the view on. This includes 'subscriptions/{subscriptionId}' for subscription scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' + /// for resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope, + /// '/providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for ExternalBillingAccount + /// scope, and '/providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for ExternalSubscription + /// scope. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Cost Management scope to save the view on. This includes 'subscriptions/{subscriptionId}' for subscription scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for BillingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' for InvoiceSection scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope, '/providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for ExternalBillingAccount scope, and '/providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for ExternalSubscription scope.", + SerializedName = @"scope", + PossibleTypes = new [] { typeof(string) })] + string Scope { get; set; } + /// The start date to pull data from. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The start date to pull data from.", + SerializedName = @"from", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime TimePeriodFrom { get; set; } + /// The end date to pull data to. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The end date to pull data to.", + SerializedName = @"to", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + global::System.DateTime TimePeriodTo { get; set; } + + } + /// The properties of the view. + public partial interface IViewPropertiesInternal + + { + /// Show costs accumulated over time. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AccumulatedType? Accumulated { get; set; } + /// Chart type of the main view in Cost Analysis. Required. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ChartType? Chart { get; set; } + /// + /// Array of column names to be included in the report. Any valid report column name is allowed. If not provided, then report + /// includes all columns. + /// + string[] ConfigurationColumn { get; set; } + /// Date the user created this view. + global::System.DateTime? CreatedOn { get; set; } + /// + /// Dictionary of aggregation expression to use in the report. The key of each item in the dictionary is the alias for the + /// aggregated column. Report can have up to 2 aggregation clauses. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetAggregation DatasetAggregation { get; set; } + /// + /// Has configuration information for the data in the report. The configuration will be ignored if aggregation and grouping + /// are provided. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDatasetConfiguration DatasetConfiguration { get; set; } + /// Has filter expression to use in the report. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigFilter1 DatasetFilter { get; set; } + /// The granularity of rows in the report. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType? DatasetGranularity { get; set; } + /// + /// Array of group by expression to use in the report. Report can have up to 2 group by clauses. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigGrouping[] DatasetGrouping { get; set; } + /// Array of order by expression to use in the report. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigSorting[] DatasetSorting { get; set; } + /// User input name of the view. Required. + string DisplayName { get; set; } + /// List of KPIs to show in Cost Analysis UI. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IKpiProperties[] Kpi { get; set; } + /// Metric to use when displaying costs. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.MetricType? Metric { get; set; } + /// Date when the user last modified this view. + global::System.DateTime? ModifiedOn { get; set; } + /// Configuration of 3 sub-views in the Cost Analysis UI. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IPivotProperties[] Pivot { get; set; } + /// Query body configuration. Required. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDefinition Query { get; set; } + /// Has definition for data in this report config. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigDataset1 QueryDataset { get; set; } + /// Has time period for pulling data for the report. + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IReportConfigTimePeriod QueryTimePeriod { get; set; } + /// + /// The time frame for pulling data for the report. If custom, then a specific time period must be provided. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportTimeframeType QueryTimeframe { get; set; } + /// + /// The type of the report. Usage represents actual usage, forecast represents forecasted data and UsageAndForecast represents + /// both usage and forecasted data. Actual usage and forecasted data can be differentiated based on dates. + /// + string QueryType { get; set; } + /// + /// Cost Management scope to save the view on. This includes 'subscriptions/{subscriptionId}' for subscription scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' + /// for resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope, + /// '/providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for ExternalBillingAccount + /// scope, and '/providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for ExternalSubscription + /// scope. + /// + string Scope { get; set; } + /// The start date to pull data from. + global::System.DateTime TimePeriodFrom { get; set; } + /// The end date to pull data to. + global::System.DateTime TimePeriodTo { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/Api20200601/ViewProperties.json.cs b/src/CostManagement/generated/api/Models/Api20200601/ViewProperties.json.cs new file mode 100644 index 000000000000..e937ecdcefc4 --- /dev/null +++ b/src/CostManagement/generated/api/Models/Api20200601/ViewProperties.json.cs @@ -0,0 +1,141 @@ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601 +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The properties of the view. + public partial class ViewProperties + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewProperties. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewProperties. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IViewProperties FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new ViewProperties(json) : null; + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + AddIf( null != this._query ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) this._query.ToJson(null,serializationMode) : null, "query" ,container.Add ); + AddIf( null != (((object)this._accumulated)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._accumulated.ToString()) : null, "accumulated" ,container.Add ); + AddIf( null != (((object)this._chart)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._chart.ToString()) : null, "chart" ,container.Add ); + if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeReadOnly)) + { + AddIf( null != this._createdOn ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._createdOn?.ToString(@"yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK",global::System.Globalization.CultureInfo.InvariantCulture)) : null, "createdOn" ,container.Add ); + } + AddIf( null != (((object)this._displayName)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._displayName.ToString()) : null, "displayName" ,container.Add ); + if (null != this._kpi) + { + var __w = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.XNodeArray(); + foreach( var __x in this._kpi ) + { + AddIf(__x?.ToJson(null, serializationMode) ,__w.Add); + } + container.Add("kpis",__w); + } + AddIf( null != (((object)this._metric)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._metric.ToString()) : null, "metric" ,container.Add ); + if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeReadOnly)) + { + AddIf( null != this._modifiedOn ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._modifiedOn?.ToString(@"yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK",global::System.Globalization.CultureInfo.InvariantCulture)) : null, "modifiedOn" ,container.Add ); + } + if (null != this._pivot) + { + var __r = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.XNodeArray(); + foreach( var __s in this._pivot ) + { + AddIf(__s?.ToJson(null, serializationMode) ,__r.Add); + } + container.Add("pivots",__r); + } + AddIf( null != (((object)this._scope)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._scope.ToString()) : null, "scope" ,container.Add ); + AfterToJson(ref container); + return container; + } + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal ViewProperties(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_query = If( json?.PropertyT("query"), out var __jsonQuery) ? Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.ReportConfigDefinition.FromJson(__jsonQuery) : Query;} + {_accumulated = If( json?.PropertyT("accumulated"), out var __jsonAccumulated) ? (string)__jsonAccumulated : (string)Accumulated;} + {_chart = If( json?.PropertyT("chart"), out var __jsonChart) ? (string)__jsonChart : (string)Chart;} + {_createdOn = If( json?.PropertyT("createdOn"), out var __jsonCreatedOn) ? global::System.DateTime.TryParse((string)__jsonCreatedOn, global::System.Globalization.CultureInfo.InvariantCulture, global::System.Globalization.DateTimeStyles.AdjustToUniversal, out var __jsonCreatedOnValue) ? __jsonCreatedOnValue : CreatedOn : CreatedOn;} + {_displayName = If( json?.PropertyT("displayName"), out var __jsonDisplayName) ? (string)__jsonDisplayName : (string)DisplayName;} + {_kpi = If( json?.PropertyT("kpis"), out var __jsonKpis) ? If( __jsonKpis as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonArray, out var __v) ? new global::System.Func(()=> global::System.Linq.Enumerable.ToArray(global::System.Linq.Enumerable.Select(__v, (__u)=>(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IKpiProperties) (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.KpiProperties.FromJson(__u) )) ))() : null : Kpi;} + {_metric = If( json?.PropertyT("metric"), out var __jsonMetric) ? (string)__jsonMetric : (string)Metric;} + {_modifiedOn = If( json?.PropertyT("modifiedOn"), out var __jsonModifiedOn) ? global::System.DateTime.TryParse((string)__jsonModifiedOn, global::System.Globalization.CultureInfo.InvariantCulture, global::System.Globalization.DateTimeStyles.AdjustToUniversal, out var __jsonModifiedOnValue) ? __jsonModifiedOnValue : ModifiedOn : ModifiedOn;} + {_pivot = If( json?.PropertyT("pivots"), out var __jsonPivots) ? If( __jsonPivots as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonArray, out var __q) ? new global::System.Func(()=> global::System.Linq.Enumerable.ToArray(global::System.Linq.Enumerable.Select(__q, (__p)=>(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IPivotProperties) (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.PivotProperties.FromJson(__p) )) ))() : null : Pivot;} + {_scope = If( json?.PropertyT("scope"), out var __jsonScope) ? (string)__jsonScope : (string)Scope;} + AfterFromJson(json); + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/CostManagementIdentity.PowerShell.cs b/src/CostManagement/generated/api/Models/CostManagementIdentity.PowerShell.cs new file mode 100644 index 000000000000..4eb06fc628ef --- /dev/null +++ b/src/CostManagement/generated/api/Models/CostManagementIdentity.PowerShell.cs @@ -0,0 +1,146 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + [System.ComponentModel.TypeConverter(typeof(CostManagementIdentityTypeConverter))] + public partial class CostManagementIdentity + { + + /// + /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the + /// object before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Collections.IDictionary content that should be used. + + partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); + + /// + /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The global::System.Management.Automation.PSObject content that should be used. + + partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); + + /// + /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Collections.IDictionary content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); + + /// + /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization + /// of the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + internal CostManagementIdentity(global::System.Collections.IDictionary content) + { + bool returnNow = false; + BeforeDeserializeDictionary(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentityInternal)this).AlertId = (string) content.GetValueForProperty("AlertId",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentityInternal)this).AlertId, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentityInternal)this).ExportName = (string) content.GetValueForProperty("ExportName",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentityInternal)this).ExportName, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentityInternal)this).ExternalCloudProviderId = (string) content.GetValueForProperty("ExternalCloudProviderId",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentityInternal)this).ExternalCloudProviderId, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentityInternal)this).ExternalCloudProviderType = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExternalCloudProviderType?) content.GetValueForProperty("ExternalCloudProviderType",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentityInternal)this).ExternalCloudProviderType, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExternalCloudProviderType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentityInternal)this).Id = (string) content.GetValueForProperty("Id",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentityInternal)this).Id, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentityInternal)this).Scope = (string) content.GetValueForProperty("Scope",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentityInternal)this).Scope, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentityInternal)this).ViewName = (string) content.GetValueForProperty("ViewName",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentityInternal)this).ViewName, global::System.Convert.ToString); + AfterDeserializeDictionary(content); + } + + /// + /// Deserializes a into a new instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + internal CostManagementIdentity(global::System.Management.Automation.PSObject content) + { + bool returnNow = false; + BeforeDeserializePSObject(content, ref returnNow); + if (returnNow) + { + return; + } + // actually deserialize + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentityInternal)this).AlertId = (string) content.GetValueForProperty("AlertId",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentityInternal)this).AlertId, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentityInternal)this).ExportName = (string) content.GetValueForProperty("ExportName",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentityInternal)this).ExportName, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentityInternal)this).ExternalCloudProviderId = (string) content.GetValueForProperty("ExternalCloudProviderId",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentityInternal)this).ExternalCloudProviderId, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentityInternal)this).ExternalCloudProviderType = (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExternalCloudProviderType?) content.GetValueForProperty("ExternalCloudProviderType",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentityInternal)this).ExternalCloudProviderType, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExternalCloudProviderType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentityInternal)this).Id = (string) content.GetValueForProperty("Id",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentityInternal)this).Id, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentityInternal)this).Scope = (string) content.GetValueForProperty("Scope",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentityInternal)this).Scope, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentityInternal)this).ViewName = (string) content.GetValueForProperty("ViewName",((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentityInternal)this).ViewName, global::System.Convert.ToString); + AfterDeserializePSObject(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Collections.IDictionary content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity DeserializeFromDictionary(global::System.Collections.IDictionary content) + { + return new CostManagementIdentity(content); + } + + /// + /// Deserializes a into an instance of . + /// + /// The global::System.Management.Automation.PSObject content that should be used. + /// + /// an instance of . + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + { + return new CostManagementIdentity(content); + } + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + /// Serializes this instance to a json string. + + /// a containing this model serialized to JSON text. + public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode.IncludeAll)?.ToString(); + } + [System.ComponentModel.TypeConverter(typeof(CostManagementIdentityTypeConverter))] + public partial interface ICostManagementIdentity + + { + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/CostManagementIdentity.TypeConverter.cs b/src/CostManagement/generated/api/Models/CostManagementIdentity.TypeConverter.cs new file mode 100644 index 000000000000..9d46cb3f5eff --- /dev/null +++ b/src/CostManagement/generated/api/Models/CostManagementIdentity.TypeConverter.cs @@ -0,0 +1,157 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models +{ + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell; + + /// + /// A PowerShell PSTypeConverter to support converting to an instance of + /// + public partial class CostManagementIdentityTypeConverter : global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + // we allow string conversion too. + if (type == typeof(global::System.String)) + { + return true; + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + // support direct string to id type conversion. + if (type == typeof(global::System.String)) + { + return new CostManagementIdentity { Id = sourceValue }; + } + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return CostManagementIdentity.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());; + } + catch + { + // Unable to use JSON pattern + } + if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return CostManagementIdentity.DeserializeFromPSObject(sourceValue); + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return CostManagementIdentity.DeserializeFromDictionary(sourceValue); + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/CostManagementIdentity.cs b/src/CostManagement/generated/api/Models/CostManagementIdentity.cs new file mode 100644 index 000000000000..57a6915f2f32 --- /dev/null +++ b/src/CostManagement/generated/api/Models/CostManagementIdentity.cs @@ -0,0 +1,198 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + public partial class CostManagementIdentity : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentityInternal + { + + /// Backing field for property. + private string _alertId; + + /// Alert ID + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string AlertId { get => this._alertId; set => this._alertId = value; } + + /// Backing field for property. + private string _exportName; + + /// Export Name. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string ExportName { get => this._exportName; set => this._exportName = value; } + + /// Backing field for property. + private string _externalCloudProviderId; + + /// + /// This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' for consolidated account used + /// with dimension/query operations. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string ExternalCloudProviderId { get => this._externalCloudProviderId; set => this._externalCloudProviderId = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExternalCloudProviderType? _externalCloudProviderType; + + /// + /// The external cloud provider type associated with dimension/query operations. This includes 'externalSubscriptions' for + /// linked account and 'externalBillingAccounts' for consolidated account. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExternalCloudProviderType? ExternalCloudProviderType { get => this._externalCloudProviderType; set => this._externalCloudProviderType = value; } + + /// Backing field for property. + private string _id; + + /// Resource identity path + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string Id { get => this._id; set => this._id = value; } + + /// Backing field for property. + private string _scope; + + /// + /// The scope associated with view operations. This includes 'subscriptions/{subscriptionId}' for subscription scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' + /// for resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for External Billing Account + /// scope and 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for External Subscription + /// scope. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string Scope { get => this._scope; set => this._scope = value; } + + /// Backing field for property. + private string _viewName; + + /// View name + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Origin(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.PropertyOrigin.Owned)] + public string ViewName { get => this._viewName; set => this._viewName = value; } + + /// Creates an new instance. + public CostManagementIdentity() + { + + } + } + public partial interface ICostManagementIdentity : + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable + { + /// Alert ID + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Alert ID", + SerializedName = @"alertId", + PossibleTypes = new [] { typeof(string) })] + string AlertId { get; set; } + /// Export Name. + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Export Name.", + SerializedName = @"exportName", + PossibleTypes = new [] { typeof(string) })] + string ExportName { get; set; } + /// + /// This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' for consolidated account used + /// with dimension/query operations. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' for consolidated account used with dimension/query operations.", + SerializedName = @"externalCloudProviderId", + PossibleTypes = new [] { typeof(string) })] + string ExternalCloudProviderId { get; set; } + /// + /// The external cloud provider type associated with dimension/query operations. This includes 'externalSubscriptions' for + /// linked account and 'externalBillingAccounts' for consolidated account. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The external cloud provider type associated with dimension/query operations. This includes 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated account.", + SerializedName = @"externalCloudProviderType", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExternalCloudProviderType) })] + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExternalCloudProviderType? ExternalCloudProviderType { get; set; } + /// Resource identity path + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Resource identity path", + SerializedName = @"id", + PossibleTypes = new [] { typeof(string) })] + string Id { get; set; } + /// + /// The scope associated with view operations. This includes 'subscriptions/{subscriptionId}' for subscription scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' + /// for resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for External Billing Account + /// scope and 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for External Subscription + /// scope. + /// + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The scope associated with view operations. This includes 'subscriptions/{subscriptionId}' for subscription scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for BillingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' for InvoiceSection scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope, 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for External Billing Account scope and 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for External Subscription scope.", + SerializedName = @"scope", + PossibleTypes = new [] { typeof(string) })] + string Scope { get; set; } + /// View name + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"View name", + SerializedName = @"viewName", + PossibleTypes = new [] { typeof(string) })] + string ViewName { get; set; } + + } + public partial interface ICostManagementIdentityInternal + + { + /// Alert ID + string AlertId { get; set; } + /// Export Name. + string ExportName { get; set; } + /// + /// This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' for consolidated account used + /// with dimension/query operations. + /// + string ExternalCloudProviderId { get; set; } + /// + /// The external cloud provider type associated with dimension/query operations. This includes 'externalSubscriptions' for + /// linked account and 'externalBillingAccounts' for consolidated account. + /// + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExternalCloudProviderType? ExternalCloudProviderType { get; set; } + /// Resource identity path + string Id { get; set; } + /// + /// The scope associated with view operations. This includes 'subscriptions/{subscriptionId}' for subscription scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' + /// for resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' + /// for Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + /// for EnrollmentAccount scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + /// for BillingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + /// for InvoiceSection scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope, + /// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for External Billing Account + /// scope and 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for External Subscription + /// scope. + /// + string Scope { get; set; } + /// View name + string ViewName { get; set; } + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Models/CostManagementIdentity.json.cs b/src/CostManagement/generated/api/Models/CostManagementIdentity.json.cs new file mode 100644 index 000000000000..22a57a8365f8 --- /dev/null +++ b/src/CostManagement/generated/api/Models/CostManagementIdentity.json.cs @@ -0,0 +1,117 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + public partial class CostManagementIdentity + { + + /// + /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object + /// before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JsonNode that should be deserialized into this object. + + partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json); + + /// + /// AfterToJson will be called after the json erialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior + /// + /// The JSON container that the serialization result will be placed in. + + partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container); + + /// + /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of + /// the object before it is deserialized. + /// If you wish to disable the default deserialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JsonNode that should be deserialized into this object. + /// Determines if the rest of the deserialization should be processed, or if the method should return + /// instantly. + + partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json, ref bool returnNow); + + /// + /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the + /// object before it is serialized. + /// If you wish to disable the default serialization entirely, return true in the output parameter. + /// Implement this method in a partial class to enable this behavior. + /// + /// The JSON container that the serialization result will be placed in. + /// Determines if the rest of the serialization should be processed, or if the method should return + /// instantly. + + partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, ref bool returnNow); + + /// + /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject into a new instance of . + /// + /// A Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject instance to deserialize from. + internal CostManagementIdentity(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + bool returnNow = false; + BeforeFromJson(json, ref returnNow); + if (returnNow) + { + return; + } + {_alertId = If( json?.PropertyT("alertId"), out var __jsonAlertId) ? (string)__jsonAlertId : (string)AlertId;} + {_exportName = If( json?.PropertyT("exportName"), out var __jsonExportName) ? (string)__jsonExportName : (string)ExportName;} + {_externalCloudProviderId = If( json?.PropertyT("externalCloudProviderId"), out var __jsonExternalCloudProviderId) ? (string)__jsonExternalCloudProviderId : (string)ExternalCloudProviderId;} + {_externalCloudProviderType = If( json?.PropertyT("externalCloudProviderType"), out var __jsonExternalCloudProviderType) ? (string)__jsonExternalCloudProviderType : (string)ExternalCloudProviderType;} + {_id = If( json?.PropertyT("id"), out var __jsonId) ? (string)__jsonId : (string)Id;} + {_scope = If( json?.PropertyT("scope"), out var __jsonScope) ? (string)__jsonScope : (string)Scope;} + {_viewName = If( json?.PropertyT("viewName"), out var __jsonViewName) ? (string)__jsonViewName : (string)ViewName;} + AfterFromJson(json); + } + + /// + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity. + /// + /// a to deserialize from. + /// + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity. + /// + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new CostManagementIdentity(json) : null; + } + + /// + /// Serializes this instance of into a . + /// + /// The container to serialize this object into. If the caller + /// passes in null, a new instance will be created and returned to the caller. + /// Allows the caller to choose the depth of the serialization. See . + /// + /// a serialized instance of as a . + /// + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SerializationMode serializationMode) + { + container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject(); + + bool returnNow = false; + BeforeToJson(ref container, ref returnNow); + if (returnNow) + { + return container; + } + AddIf( null != (((object)this._alertId)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._alertId.ToString()) : null, "alertId" ,container.Add ); + AddIf( null != (((object)this._exportName)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._exportName.ToString()) : null, "exportName" ,container.Add ); + AddIf( null != (((object)this._externalCloudProviderId)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._externalCloudProviderId.ToString()) : null, "externalCloudProviderId" ,container.Add ); + AddIf( null != (((object)this._externalCloudProviderType)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._externalCloudProviderType.ToString()) : null, "externalCloudProviderType" ,container.Add ); + AddIf( null != (((object)this._id)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._id.ToString()) : null, "id" ,container.Add ); + AddIf( null != (((object)this._scope)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._scope.ToString()) : null, "scope" ,container.Add ); + AddIf( null != (((object)this._viewName)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonString(this._viewName.ToString()) : null, "viewName" ,container.Add ); + AfterToJson(ref container); + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/AccumulatedType.Completer.cs b/src/CostManagement/generated/api/Support/AccumulatedType.Completer.cs new file mode 100644 index 000000000000..fc1536dacba5 --- /dev/null +++ b/src/CostManagement/generated/api/Support/AccumulatedType.Completer.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// Argument completer implementation for AccumulatedType. + [System.ComponentModel.TypeConverter(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AccumulatedTypeTypeConverter))] + public partial struct AccumulatedType : + System.Management.Automation.IArgumentCompleter + { + + /// + /// Implementations of this function are called by PowerShell to complete arguments. + /// + /// The name of the command that needs argument completion. + /// The name of the parameter that needs argument completion. + /// The (possibly empty) word being completed. + /// The command ast in case it is needed for completion. + /// This parameter is similar to $PSBoundParameters, except that sometimes PowerShell cannot + /// or will not attempt to evaluate an argument, in which case you may need to use commandAst. + /// + /// A collection of completion results, most like with ResultType set to ParameterValue. + /// + public global::System.Collections.Generic.IEnumerable CompleteArgument(global::System.String commandName, global::System.String parameterName, global::System.String wordToComplete, global::System.Management.Automation.Language.CommandAst commandAst, global::System.Collections.IDictionary fakeBoundParameters) + { + if (global::System.String.IsNullOrEmpty(wordToComplete) || "true".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("true", "true", global::System.Management.Automation.CompletionResultType.ParameterValue, "true"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "false".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("false", "false", global::System.Management.Automation.CompletionResultType.ParameterValue, "false"); + } + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/AccumulatedType.TypeConverter.cs b/src/CostManagement/generated/api/Support/AccumulatedType.TypeConverter.cs new file mode 100644 index 000000000000..c00fe65b333a --- /dev/null +++ b/src/CostManagement/generated/api/Support/AccumulatedType.TypeConverter.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// TypeConverter implementation for AccumulatedType. + public partial class AccumulatedTypeTypeConverter : + global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => true; + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => AccumulatedType.CreateFrom(sourceValue); + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/AccumulatedType.cs b/src/CostManagement/generated/api/Support/AccumulatedType.cs new file mode 100644 index 000000000000..2c491ef62562 --- /dev/null +++ b/src/CostManagement/generated/api/Support/AccumulatedType.cs @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + public partial struct AccumulatedType : + System.IEquatable + { + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AccumulatedType False = @"false"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AccumulatedType True = @"true"; + + /// the value for an instance of the Enum. + private string _value { get; set; } + + /// Creates an instance of the + /// the value to create an instance for. + private AccumulatedType(string underlyingValue) + { + this._value = underlyingValue; + } + + /// Conversion from arbitrary object to AccumulatedType + /// the value to convert to an instance of . + internal static object CreateFrom(object value) + { + return new AccumulatedType(System.Convert.ToString(value)); + } + + /// Compares values of enum type AccumulatedType + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public bool Equals(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AccumulatedType e) + { + return _value.Equals(e._value); + } + + /// Compares values of enum type AccumulatedType (override for Object) + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public override bool Equals(object obj) + { + return obj is AccumulatedType && Equals((AccumulatedType)obj); + } + + /// Returns hashCode for enum AccumulatedType + /// The hashCode of the value + public override int GetHashCode() + { + return this._value.GetHashCode(); + } + + /// Returns string representation for AccumulatedType + /// A string for this value. + public override string ToString() + { + return this._value; + } + + /// Implicit operator to convert string to AccumulatedType + /// the value to convert to an instance of . + + public static implicit operator AccumulatedType(string value) + { + return new AccumulatedType(value); + } + + /// Implicit operator to convert AccumulatedType to string + /// the value to convert to an instance of . + + public static implicit operator string(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AccumulatedType e) + { + return e._value; + } + + /// Overriding != operator for enum AccumulatedType + /// the value to compare against + /// the value to compare against + /// true if the two instances are not equal to the same value + public static bool operator !=(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AccumulatedType e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AccumulatedType e2) + { + return !e2.Equals(e1); + } + + /// Overriding == operator for enum AccumulatedType + /// the value to compare against + /// the value to compare against + /// true if the two instances are equal to the same value + public static bool operator ==(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AccumulatedType e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AccumulatedType e2) + { + return e2.Equals(e1); + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/AlertCategory.Completer.cs b/src/CostManagement/generated/api/Support/AlertCategory.Completer.cs new file mode 100644 index 000000000000..d07515b4e0da --- /dev/null +++ b/src/CostManagement/generated/api/Support/AlertCategory.Completer.cs @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// Argument completer implementation for AlertCategory. + [System.ComponentModel.TypeConverter(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCategoryTypeConverter))] + public partial struct AlertCategory : + System.Management.Automation.IArgumentCompleter + { + + /// + /// Implementations of this function are called by PowerShell to complete arguments. + /// + /// The name of the command that needs argument completion. + /// The name of the parameter that needs argument completion. + /// The (possibly empty) word being completed. + /// The command ast in case it is needed for completion. + /// This parameter is similar to $PSBoundParameters, except that sometimes PowerShell cannot + /// or will not attempt to evaluate an argument, in which case you may need to use commandAst. + /// + /// A collection of completion results, most like with ResultType set to ParameterValue. + /// + public global::System.Collections.Generic.IEnumerable CompleteArgument(global::System.String commandName, global::System.String parameterName, global::System.String wordToComplete, global::System.Management.Automation.Language.CommandAst commandAst, global::System.Collections.IDictionary fakeBoundParameters) + { + if (global::System.String.IsNullOrEmpty(wordToComplete) || "Cost".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("Cost", "Cost", global::System.Management.Automation.CompletionResultType.ParameterValue, "Cost"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "Usage".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("Usage", "Usage", global::System.Management.Automation.CompletionResultType.ParameterValue, "Usage"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "Billing".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("Billing", "Billing", global::System.Management.Automation.CompletionResultType.ParameterValue, "Billing"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "System".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("System", "System", global::System.Management.Automation.CompletionResultType.ParameterValue, "System"); + } + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/AlertCategory.TypeConverter.cs b/src/CostManagement/generated/api/Support/AlertCategory.TypeConverter.cs new file mode 100644 index 000000000000..cecf2d2bb4f2 --- /dev/null +++ b/src/CostManagement/generated/api/Support/AlertCategory.TypeConverter.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// TypeConverter implementation for AlertCategory. + public partial class AlertCategoryTypeConverter : + global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => true; + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => AlertCategory.CreateFrom(sourceValue); + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/AlertCategory.cs b/src/CostManagement/generated/api/Support/AlertCategory.cs new file mode 100644 index 000000000000..7f185a5dfa21 --- /dev/null +++ b/src/CostManagement/generated/api/Support/AlertCategory.cs @@ -0,0 +1,101 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + public partial struct AlertCategory : + System.IEquatable + { + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCategory Billing = @"Billing"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCategory Cost = @"Cost"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCategory System1 = @"System"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCategory Usage = @"Usage"; + + /// the value for an instance of the Enum. + private string _value { get; set; } + + /// Creates an instance of the + /// the value to create an instance for. + private AlertCategory(string underlyingValue) + { + this._value = underlyingValue; + } + + /// Conversion from arbitrary object to AlertCategory + /// the value to convert to an instance of . + internal static object CreateFrom(object value) + { + return new AlertCategory(System.Convert.ToString(value)); + } + + /// Compares values of enum type AlertCategory + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public bool Equals(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCategory e) + { + return _value.Equals(e._value); + } + + /// Compares values of enum type AlertCategory (override for Object) + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public override bool Equals(object obj) + { + return obj is AlertCategory && Equals((AlertCategory)obj); + } + + /// Returns hashCode for enum AlertCategory + /// The hashCode of the value + public override int GetHashCode() + { + return this._value.GetHashCode(); + } + + /// Returns string representation for AlertCategory + /// A string for this value. + public override string ToString() + { + return this._value; + } + + /// Implicit operator to convert string to AlertCategory + /// the value to convert to an instance of . + + public static implicit operator AlertCategory(string value) + { + return new AlertCategory(value); + } + + /// Implicit operator to convert AlertCategory to string + /// the value to convert to an instance of . + + public static implicit operator string(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCategory e) + { + return e._value; + } + + /// Overriding != operator for enum AlertCategory + /// the value to compare against + /// the value to compare against + /// true if the two instances are not equal to the same value + public static bool operator !=(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCategory e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCategory e2) + { + return !e2.Equals(e1); + } + + /// Overriding == operator for enum AlertCategory + /// the value to compare against + /// the value to compare against + /// true if the two instances are equal to the same value + public static bool operator ==(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCategory e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCategory e2) + { + return e2.Equals(e1); + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/AlertCriteria.Completer.cs b/src/CostManagement/generated/api/Support/AlertCriteria.Completer.cs new file mode 100644 index 000000000000..50843b37cb59 --- /dev/null +++ b/src/CostManagement/generated/api/Support/AlertCriteria.Completer.cs @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// Argument completer implementation for AlertCriteria. + [System.ComponentModel.TypeConverter(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteriaTypeConverter))] + public partial struct AlertCriteria : + System.Management.Automation.IArgumentCompleter + { + + /// + /// Implementations of this function are called by PowerShell to complete arguments. + /// + /// The name of the command that needs argument completion. + /// The name of the parameter that needs argument completion. + /// The (possibly empty) word being completed. + /// The command ast in case it is needed for completion. + /// This parameter is similar to $PSBoundParameters, except that sometimes PowerShell cannot + /// or will not attempt to evaluate an argument, in which case you may need to use commandAst. + /// + /// A collection of completion results, most like with ResultType set to ParameterValue. + /// + public global::System.Collections.Generic.IEnumerable CompleteArgument(global::System.String commandName, global::System.String parameterName, global::System.String wordToComplete, global::System.Management.Automation.Language.CommandAst commandAst, global::System.Collections.IDictionary fakeBoundParameters) + { + if (global::System.String.IsNullOrEmpty(wordToComplete) || "CostThresholdExceeded".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("CostThresholdExceeded", "CostThresholdExceeded", global::System.Management.Automation.CompletionResultType.ParameterValue, "CostThresholdExceeded"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "UsageThresholdExceeded".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("UsageThresholdExceeded", "UsageThresholdExceeded", global::System.Management.Automation.CompletionResultType.ParameterValue, "UsageThresholdExceeded"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "CreditThresholdApproaching".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("CreditThresholdApproaching", "CreditThresholdApproaching", global::System.Management.Automation.CompletionResultType.ParameterValue, "CreditThresholdApproaching"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "CreditThresholdReached".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("CreditThresholdReached", "CreditThresholdReached", global::System.Management.Automation.CompletionResultType.ParameterValue, "CreditThresholdReached"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "QuotaThresholdApproaching".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("QuotaThresholdApproaching", "QuotaThresholdApproaching", global::System.Management.Automation.CompletionResultType.ParameterValue, "QuotaThresholdApproaching"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "QuotaThresholdReached".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("QuotaThresholdReached", "QuotaThresholdReached", global::System.Management.Automation.CompletionResultType.ParameterValue, "QuotaThresholdReached"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "MultiCurrency".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("MultiCurrency", "MultiCurrency", global::System.Management.Automation.CompletionResultType.ParameterValue, "MultiCurrency"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "ForecastCostThresholdExceeded".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("ForecastCostThresholdExceeded", "ForecastCostThresholdExceeded", global::System.Management.Automation.CompletionResultType.ParameterValue, "ForecastCostThresholdExceeded"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "ForecastUsageThresholdExceeded".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("ForecastUsageThresholdExceeded", "ForecastUsageThresholdExceeded", global::System.Management.Automation.CompletionResultType.ParameterValue, "ForecastUsageThresholdExceeded"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "InvoiceDueDateApproaching".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("InvoiceDueDateApproaching", "InvoiceDueDateApproaching", global::System.Management.Automation.CompletionResultType.ParameterValue, "InvoiceDueDateApproaching"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "InvoiceDueDateReached".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("InvoiceDueDateReached", "InvoiceDueDateReached", global::System.Management.Automation.CompletionResultType.ParameterValue, "InvoiceDueDateReached"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "CrossCloudNewDataAvailable".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("CrossCloudNewDataAvailable", "CrossCloudNewDataAvailable", global::System.Management.Automation.CompletionResultType.ParameterValue, "CrossCloudNewDataAvailable"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "CrossCloudCollectionError".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("CrossCloudCollectionError", "CrossCloudCollectionError", global::System.Management.Automation.CompletionResultType.ParameterValue, "CrossCloudCollectionError"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "GeneralThresholdError".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("GeneralThresholdError", "GeneralThresholdError", global::System.Management.Automation.CompletionResultType.ParameterValue, "GeneralThresholdError"); + } + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/AlertCriteria.TypeConverter.cs b/src/CostManagement/generated/api/Support/AlertCriteria.TypeConverter.cs new file mode 100644 index 000000000000..28503407c6fe --- /dev/null +++ b/src/CostManagement/generated/api/Support/AlertCriteria.TypeConverter.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// TypeConverter implementation for AlertCriteria. + public partial class AlertCriteriaTypeConverter : + global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => true; + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => AlertCriteria.CreateFrom(sourceValue); + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/AlertCriteria.cs b/src/CostManagement/generated/api/Support/AlertCriteria.cs new file mode 100644 index 000000000000..e4f2886095a9 --- /dev/null +++ b/src/CostManagement/generated/api/Support/AlertCriteria.cs @@ -0,0 +1,121 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + public partial struct AlertCriteria : + System.IEquatable + { + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria CostThresholdExceeded = @"CostThresholdExceeded"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria CreditThresholdApproaching = @"CreditThresholdApproaching"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria CreditThresholdReached = @"CreditThresholdReached"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria CrossCloudCollectionError = @"CrossCloudCollectionError"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria CrossCloudNewDataAvailable = @"CrossCloudNewDataAvailable"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria ForecastCostThresholdExceeded = @"ForecastCostThresholdExceeded"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria ForecastUsageThresholdExceeded = @"ForecastUsageThresholdExceeded"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria GeneralThresholdError = @"GeneralThresholdError"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria InvoiceDueDateApproaching = @"InvoiceDueDateApproaching"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria InvoiceDueDateReached = @"InvoiceDueDateReached"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria MultiCurrency = @"MultiCurrency"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria QuotaThresholdApproaching = @"QuotaThresholdApproaching"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria QuotaThresholdReached = @"QuotaThresholdReached"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria UsageThresholdExceeded = @"UsageThresholdExceeded"; + + /// the value for an instance of the Enum. + private string _value { get; set; } + + /// Creates an instance of the + /// the value to create an instance for. + private AlertCriteria(string underlyingValue) + { + this._value = underlyingValue; + } + + /// Conversion from arbitrary object to AlertCriteria + /// the value to convert to an instance of . + internal static object CreateFrom(object value) + { + return new AlertCriteria(System.Convert.ToString(value)); + } + + /// Compares values of enum type AlertCriteria + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public bool Equals(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria e) + { + return _value.Equals(e._value); + } + + /// Compares values of enum type AlertCriteria (override for Object) + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public override bool Equals(object obj) + { + return obj is AlertCriteria && Equals((AlertCriteria)obj); + } + + /// Returns hashCode for enum AlertCriteria + /// The hashCode of the value + public override int GetHashCode() + { + return this._value.GetHashCode(); + } + + /// Returns string representation for AlertCriteria + /// A string for this value. + public override string ToString() + { + return this._value; + } + + /// Implicit operator to convert string to AlertCriteria + /// the value to convert to an instance of . + + public static implicit operator AlertCriteria(string value) + { + return new AlertCriteria(value); + } + + /// Implicit operator to convert AlertCriteria to string + /// the value to convert to an instance of . + + public static implicit operator string(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria e) + { + return e._value; + } + + /// Overriding != operator for enum AlertCriteria + /// the value to compare against + /// the value to compare against + /// true if the two instances are not equal to the same value + public static bool operator !=(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria e2) + { + return !e2.Equals(e1); + } + + /// Overriding == operator for enum AlertCriteria + /// the value to compare against + /// the value to compare against + /// true if the two instances are equal to the same value + public static bool operator ==(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertCriteria e2) + { + return e2.Equals(e1); + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/AlertOperator.Completer.cs b/src/CostManagement/generated/api/Support/AlertOperator.Completer.cs new file mode 100644 index 000000000000..9e4ea2c7a410 --- /dev/null +++ b/src/CostManagement/generated/api/Support/AlertOperator.Completer.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// Argument completer implementation for AlertOperator. + [System.ComponentModel.TypeConverter(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertOperatorTypeConverter))] + public partial struct AlertOperator : + System.Management.Automation.IArgumentCompleter + { + + /// + /// Implementations of this function are called by PowerShell to complete arguments. + /// + /// The name of the command that needs argument completion. + /// The name of the parameter that needs argument completion. + /// The (possibly empty) word being completed. + /// The command ast in case it is needed for completion. + /// This parameter is similar to $PSBoundParameters, except that sometimes PowerShell cannot + /// or will not attempt to evaluate an argument, in which case you may need to use commandAst. + /// + /// A collection of completion results, most like with ResultType set to ParameterValue. + /// + public global::System.Collections.Generic.IEnumerable CompleteArgument(global::System.String commandName, global::System.String parameterName, global::System.String wordToComplete, global::System.Management.Automation.Language.CommandAst commandAst, global::System.Collections.IDictionary fakeBoundParameters) + { + if (global::System.String.IsNullOrEmpty(wordToComplete) || "None".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("None", "None", global::System.Management.Automation.CompletionResultType.ParameterValue, "None"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "EqualTo".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("EqualTo", "EqualTo", global::System.Management.Automation.CompletionResultType.ParameterValue, "EqualTo"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "GreaterThan".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("GreaterThan", "GreaterThan", global::System.Management.Automation.CompletionResultType.ParameterValue, "GreaterThan"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "GreaterThanOrEqualTo".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("GreaterThanOrEqualTo", "GreaterThanOrEqualTo", global::System.Management.Automation.CompletionResultType.ParameterValue, "GreaterThanOrEqualTo"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "LessThan".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("LessThan", "LessThan", global::System.Management.Automation.CompletionResultType.ParameterValue, "LessThan"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "LessThanOrEqualTo".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("LessThanOrEqualTo", "LessThanOrEqualTo", global::System.Management.Automation.CompletionResultType.ParameterValue, "LessThanOrEqualTo"); + } + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/AlertOperator.TypeConverter.cs b/src/CostManagement/generated/api/Support/AlertOperator.TypeConverter.cs new file mode 100644 index 000000000000..c6cd4d2b983a --- /dev/null +++ b/src/CostManagement/generated/api/Support/AlertOperator.TypeConverter.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// TypeConverter implementation for AlertOperator. + public partial class AlertOperatorTypeConverter : + global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => true; + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => AlertOperator.CreateFrom(sourceValue); + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/AlertOperator.cs b/src/CostManagement/generated/api/Support/AlertOperator.cs new file mode 100644 index 000000000000..567ba99bbc87 --- /dev/null +++ b/src/CostManagement/generated/api/Support/AlertOperator.cs @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + public partial struct AlertOperator : + System.IEquatable + { + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertOperator EqualTo = @"EqualTo"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertOperator GreaterThan = @"GreaterThan"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertOperator GreaterThanOrEqualTo = @"GreaterThanOrEqualTo"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertOperator LessThan = @"LessThan"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertOperator LessThanOrEqualTo = @"LessThanOrEqualTo"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertOperator None = @"None"; + + /// the value for an instance of the Enum. + private string _value { get; set; } + + /// Creates an instance of the + /// the value to create an instance for. + private AlertOperator(string underlyingValue) + { + this._value = underlyingValue; + } + + /// Conversion from arbitrary object to AlertOperator + /// the value to convert to an instance of . + internal static object CreateFrom(object value) + { + return new AlertOperator(System.Convert.ToString(value)); + } + + /// Compares values of enum type AlertOperator + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public bool Equals(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertOperator e) + { + return _value.Equals(e._value); + } + + /// Compares values of enum type AlertOperator (override for Object) + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public override bool Equals(object obj) + { + return obj is AlertOperator && Equals((AlertOperator)obj); + } + + /// Returns hashCode for enum AlertOperator + /// The hashCode of the value + public override int GetHashCode() + { + return this._value.GetHashCode(); + } + + /// Returns string representation for AlertOperator + /// A string for this value. + public override string ToString() + { + return this._value; + } + + /// Implicit operator to convert string to AlertOperator + /// the value to convert to an instance of . + + public static implicit operator AlertOperator(string value) + { + return new AlertOperator(value); + } + + /// Implicit operator to convert AlertOperator to string + /// the value to convert to an instance of . + + public static implicit operator string(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertOperator e) + { + return e._value; + } + + /// Overriding != operator for enum AlertOperator + /// the value to compare against + /// the value to compare against + /// true if the two instances are not equal to the same value + public static bool operator !=(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertOperator e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertOperator e2) + { + return !e2.Equals(e1); + } + + /// Overriding == operator for enum AlertOperator + /// the value to compare against + /// the value to compare against + /// true if the two instances are equal to the same value + public static bool operator ==(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertOperator e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertOperator e2) + { + return e2.Equals(e1); + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/AlertSource.Completer.cs b/src/CostManagement/generated/api/Support/AlertSource.Completer.cs new file mode 100644 index 000000000000..7532271e89d0 --- /dev/null +++ b/src/CostManagement/generated/api/Support/AlertSource.Completer.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// Argument completer implementation for AlertSource. + [System.ComponentModel.TypeConverter(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertSourceTypeConverter))] + public partial struct AlertSource : + System.Management.Automation.IArgumentCompleter + { + + /// + /// Implementations of this function are called by PowerShell to complete arguments. + /// + /// The name of the command that needs argument completion. + /// The name of the parameter that needs argument completion. + /// The (possibly empty) word being completed. + /// The command ast in case it is needed for completion. + /// This parameter is similar to $PSBoundParameters, except that sometimes PowerShell cannot + /// or will not attempt to evaluate an argument, in which case you may need to use commandAst. + /// + /// A collection of completion results, most like with ResultType set to ParameterValue. + /// + public global::System.Collections.Generic.IEnumerable CompleteArgument(global::System.String commandName, global::System.String parameterName, global::System.String wordToComplete, global::System.Management.Automation.Language.CommandAst commandAst, global::System.Collections.IDictionary fakeBoundParameters) + { + if (global::System.String.IsNullOrEmpty(wordToComplete) || "Preset".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("Preset", "Preset", global::System.Management.Automation.CompletionResultType.ParameterValue, "Preset"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "User".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("User", "User", global::System.Management.Automation.CompletionResultType.ParameterValue, "User"); + } + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/AlertSource.TypeConverter.cs b/src/CostManagement/generated/api/Support/AlertSource.TypeConverter.cs new file mode 100644 index 000000000000..3be048ab6919 --- /dev/null +++ b/src/CostManagement/generated/api/Support/AlertSource.TypeConverter.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// TypeConverter implementation for AlertSource. + public partial class AlertSourceTypeConverter : + global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => true; + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => AlertSource.CreateFrom(sourceValue); + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/AlertSource.cs b/src/CostManagement/generated/api/Support/AlertSource.cs new file mode 100644 index 000000000000..9cd1585ad294 --- /dev/null +++ b/src/CostManagement/generated/api/Support/AlertSource.cs @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + public partial struct AlertSource : + System.IEquatable + { + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertSource Preset = @"Preset"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertSource User = @"User"; + + /// the value for an instance of the Enum. + private string _value { get; set; } + + /// Creates an instance of the + /// the value to create an instance for. + private AlertSource(string underlyingValue) + { + this._value = underlyingValue; + } + + /// Conversion from arbitrary object to AlertSource + /// the value to convert to an instance of . + internal static object CreateFrom(object value) + { + return new AlertSource(System.Convert.ToString(value)); + } + + /// Compares values of enum type AlertSource + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public bool Equals(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertSource e) + { + return _value.Equals(e._value); + } + + /// Compares values of enum type AlertSource (override for Object) + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public override bool Equals(object obj) + { + return obj is AlertSource && Equals((AlertSource)obj); + } + + /// Returns hashCode for enum AlertSource + /// The hashCode of the value + public override int GetHashCode() + { + return this._value.GetHashCode(); + } + + /// Returns string representation for AlertSource + /// A string for this value. + public override string ToString() + { + return this._value; + } + + /// Implicit operator to convert string to AlertSource + /// the value to convert to an instance of . + + public static implicit operator AlertSource(string value) + { + return new AlertSource(value); + } + + /// Implicit operator to convert AlertSource to string + /// the value to convert to an instance of . + + public static implicit operator string(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertSource e) + { + return e._value; + } + + /// Overriding != operator for enum AlertSource + /// the value to compare against + /// the value to compare against + /// true if the two instances are not equal to the same value + public static bool operator !=(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertSource e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertSource e2) + { + return !e2.Equals(e1); + } + + /// Overriding == operator for enum AlertSource + /// the value to compare against + /// the value to compare against + /// true if the two instances are equal to the same value + public static bool operator ==(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertSource e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertSource e2) + { + return e2.Equals(e1); + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/AlertStatus.Completer.cs b/src/CostManagement/generated/api/Support/AlertStatus.Completer.cs new file mode 100644 index 000000000000..0947d5bfc3ff --- /dev/null +++ b/src/CostManagement/generated/api/Support/AlertStatus.Completer.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// Argument completer implementation for AlertStatus. + [System.ComponentModel.TypeConverter(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertStatusTypeConverter))] + public partial struct AlertStatus : + System.Management.Automation.IArgumentCompleter + { + + /// + /// Implementations of this function are called by PowerShell to complete arguments. + /// + /// The name of the command that needs argument completion. + /// The name of the parameter that needs argument completion. + /// The (possibly empty) word being completed. + /// The command ast in case it is needed for completion. + /// This parameter is similar to $PSBoundParameters, except that sometimes PowerShell cannot + /// or will not attempt to evaluate an argument, in which case you may need to use commandAst. + /// + /// A collection of completion results, most like with ResultType set to ParameterValue. + /// + public global::System.Collections.Generic.IEnumerable CompleteArgument(global::System.String commandName, global::System.String parameterName, global::System.String wordToComplete, global::System.Management.Automation.Language.CommandAst commandAst, global::System.Collections.IDictionary fakeBoundParameters) + { + if (global::System.String.IsNullOrEmpty(wordToComplete) || "None".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("None", "None", global::System.Management.Automation.CompletionResultType.ParameterValue, "None"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "Active".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("Active", "Active", global::System.Management.Automation.CompletionResultType.ParameterValue, "Active"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "Overridden".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("Overridden", "Overridden", global::System.Management.Automation.CompletionResultType.ParameterValue, "Overridden"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "Resolved".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("Resolved", "Resolved", global::System.Management.Automation.CompletionResultType.ParameterValue, "Resolved"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "Dismissed".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("Dismissed", "Dismissed", global::System.Management.Automation.CompletionResultType.ParameterValue, "Dismissed"); + } + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/AlertStatus.TypeConverter.cs b/src/CostManagement/generated/api/Support/AlertStatus.TypeConverter.cs new file mode 100644 index 000000000000..044f9c978605 --- /dev/null +++ b/src/CostManagement/generated/api/Support/AlertStatus.TypeConverter.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// TypeConverter implementation for AlertStatus. + public partial class AlertStatusTypeConverter : + global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => true; + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => AlertStatus.CreateFrom(sourceValue); + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/AlertStatus.cs b/src/CostManagement/generated/api/Support/AlertStatus.cs new file mode 100644 index 000000000000..f8c8638724b9 --- /dev/null +++ b/src/CostManagement/generated/api/Support/AlertStatus.cs @@ -0,0 +1,103 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + public partial struct AlertStatus : + System.IEquatable + { + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertStatus Active = @"Active"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertStatus Dismissed = @"Dismissed"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertStatus None = @"None"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertStatus Overridden = @"Overridden"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertStatus Resolved = @"Resolved"; + + /// the value for an instance of the Enum. + private string _value { get; set; } + + /// Creates an instance of the + /// the value to create an instance for. + private AlertStatus(string underlyingValue) + { + this._value = underlyingValue; + } + + /// Conversion from arbitrary object to AlertStatus + /// the value to convert to an instance of . + internal static object CreateFrom(object value) + { + return new AlertStatus(System.Convert.ToString(value)); + } + + /// Compares values of enum type AlertStatus + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public bool Equals(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertStatus e) + { + return _value.Equals(e._value); + } + + /// Compares values of enum type AlertStatus (override for Object) + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public override bool Equals(object obj) + { + return obj is AlertStatus && Equals((AlertStatus)obj); + } + + /// Returns hashCode for enum AlertStatus + /// The hashCode of the value + public override int GetHashCode() + { + return this._value.GetHashCode(); + } + + /// Returns string representation for AlertStatus + /// A string for this value. + public override string ToString() + { + return this._value; + } + + /// Implicit operator to convert string to AlertStatus + /// the value to convert to an instance of . + + public static implicit operator AlertStatus(string value) + { + return new AlertStatus(value); + } + + /// Implicit operator to convert AlertStatus to string + /// the value to convert to an instance of . + + public static implicit operator string(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertStatus e) + { + return e._value; + } + + /// Overriding != operator for enum AlertStatus + /// the value to compare against + /// the value to compare against + /// true if the two instances are not equal to the same value + public static bool operator !=(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertStatus e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertStatus e2) + { + return !e2.Equals(e1); + } + + /// Overriding == operator for enum AlertStatus + /// the value to compare against + /// the value to compare against + /// true if the two instances are equal to the same value + public static bool operator ==(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertStatus e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertStatus e2) + { + return e2.Equals(e1); + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/AlertTimeGrainType.Completer.cs b/src/CostManagement/generated/api/Support/AlertTimeGrainType.Completer.cs new file mode 100644 index 000000000000..006ff6083ed2 --- /dev/null +++ b/src/CostManagement/generated/api/Support/AlertTimeGrainType.Completer.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// Argument completer implementation for AlertTimeGrainType. + [System.ComponentModel.TypeConverter(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertTimeGrainTypeTypeConverter))] + public partial struct AlertTimeGrainType : + System.Management.Automation.IArgumentCompleter + { + + /// + /// Implementations of this function are called by PowerShell to complete arguments. + /// + /// The name of the command that needs argument completion. + /// The name of the parameter that needs argument completion. + /// The (possibly empty) word being completed. + /// The command ast in case it is needed for completion. + /// This parameter is similar to $PSBoundParameters, except that sometimes PowerShell cannot + /// or will not attempt to evaluate an argument, in which case you may need to use commandAst. + /// + /// A collection of completion results, most like with ResultType set to ParameterValue. + /// + public global::System.Collections.Generic.IEnumerable CompleteArgument(global::System.String commandName, global::System.String parameterName, global::System.String wordToComplete, global::System.Management.Automation.Language.CommandAst commandAst, global::System.Collections.IDictionary fakeBoundParameters) + { + if (global::System.String.IsNullOrEmpty(wordToComplete) || "None".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("None", "None", global::System.Management.Automation.CompletionResultType.ParameterValue, "None"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "Monthly".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("Monthly", "Monthly", global::System.Management.Automation.CompletionResultType.ParameterValue, "Monthly"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "Quarterly".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("Quarterly", "Quarterly", global::System.Management.Automation.CompletionResultType.ParameterValue, "Quarterly"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "Annually".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("Annually", "Annually", global::System.Management.Automation.CompletionResultType.ParameterValue, "Annually"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "BillingMonth".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("BillingMonth", "BillingMonth", global::System.Management.Automation.CompletionResultType.ParameterValue, "BillingMonth"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "BillingQuarter".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("BillingQuarter", "BillingQuarter", global::System.Management.Automation.CompletionResultType.ParameterValue, "BillingQuarter"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "BillingAnnual".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("BillingAnnual", "BillingAnnual", global::System.Management.Automation.CompletionResultType.ParameterValue, "BillingAnnual"); + } + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/AlertTimeGrainType.TypeConverter.cs b/src/CostManagement/generated/api/Support/AlertTimeGrainType.TypeConverter.cs new file mode 100644 index 000000000000..531d1977d313 --- /dev/null +++ b/src/CostManagement/generated/api/Support/AlertTimeGrainType.TypeConverter.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// TypeConverter implementation for AlertTimeGrainType. + public partial class AlertTimeGrainTypeTypeConverter : + global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => true; + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => AlertTimeGrainType.CreateFrom(sourceValue); + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/AlertTimeGrainType.cs b/src/CostManagement/generated/api/Support/AlertTimeGrainType.cs new file mode 100644 index 000000000000..374aef6379b8 --- /dev/null +++ b/src/CostManagement/generated/api/Support/AlertTimeGrainType.cs @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + public partial struct AlertTimeGrainType : + System.IEquatable + { + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertTimeGrainType Annually = @"Annually"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertTimeGrainType BillingAnnual = @"BillingAnnual"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertTimeGrainType BillingMonth = @"BillingMonth"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertTimeGrainType BillingQuarter = @"BillingQuarter"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertTimeGrainType Monthly = @"Monthly"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertTimeGrainType None = @"None"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertTimeGrainType Quarterly = @"Quarterly"; + + /// the value for an instance of the Enum. + private string _value { get; set; } + + /// Creates an instance of the + /// the value to create an instance for. + private AlertTimeGrainType(string underlyingValue) + { + this._value = underlyingValue; + } + + /// Conversion from arbitrary object to AlertTimeGrainType + /// the value to convert to an instance of . + internal static object CreateFrom(object value) + { + return new AlertTimeGrainType(System.Convert.ToString(value)); + } + + /// Compares values of enum type AlertTimeGrainType + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public bool Equals(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertTimeGrainType e) + { + return _value.Equals(e._value); + } + + /// Compares values of enum type AlertTimeGrainType (override for Object) + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public override bool Equals(object obj) + { + return obj is AlertTimeGrainType && Equals((AlertTimeGrainType)obj); + } + + /// Returns hashCode for enum AlertTimeGrainType + /// The hashCode of the value + public override int GetHashCode() + { + return this._value.GetHashCode(); + } + + /// Returns string representation for AlertTimeGrainType + /// A string for this value. + public override string ToString() + { + return this._value; + } + + /// Implicit operator to convert string to AlertTimeGrainType + /// the value to convert to an instance of . + + public static implicit operator AlertTimeGrainType(string value) + { + return new AlertTimeGrainType(value); + } + + /// Implicit operator to convert AlertTimeGrainType to string + /// the value to convert to an instance of . + + public static implicit operator string(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertTimeGrainType e) + { + return e._value; + } + + /// Overriding != operator for enum AlertTimeGrainType + /// the value to compare against + /// the value to compare against + /// true if the two instances are not equal to the same value + public static bool operator !=(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertTimeGrainType e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertTimeGrainType e2) + { + return !e2.Equals(e1); + } + + /// Overriding == operator for enum AlertTimeGrainType + /// the value to compare against + /// the value to compare against + /// true if the two instances are equal to the same value + public static bool operator ==(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertTimeGrainType e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertTimeGrainType e2) + { + return e2.Equals(e1); + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/AlertType.Completer.cs b/src/CostManagement/generated/api/Support/AlertType.Completer.cs new file mode 100644 index 000000000000..248980c31a50 --- /dev/null +++ b/src/CostManagement/generated/api/Support/AlertType.Completer.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// Argument completer implementation for AlertType. + [System.ComponentModel.TypeConverter(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertTypeTypeConverter))] + public partial struct AlertType : + System.Management.Automation.IArgumentCompleter + { + + /// + /// Implementations of this function are called by PowerShell to complete arguments. + /// + /// The name of the command that needs argument completion. + /// The name of the parameter that needs argument completion. + /// The (possibly empty) word being completed. + /// The command ast in case it is needed for completion. + /// This parameter is similar to $PSBoundParameters, except that sometimes PowerShell cannot + /// or will not attempt to evaluate an argument, in which case you may need to use commandAst. + /// + /// A collection of completion results, most like with ResultType set to ParameterValue. + /// + public global::System.Collections.Generic.IEnumerable CompleteArgument(global::System.String commandName, global::System.String parameterName, global::System.String wordToComplete, global::System.Management.Automation.Language.CommandAst commandAst, global::System.Collections.IDictionary fakeBoundParameters) + { + if (global::System.String.IsNullOrEmpty(wordToComplete) || "Budget".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("Budget", "Budget", global::System.Management.Automation.CompletionResultType.ParameterValue, "Budget"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "Invoice".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("Invoice", "Invoice", global::System.Management.Automation.CompletionResultType.ParameterValue, "Invoice"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "Credit".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("Credit", "Credit", global::System.Management.Automation.CompletionResultType.ParameterValue, "Credit"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "Quota".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("Quota", "Quota", global::System.Management.Automation.CompletionResultType.ParameterValue, "Quota"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "General".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("General", "General", global::System.Management.Automation.CompletionResultType.ParameterValue, "General"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "xCloud".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("xCloud", "xCloud", global::System.Management.Automation.CompletionResultType.ParameterValue, "xCloud"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "BudgetForecast".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("BudgetForecast", "BudgetForecast", global::System.Management.Automation.CompletionResultType.ParameterValue, "BudgetForecast"); + } + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/AlertType.TypeConverter.cs b/src/CostManagement/generated/api/Support/AlertType.TypeConverter.cs new file mode 100644 index 000000000000..7270ad47976e --- /dev/null +++ b/src/CostManagement/generated/api/Support/AlertType.TypeConverter.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// TypeConverter implementation for AlertType. + public partial class AlertTypeTypeConverter : + global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => true; + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => AlertType.CreateFrom(sourceValue); + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/AlertType.cs b/src/CostManagement/generated/api/Support/AlertType.cs new file mode 100644 index 000000000000..e52deecc0912 --- /dev/null +++ b/src/CostManagement/generated/api/Support/AlertType.cs @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + public partial struct AlertType : + System.IEquatable + { + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertType Budget = @"Budget"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertType BudgetForecast = @"BudgetForecast"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertType Credit = @"Credit"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertType General = @"General"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertType Invoice = @"Invoice"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertType Quota = @"Quota"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertType XCloud = @"xCloud"; + + /// the value for an instance of the Enum. + private string _value { get; set; } + + /// Creates an instance of the + /// the value to create an instance for. + private AlertType(string underlyingValue) + { + this._value = underlyingValue; + } + + /// Conversion from arbitrary object to AlertType + /// the value to convert to an instance of . + internal static object CreateFrom(object value) + { + return new AlertType(System.Convert.ToString(value)); + } + + /// Compares values of enum type AlertType + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public bool Equals(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertType e) + { + return _value.Equals(e._value); + } + + /// Compares values of enum type AlertType (override for Object) + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public override bool Equals(object obj) + { + return obj is AlertType && Equals((AlertType)obj); + } + + /// Returns hashCode for enum AlertType + /// The hashCode of the value + public override int GetHashCode() + { + return this._value.GetHashCode(); + } + + /// Returns string representation for AlertType + /// A string for this value. + public override string ToString() + { + return this._value; + } + + /// Implicit operator to convert string to AlertType + /// the value to convert to an instance of . + + public static implicit operator AlertType(string value) + { + return new AlertType(value); + } + + /// Implicit operator to convert AlertType to string + /// the value to convert to an instance of . + + public static implicit operator string(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertType e) + { + return e._value; + } + + /// Overriding != operator for enum AlertType + /// the value to compare against + /// the value to compare against + /// true if the two instances are not equal to the same value + public static bool operator !=(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertType e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertType e2) + { + return !e2.Equals(e1); + } + + /// Overriding == operator for enum AlertType + /// the value to compare against + /// the value to compare against + /// true if the two instances are equal to the same value + public static bool operator ==(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertType e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.AlertType e2) + { + return e2.Equals(e1); + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/ChartType.Completer.cs b/src/CostManagement/generated/api/Support/ChartType.Completer.cs new file mode 100644 index 000000000000..be409c0ed224 --- /dev/null +++ b/src/CostManagement/generated/api/Support/ChartType.Completer.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// Argument completer implementation for ChartType. + [System.ComponentModel.TypeConverter(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ChartTypeTypeConverter))] + public partial struct ChartType : + System.Management.Automation.IArgumentCompleter + { + + /// + /// Implementations of this function are called by PowerShell to complete arguments. + /// + /// The name of the command that needs argument completion. + /// The name of the parameter that needs argument completion. + /// The (possibly empty) word being completed. + /// The command ast in case it is needed for completion. + /// This parameter is similar to $PSBoundParameters, except that sometimes PowerShell cannot + /// or will not attempt to evaluate an argument, in which case you may need to use commandAst. + /// + /// A collection of completion results, most like with ResultType set to ParameterValue. + /// + public global::System.Collections.Generic.IEnumerable CompleteArgument(global::System.String commandName, global::System.String parameterName, global::System.String wordToComplete, global::System.Management.Automation.Language.CommandAst commandAst, global::System.Collections.IDictionary fakeBoundParameters) + { + if (global::System.String.IsNullOrEmpty(wordToComplete) || "Area".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("Area", "Area", global::System.Management.Automation.CompletionResultType.ParameterValue, "Area"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "Line".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("Line", "Line", global::System.Management.Automation.CompletionResultType.ParameterValue, "Line"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "StackedColumn".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("StackedColumn", "StackedColumn", global::System.Management.Automation.CompletionResultType.ParameterValue, "StackedColumn"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "GroupedColumn".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("GroupedColumn", "GroupedColumn", global::System.Management.Automation.CompletionResultType.ParameterValue, "GroupedColumn"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "Table".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("Table", "Table", global::System.Management.Automation.CompletionResultType.ParameterValue, "Table"); + } + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/ChartType.TypeConverter.cs b/src/CostManagement/generated/api/Support/ChartType.TypeConverter.cs new file mode 100644 index 000000000000..84f5e73bb407 --- /dev/null +++ b/src/CostManagement/generated/api/Support/ChartType.TypeConverter.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// TypeConverter implementation for ChartType. + public partial class ChartTypeTypeConverter : + global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => true; + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ChartType.CreateFrom(sourceValue); + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/ChartType.cs b/src/CostManagement/generated/api/Support/ChartType.cs new file mode 100644 index 000000000000..cdccbd359de0 --- /dev/null +++ b/src/CostManagement/generated/api/Support/ChartType.cs @@ -0,0 +1,103 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + public partial struct ChartType : + System.IEquatable + { + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ChartType Area = @"Area"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ChartType GroupedColumn = @"GroupedColumn"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ChartType Line = @"Line"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ChartType StackedColumn = @"StackedColumn"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ChartType Table = @"Table"; + + /// the value for an instance of the Enum. + private string _value { get; set; } + + /// Creates an instance of the + /// the value to create an instance for. + private ChartType(string underlyingValue) + { + this._value = underlyingValue; + } + + /// Conversion from arbitrary object to ChartType + /// the value to convert to an instance of . + internal static object CreateFrom(object value) + { + return new ChartType(System.Convert.ToString(value)); + } + + /// Compares values of enum type ChartType + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public bool Equals(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ChartType e) + { + return _value.Equals(e._value); + } + + /// Compares values of enum type ChartType (override for Object) + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public override bool Equals(object obj) + { + return obj is ChartType && Equals((ChartType)obj); + } + + /// Returns hashCode for enum ChartType + /// The hashCode of the value + public override int GetHashCode() + { + return this._value.GetHashCode(); + } + + /// Returns string representation for ChartType + /// A string for this value. + public override string ToString() + { + return this._value; + } + + /// Implicit operator to convert string to ChartType + /// the value to convert to an instance of . + + public static implicit operator ChartType(string value) + { + return new ChartType(value); + } + + /// Implicit operator to convert ChartType to string + /// the value to convert to an instance of . + + public static implicit operator string(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ChartType e) + { + return e._value; + } + + /// Overriding != operator for enum ChartType + /// the value to compare against + /// the value to compare against + /// true if the two instances are not equal to the same value + public static bool operator !=(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ChartType e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ChartType e2) + { + return !e2.Equals(e1); + } + + /// Overriding == operator for enum ChartType + /// the value to compare against + /// the value to compare against + /// true if the two instances are equal to the same value + public static bool operator ==(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ChartType e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ChartType e2) + { + return e2.Equals(e1); + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/ExecutionStatus.Completer.cs b/src/CostManagement/generated/api/Support/ExecutionStatus.Completer.cs new file mode 100644 index 000000000000..f4b303f7f963 --- /dev/null +++ b/src/CostManagement/generated/api/Support/ExecutionStatus.Completer.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// Argument completer implementation for ExecutionStatus. + [System.ComponentModel.TypeConverter(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionStatusTypeConverter))] + public partial struct ExecutionStatus : + System.Management.Automation.IArgumentCompleter + { + + /// + /// Implementations of this function are called by PowerShell to complete arguments. + /// + /// The name of the command that needs argument completion. + /// The name of the parameter that needs argument completion. + /// The (possibly empty) word being completed. + /// The command ast in case it is needed for completion. + /// This parameter is similar to $PSBoundParameters, except that sometimes PowerShell cannot + /// or will not attempt to evaluate an argument, in which case you may need to use commandAst. + /// + /// A collection of completion results, most like with ResultType set to ParameterValue. + /// + public global::System.Collections.Generic.IEnumerable CompleteArgument(global::System.String commandName, global::System.String parameterName, global::System.String wordToComplete, global::System.Management.Automation.Language.CommandAst commandAst, global::System.Collections.IDictionary fakeBoundParameters) + { + if (global::System.String.IsNullOrEmpty(wordToComplete) || "Queued".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("Queued", "Queued", global::System.Management.Automation.CompletionResultType.ParameterValue, "Queued"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "InProgress".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("InProgress", "InProgress", global::System.Management.Automation.CompletionResultType.ParameterValue, "InProgress"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "Completed".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("Completed", "Completed", global::System.Management.Automation.CompletionResultType.ParameterValue, "Completed"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "Failed".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("Failed", "Failed", global::System.Management.Automation.CompletionResultType.ParameterValue, "Failed"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "Timeout".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("Timeout", "Timeout", global::System.Management.Automation.CompletionResultType.ParameterValue, "Timeout"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "NewDataNotAvailable".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("NewDataNotAvailable", "NewDataNotAvailable", global::System.Management.Automation.CompletionResultType.ParameterValue, "NewDataNotAvailable"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "DataNotAvailable".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("DataNotAvailable", "DataNotAvailable", global::System.Management.Automation.CompletionResultType.ParameterValue, "DataNotAvailable"); + } + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/ExecutionStatus.TypeConverter.cs b/src/CostManagement/generated/api/Support/ExecutionStatus.TypeConverter.cs new file mode 100644 index 000000000000..f2e78de4a424 --- /dev/null +++ b/src/CostManagement/generated/api/Support/ExecutionStatus.TypeConverter.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// TypeConverter implementation for ExecutionStatus. + public partial class ExecutionStatusTypeConverter : + global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => true; + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ExecutionStatus.CreateFrom(sourceValue); + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/ExecutionStatus.cs b/src/CostManagement/generated/api/Support/ExecutionStatus.cs new file mode 100644 index 000000000000..cd5cad14c8bc --- /dev/null +++ b/src/CostManagement/generated/api/Support/ExecutionStatus.cs @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + public partial struct ExecutionStatus : + System.IEquatable + { + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionStatus Completed = @"Completed"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionStatus DataNotAvailable = @"DataNotAvailable"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionStatus Failed = @"Failed"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionStatus InProgress = @"InProgress"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionStatus NewDataNotAvailable = @"NewDataNotAvailable"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionStatus Queued = @"Queued"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionStatus Timeout = @"Timeout"; + + /// the value for an instance of the Enum. + private string _value { get; set; } + + /// Conversion from arbitrary object to ExecutionStatus + /// the value to convert to an instance of . + internal static object CreateFrom(object value) + { + return new ExecutionStatus(System.Convert.ToString(value)); + } + + /// Compares values of enum type ExecutionStatus + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public bool Equals(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionStatus e) + { + return _value.Equals(e._value); + } + + /// Compares values of enum type ExecutionStatus (override for Object) + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public override bool Equals(object obj) + { + return obj is ExecutionStatus && Equals((ExecutionStatus)obj); + } + + /// Creates an instance of the + /// the value to create an instance for. + private ExecutionStatus(string underlyingValue) + { + this._value = underlyingValue; + } + + /// Returns hashCode for enum ExecutionStatus + /// The hashCode of the value + public override int GetHashCode() + { + return this._value.GetHashCode(); + } + + /// Returns string representation for ExecutionStatus + /// A string for this value. + public override string ToString() + { + return this._value; + } + + /// Implicit operator to convert string to ExecutionStatus + /// the value to convert to an instance of . + + public static implicit operator ExecutionStatus(string value) + { + return new ExecutionStatus(value); + } + + /// Implicit operator to convert ExecutionStatus to string + /// the value to convert to an instance of . + + public static implicit operator string(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionStatus e) + { + return e._value; + } + + /// Overriding != operator for enum ExecutionStatus + /// the value to compare against + /// the value to compare against + /// true if the two instances are not equal to the same value + public static bool operator !=(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionStatus e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionStatus e2) + { + return !e2.Equals(e1); + } + + /// Overriding == operator for enum ExecutionStatus + /// the value to compare against + /// the value to compare against + /// true if the two instances are equal to the same value + public static bool operator ==(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionStatus e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionStatus e2) + { + return e2.Equals(e1); + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/ExecutionType.Completer.cs b/src/CostManagement/generated/api/Support/ExecutionType.Completer.cs new file mode 100644 index 000000000000..34d76d39e952 --- /dev/null +++ b/src/CostManagement/generated/api/Support/ExecutionType.Completer.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// Argument completer implementation for ExecutionType. + [System.ComponentModel.TypeConverter(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionTypeTypeConverter))] + public partial struct ExecutionType : + System.Management.Automation.IArgumentCompleter + { + + /// + /// Implementations of this function are called by PowerShell to complete arguments. + /// + /// The name of the command that needs argument completion. + /// The name of the parameter that needs argument completion. + /// The (possibly empty) word being completed. + /// The command ast in case it is needed for completion. + /// This parameter is similar to $PSBoundParameters, except that sometimes PowerShell cannot + /// or will not attempt to evaluate an argument, in which case you may need to use commandAst. + /// + /// A collection of completion results, most like with ResultType set to ParameterValue. + /// + public global::System.Collections.Generic.IEnumerable CompleteArgument(global::System.String commandName, global::System.String parameterName, global::System.String wordToComplete, global::System.Management.Automation.Language.CommandAst commandAst, global::System.Collections.IDictionary fakeBoundParameters) + { + if (global::System.String.IsNullOrEmpty(wordToComplete) || "OnDemand".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("OnDemand", "OnDemand", global::System.Management.Automation.CompletionResultType.ParameterValue, "OnDemand"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "Scheduled".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("Scheduled", "Scheduled", global::System.Management.Automation.CompletionResultType.ParameterValue, "Scheduled"); + } + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/ExecutionType.TypeConverter.cs b/src/CostManagement/generated/api/Support/ExecutionType.TypeConverter.cs new file mode 100644 index 000000000000..908957dfc135 --- /dev/null +++ b/src/CostManagement/generated/api/Support/ExecutionType.TypeConverter.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// TypeConverter implementation for ExecutionType. + public partial class ExecutionTypeTypeConverter : + global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => true; + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ExecutionType.CreateFrom(sourceValue); + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/ExecutionType.cs b/src/CostManagement/generated/api/Support/ExecutionType.cs new file mode 100644 index 000000000000..2e277829098c --- /dev/null +++ b/src/CostManagement/generated/api/Support/ExecutionType.cs @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + public partial struct ExecutionType : + System.IEquatable + { + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionType OnDemand = @"OnDemand"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionType Scheduled = @"Scheduled"; + + /// the value for an instance of the Enum. + private string _value { get; set; } + + /// Conversion from arbitrary object to ExecutionType + /// the value to convert to an instance of . + internal static object CreateFrom(object value) + { + return new ExecutionType(System.Convert.ToString(value)); + } + + /// Compares values of enum type ExecutionType + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public bool Equals(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionType e) + { + return _value.Equals(e._value); + } + + /// Compares values of enum type ExecutionType (override for Object) + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public override bool Equals(object obj) + { + return obj is ExecutionType && Equals((ExecutionType)obj); + } + + /// Creates an instance of the + /// the value to create an instance for. + private ExecutionType(string underlyingValue) + { + this._value = underlyingValue; + } + + /// Returns hashCode for enum ExecutionType + /// The hashCode of the value + public override int GetHashCode() + { + return this._value.GetHashCode(); + } + + /// Returns string representation for ExecutionType + /// A string for this value. + public override string ToString() + { + return this._value; + } + + /// Implicit operator to convert string to ExecutionType + /// the value to convert to an instance of . + + public static implicit operator ExecutionType(string value) + { + return new ExecutionType(value); + } + + /// Implicit operator to convert ExecutionType to string + /// the value to convert to an instance of . + + public static implicit operator string(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionType e) + { + return e._value; + } + + /// Overriding != operator for enum ExecutionType + /// the value to compare against + /// the value to compare against + /// true if the two instances are not equal to the same value + public static bool operator !=(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionType e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionType e2) + { + return !e2.Equals(e1); + } + + /// Overriding == operator for enum ExecutionType + /// the value to compare against + /// the value to compare against + /// true if the two instances are equal to the same value + public static bool operator ==(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionType e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExecutionType e2) + { + return e2.Equals(e1); + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/ExportType.Completer.cs b/src/CostManagement/generated/api/Support/ExportType.Completer.cs new file mode 100644 index 000000000000..29a514520eda --- /dev/null +++ b/src/CostManagement/generated/api/Support/ExportType.Completer.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// Argument completer implementation for ExportType. + [System.ComponentModel.TypeConverter(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportTypeTypeConverter))] + public partial struct ExportType : + System.Management.Automation.IArgumentCompleter + { + + /// + /// Implementations of this function are called by PowerShell to complete arguments. + /// + /// The name of the command that needs argument completion. + /// The name of the parameter that needs argument completion. + /// The (possibly empty) word being completed. + /// The command ast in case it is needed for completion. + /// This parameter is similar to $PSBoundParameters, except that sometimes PowerShell cannot + /// or will not attempt to evaluate an argument, in which case you may need to use commandAst. + /// + /// A collection of completion results, most like with ResultType set to ParameterValue. + /// + public global::System.Collections.Generic.IEnumerable CompleteArgument(global::System.String commandName, global::System.String parameterName, global::System.String wordToComplete, global::System.Management.Automation.Language.CommandAst commandAst, global::System.Collections.IDictionary fakeBoundParameters) + { + if (global::System.String.IsNullOrEmpty(wordToComplete) || "Usage".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("Usage", "Usage", global::System.Management.Automation.CompletionResultType.ParameterValue, "Usage"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "ActualCost".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("ActualCost", "ActualCost", global::System.Management.Automation.CompletionResultType.ParameterValue, "ActualCost"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "AmortizedCost".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("AmortizedCost", "AmortizedCost", global::System.Management.Automation.CompletionResultType.ParameterValue, "AmortizedCost"); + } + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/ExportType.TypeConverter.cs b/src/CostManagement/generated/api/Support/ExportType.TypeConverter.cs new file mode 100644 index 000000000000..c11b0fda422d --- /dev/null +++ b/src/CostManagement/generated/api/Support/ExportType.TypeConverter.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// TypeConverter implementation for ExportType. + public partial class ExportTypeTypeConverter : + global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => true; + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ExportType.CreateFrom(sourceValue); + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/ExportType.cs b/src/CostManagement/generated/api/Support/ExportType.cs new file mode 100644 index 000000000000..19c9e1d097dd --- /dev/null +++ b/src/CostManagement/generated/api/Support/ExportType.cs @@ -0,0 +1,99 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + public partial struct ExportType : + System.IEquatable + { + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType ActualCost = @"ActualCost"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType AmortizedCost = @"AmortizedCost"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType Usage = @"Usage"; + + /// the value for an instance of the Enum. + private string _value { get; set; } + + /// Conversion from arbitrary object to ExportType + /// the value to convert to an instance of . + internal static object CreateFrom(object value) + { + return new ExportType(System.Convert.ToString(value)); + } + + /// Compares values of enum type ExportType + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public bool Equals(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType e) + { + return _value.Equals(e._value); + } + + /// Compares values of enum type ExportType (override for Object) + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public override bool Equals(object obj) + { + return obj is ExportType && Equals((ExportType)obj); + } + + /// Creates an instance of the + /// the value to create an instance for. + private ExportType(string underlyingValue) + { + this._value = underlyingValue; + } + + /// Returns hashCode for enum ExportType + /// The hashCode of the value + public override int GetHashCode() + { + return this._value.GetHashCode(); + } + + /// Returns string representation for ExportType + /// A string for this value. + public override string ToString() + { + return this._value; + } + + /// Implicit operator to convert string to ExportType + /// the value to convert to an instance of . + + public static implicit operator ExportType(string value) + { + return new ExportType(value); + } + + /// Implicit operator to convert ExportType to string + /// the value to convert to an instance of . + + public static implicit operator string(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType e) + { + return e._value; + } + + /// Overriding != operator for enum ExportType + /// the value to compare against + /// the value to compare against + /// true if the two instances are not equal to the same value + public static bool operator !=(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType e2) + { + return !e2.Equals(e1); + } + + /// Overriding == operator for enum ExportType + /// the value to compare against + /// the value to compare against + /// true if the two instances are equal to the same value + public static bool operator ==(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType e2) + { + return e2.Equals(e1); + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/ExternalCloudProviderType.Completer.cs b/src/CostManagement/generated/api/Support/ExternalCloudProviderType.Completer.cs new file mode 100644 index 000000000000..fb64f7224213 --- /dev/null +++ b/src/CostManagement/generated/api/Support/ExternalCloudProviderType.Completer.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// Argument completer implementation for ExternalCloudProviderType. + [System.ComponentModel.TypeConverter(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExternalCloudProviderTypeTypeConverter))] + public partial struct ExternalCloudProviderType : + System.Management.Automation.IArgumentCompleter + { + + /// + /// Implementations of this function are called by PowerShell to complete arguments. + /// + /// The name of the command that needs argument completion. + /// The name of the parameter that needs argument completion. + /// The (possibly empty) word being completed. + /// The command ast in case it is needed for completion. + /// This parameter is similar to $PSBoundParameters, except that sometimes PowerShell cannot + /// or will not attempt to evaluate an argument, in which case you may need to use commandAst. + /// + /// A collection of completion results, most like with ResultType set to ParameterValue. + /// + public global::System.Collections.Generic.IEnumerable CompleteArgument(global::System.String commandName, global::System.String parameterName, global::System.String wordToComplete, global::System.Management.Automation.Language.CommandAst commandAst, global::System.Collections.IDictionary fakeBoundParameters) + { + if (global::System.String.IsNullOrEmpty(wordToComplete) || "externalSubscriptions".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("externalSubscriptions", "externalSubscriptions", global::System.Management.Automation.CompletionResultType.ParameterValue, "externalSubscriptions"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "externalBillingAccounts".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("externalBillingAccounts", "externalBillingAccounts", global::System.Management.Automation.CompletionResultType.ParameterValue, "externalBillingAccounts"); + } + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/ExternalCloudProviderType.TypeConverter.cs b/src/CostManagement/generated/api/Support/ExternalCloudProviderType.TypeConverter.cs new file mode 100644 index 000000000000..4f2a6615c13d --- /dev/null +++ b/src/CostManagement/generated/api/Support/ExternalCloudProviderType.TypeConverter.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// TypeConverter implementation for ExternalCloudProviderType. + public partial class ExternalCloudProviderTypeTypeConverter : + global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => true; + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ExternalCloudProviderType.CreateFrom(sourceValue); + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/ExternalCloudProviderType.cs b/src/CostManagement/generated/api/Support/ExternalCloudProviderType.cs new file mode 100644 index 000000000000..10e80f142590 --- /dev/null +++ b/src/CostManagement/generated/api/Support/ExternalCloudProviderType.cs @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + public partial struct ExternalCloudProviderType : + System.IEquatable + { + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExternalCloudProviderType ExternalBillingAccounts = @"externalBillingAccounts"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExternalCloudProviderType ExternalSubscriptions = @"externalSubscriptions"; + + /// the value for an instance of the Enum. + private string _value { get; set; } + + /// Conversion from arbitrary object to ExternalCloudProviderType + /// the value to convert to an instance of . + internal static object CreateFrom(object value) + { + return new ExternalCloudProviderType(System.Convert.ToString(value)); + } + + /// Compares values of enum type ExternalCloudProviderType + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public bool Equals(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExternalCloudProviderType e) + { + return _value.Equals(e._value); + } + + /// Compares values of enum type ExternalCloudProviderType (override for Object) + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public override bool Equals(object obj) + { + return obj is ExternalCloudProviderType && Equals((ExternalCloudProviderType)obj); + } + + /// Creates an instance of the + /// the value to create an instance for. + private ExternalCloudProviderType(string underlyingValue) + { + this._value = underlyingValue; + } + + /// Returns hashCode for enum ExternalCloudProviderType + /// The hashCode of the value + public override int GetHashCode() + { + return this._value.GetHashCode(); + } + + /// Returns string representation for ExternalCloudProviderType + /// A string for this value. + public override string ToString() + { + return this._value; + } + + /// Implicit operator to convert string to ExternalCloudProviderType + /// the value to convert to an instance of . + + public static implicit operator ExternalCloudProviderType(string value) + { + return new ExternalCloudProviderType(value); + } + + /// Implicit operator to convert ExternalCloudProviderType to string + /// the value to convert to an instance of . + + public static implicit operator string(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExternalCloudProviderType e) + { + return e._value; + } + + /// Overriding != operator for enum ExternalCloudProviderType + /// the value to compare against + /// the value to compare against + /// true if the two instances are not equal to the same value + public static bool operator !=(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExternalCloudProviderType e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExternalCloudProviderType e2) + { + return !e2.Equals(e1); + } + + /// Overriding == operator for enum ExternalCloudProviderType + /// the value to compare against + /// the value to compare against + /// true if the two instances are equal to the same value + public static bool operator ==(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExternalCloudProviderType e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExternalCloudProviderType e2) + { + return e2.Equals(e1); + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/ForecastTimeframeType.Completer.cs b/src/CostManagement/generated/api/Support/ForecastTimeframeType.Completer.cs new file mode 100644 index 000000000000..f6835ababf48 --- /dev/null +++ b/src/CostManagement/generated/api/Support/ForecastTimeframeType.Completer.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// Argument completer implementation for ForecastTimeframeType. + [System.ComponentModel.TypeConverter(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ForecastTimeframeTypeTypeConverter))] + public partial struct ForecastTimeframeType : + System.Management.Automation.IArgumentCompleter + { + + /// + /// Implementations of this function are called by PowerShell to complete arguments. + /// + /// The name of the command that needs argument completion. + /// The name of the parameter that needs argument completion. + /// The (possibly empty) word being completed. + /// The command ast in case it is needed for completion. + /// This parameter is similar to $PSBoundParameters, except that sometimes PowerShell cannot + /// or will not attempt to evaluate an argument, in which case you may need to use commandAst. + /// + /// A collection of completion results, most like with ResultType set to ParameterValue. + /// + public global::System.Collections.Generic.IEnumerable CompleteArgument(global::System.String commandName, global::System.String parameterName, global::System.String wordToComplete, global::System.Management.Automation.Language.CommandAst commandAst, global::System.Collections.IDictionary fakeBoundParameters) + { + if (global::System.String.IsNullOrEmpty(wordToComplete) || "MonthToDate".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("MonthToDate", "MonthToDate", global::System.Management.Automation.CompletionResultType.ParameterValue, "MonthToDate"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "BillingMonthToDate".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("BillingMonthToDate", "BillingMonthToDate", global::System.Management.Automation.CompletionResultType.ParameterValue, "BillingMonthToDate"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "TheLastMonth".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("TheLastMonth", "TheLastMonth", global::System.Management.Automation.CompletionResultType.ParameterValue, "TheLastMonth"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "TheLastBillingMonth".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("TheLastBillingMonth", "TheLastBillingMonth", global::System.Management.Automation.CompletionResultType.ParameterValue, "TheLastBillingMonth"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "WeekToDate".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("WeekToDate", "WeekToDate", global::System.Management.Automation.CompletionResultType.ParameterValue, "WeekToDate"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "Custom".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("Custom", "Custom", global::System.Management.Automation.CompletionResultType.ParameterValue, "Custom"); + } + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/ForecastTimeframeType.TypeConverter.cs b/src/CostManagement/generated/api/Support/ForecastTimeframeType.TypeConverter.cs new file mode 100644 index 000000000000..76eb27c1f11a --- /dev/null +++ b/src/CostManagement/generated/api/Support/ForecastTimeframeType.TypeConverter.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// TypeConverter implementation for ForecastTimeframeType. + public partial class ForecastTimeframeTypeTypeConverter : + global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => true; + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ForecastTimeframeType.CreateFrom(sourceValue); + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/ForecastTimeframeType.cs b/src/CostManagement/generated/api/Support/ForecastTimeframeType.cs new file mode 100644 index 000000000000..aa388099d6b1 --- /dev/null +++ b/src/CostManagement/generated/api/Support/ForecastTimeframeType.cs @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + public partial struct ForecastTimeframeType : + System.IEquatable + { + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ForecastTimeframeType BillingMonthToDate = @"BillingMonthToDate"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ForecastTimeframeType Custom = @"Custom"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ForecastTimeframeType MonthToDate = @"MonthToDate"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ForecastTimeframeType TheLastBillingMonth = @"TheLastBillingMonth"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ForecastTimeframeType TheLastMonth = @"TheLastMonth"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ForecastTimeframeType WeekToDate = @"WeekToDate"; + + /// the value for an instance of the Enum. + private string _value { get; set; } + + /// Conversion from arbitrary object to ForecastTimeframeType + /// the value to convert to an instance of . + internal static object CreateFrom(object value) + { + return new ForecastTimeframeType(System.Convert.ToString(value)); + } + + /// Compares values of enum type ForecastTimeframeType + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public bool Equals(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ForecastTimeframeType e) + { + return _value.Equals(e._value); + } + + /// Compares values of enum type ForecastTimeframeType (override for Object) + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public override bool Equals(object obj) + { + return obj is ForecastTimeframeType && Equals((ForecastTimeframeType)obj); + } + + /// Creates an instance of the + /// the value to create an instance for. + private ForecastTimeframeType(string underlyingValue) + { + this._value = underlyingValue; + } + + /// Returns hashCode for enum ForecastTimeframeType + /// The hashCode of the value + public override int GetHashCode() + { + return this._value.GetHashCode(); + } + + /// Returns string representation for ForecastTimeframeType + /// A string for this value. + public override string ToString() + { + return this._value; + } + + /// Implicit operator to convert string to ForecastTimeframeType + /// the value to convert to an instance of . + + public static implicit operator ForecastTimeframeType(string value) + { + return new ForecastTimeframeType(value); + } + + /// Implicit operator to convert ForecastTimeframeType to string + /// the value to convert to an instance of . + + public static implicit operator string(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ForecastTimeframeType e) + { + return e._value; + } + + /// Overriding != operator for enum ForecastTimeframeType + /// the value to compare against + /// the value to compare against + /// true if the two instances are not equal to the same value + public static bool operator !=(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ForecastTimeframeType e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ForecastTimeframeType e2) + { + return !e2.Equals(e1); + } + + /// Overriding == operator for enum ForecastTimeframeType + /// the value to compare against + /// the value to compare against + /// true if the two instances are equal to the same value + public static bool operator ==(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ForecastTimeframeType e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ForecastTimeframeType e2) + { + return e2.Equals(e1); + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/ForecastType.Completer.cs b/src/CostManagement/generated/api/Support/ForecastType.Completer.cs new file mode 100644 index 000000000000..86a1aedcd691 --- /dev/null +++ b/src/CostManagement/generated/api/Support/ForecastType.Completer.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// Argument completer implementation for ForecastType. + [System.ComponentModel.TypeConverter(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ForecastTypeTypeConverter))] + public partial struct ForecastType : + System.Management.Automation.IArgumentCompleter + { + + /// + /// Implementations of this function are called by PowerShell to complete arguments. + /// + /// The name of the command that needs argument completion. + /// The name of the parameter that needs argument completion. + /// The (possibly empty) word being completed. + /// The command ast in case it is needed for completion. + /// This parameter is similar to $PSBoundParameters, except that sometimes PowerShell cannot + /// or will not attempt to evaluate an argument, in which case you may need to use commandAst. + /// + /// A collection of completion results, most like with ResultType set to ParameterValue. + /// + public global::System.Collections.Generic.IEnumerable CompleteArgument(global::System.String commandName, global::System.String parameterName, global::System.String wordToComplete, global::System.Management.Automation.Language.CommandAst commandAst, global::System.Collections.IDictionary fakeBoundParameters) + { + if (global::System.String.IsNullOrEmpty(wordToComplete) || "Usage".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("Usage", "Usage", global::System.Management.Automation.CompletionResultType.ParameterValue, "Usage"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "ActualCost".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("ActualCost", "ActualCost", global::System.Management.Automation.CompletionResultType.ParameterValue, "ActualCost"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "AmortizedCost".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("AmortizedCost", "AmortizedCost", global::System.Management.Automation.CompletionResultType.ParameterValue, "AmortizedCost"); + } + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/ForecastType.TypeConverter.cs b/src/CostManagement/generated/api/Support/ForecastType.TypeConverter.cs new file mode 100644 index 000000000000..2e7c9e4cfb52 --- /dev/null +++ b/src/CostManagement/generated/api/Support/ForecastType.TypeConverter.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// TypeConverter implementation for ForecastType. + public partial class ForecastTypeTypeConverter : + global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => true; + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ForecastType.CreateFrom(sourceValue); + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/ForecastType.cs b/src/CostManagement/generated/api/Support/ForecastType.cs new file mode 100644 index 000000000000..b1b7b26cdb99 --- /dev/null +++ b/src/CostManagement/generated/api/Support/ForecastType.cs @@ -0,0 +1,99 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + public partial struct ForecastType : + System.IEquatable + { + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ForecastType ActualCost = @"ActualCost"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ForecastType AmortizedCost = @"AmortizedCost"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ForecastType Usage = @"Usage"; + + /// the value for an instance of the Enum. + private string _value { get; set; } + + /// Conversion from arbitrary object to ForecastType + /// the value to convert to an instance of . + internal static object CreateFrom(object value) + { + return new ForecastType(System.Convert.ToString(value)); + } + + /// Compares values of enum type ForecastType + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public bool Equals(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ForecastType e) + { + return _value.Equals(e._value); + } + + /// Compares values of enum type ForecastType (override for Object) + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public override bool Equals(object obj) + { + return obj is ForecastType && Equals((ForecastType)obj); + } + + /// Creates an instance of the + /// the value to create an instance for. + private ForecastType(string underlyingValue) + { + this._value = underlyingValue; + } + + /// Returns hashCode for enum ForecastType + /// The hashCode of the value + public override int GetHashCode() + { + return this._value.GetHashCode(); + } + + /// Returns string representation for ForecastType + /// A string for this value. + public override string ToString() + { + return this._value; + } + + /// Implicit operator to convert string to ForecastType + /// the value to convert to an instance of . + + public static implicit operator ForecastType(string value) + { + return new ForecastType(value); + } + + /// Implicit operator to convert ForecastType to string + /// the value to convert to an instance of . + + public static implicit operator string(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ForecastType e) + { + return e._value; + } + + /// Overriding != operator for enum ForecastType + /// the value to compare against + /// the value to compare against + /// true if the two instances are not equal to the same value + public static bool operator !=(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ForecastType e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ForecastType e2) + { + return !e2.Equals(e1); + } + + /// Overriding == operator for enum ForecastType + /// the value to compare against + /// the value to compare against + /// true if the two instances are equal to the same value + public static bool operator ==(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ForecastType e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ForecastType e2) + { + return e2.Equals(e1); + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/FormatType.Completer.cs b/src/CostManagement/generated/api/Support/FormatType.Completer.cs new file mode 100644 index 000000000000..53b9a2e0f626 --- /dev/null +++ b/src/CostManagement/generated/api/Support/FormatType.Completer.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// Argument completer implementation for FormatType. + [System.ComponentModel.TypeConverter(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatTypeTypeConverter))] + public partial struct FormatType : + System.Management.Automation.IArgumentCompleter + { + + /// + /// Implementations of this function are called by PowerShell to complete arguments. + /// + /// The name of the command that needs argument completion. + /// The name of the parameter that needs argument completion. + /// The (possibly empty) word being completed. + /// The command ast in case it is needed for completion. + /// This parameter is similar to $PSBoundParameters, except that sometimes PowerShell cannot + /// or will not attempt to evaluate an argument, in which case you may need to use commandAst. + /// + /// A collection of completion results, most like with ResultType set to ParameterValue. + /// + public global::System.Collections.Generic.IEnumerable CompleteArgument(global::System.String commandName, global::System.String parameterName, global::System.String wordToComplete, global::System.Management.Automation.Language.CommandAst commandAst, global::System.Collections.IDictionary fakeBoundParameters) + { + if (global::System.String.IsNullOrEmpty(wordToComplete) || "Csv".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("Csv", "Csv", global::System.Management.Automation.CompletionResultType.ParameterValue, "Csv"); + } + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/FormatType.TypeConverter.cs b/src/CostManagement/generated/api/Support/FormatType.TypeConverter.cs new file mode 100644 index 000000000000..0a49285e4219 --- /dev/null +++ b/src/CostManagement/generated/api/Support/FormatType.TypeConverter.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// TypeConverter implementation for FormatType. + public partial class FormatTypeTypeConverter : + global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => true; + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => FormatType.CreateFrom(sourceValue); + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/FormatType.cs b/src/CostManagement/generated/api/Support/FormatType.cs new file mode 100644 index 000000000000..9574392ef51d --- /dev/null +++ b/src/CostManagement/generated/api/Support/FormatType.cs @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + public partial struct FormatType : + System.IEquatable + { + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType Csv = @"Csv"; + + /// the value for an instance of the Enum. + private string _value { get; set; } + + /// Conversion from arbitrary object to FormatType + /// the value to convert to an instance of . + internal static object CreateFrom(object value) + { + return new FormatType(System.Convert.ToString(value)); + } + + /// Compares values of enum type FormatType + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public bool Equals(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType e) + { + return _value.Equals(e._value); + } + + /// Compares values of enum type FormatType (override for Object) + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public override bool Equals(object obj) + { + return obj is FormatType && Equals((FormatType)obj); + } + + /// Creates an instance of the + /// the value to create an instance for. + private FormatType(string underlyingValue) + { + this._value = underlyingValue; + } + + /// Returns hashCode for enum FormatType + /// The hashCode of the value + public override int GetHashCode() + { + return this._value.GetHashCode(); + } + + /// Returns string representation for FormatType + /// A string for this value. + public override string ToString() + { + return this._value; + } + + /// Implicit operator to convert string to FormatType + /// the value to convert to an instance of . + + public static implicit operator FormatType(string value) + { + return new FormatType(value); + } + + /// Implicit operator to convert FormatType to string + /// the value to convert to an instance of . + + public static implicit operator string(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType e) + { + return e._value; + } + + /// Overriding != operator for enum FormatType + /// the value to compare against + /// the value to compare against + /// true if the two instances are not equal to the same value + public static bool operator !=(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType e2) + { + return !e2.Equals(e1); + } + + /// Overriding == operator for enum FormatType + /// the value to compare against + /// the value to compare against + /// true if the two instances are equal to the same value + public static bool operator ==(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType e2) + { + return e2.Equals(e1); + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/GranularityType.Completer.cs b/src/CostManagement/generated/api/Support/GranularityType.Completer.cs new file mode 100644 index 000000000000..cf5065b3bd63 --- /dev/null +++ b/src/CostManagement/generated/api/Support/GranularityType.Completer.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// Argument completer implementation for GranularityType. + [System.ComponentModel.TypeConverter(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityTypeTypeConverter))] + public partial struct GranularityType : + System.Management.Automation.IArgumentCompleter + { + + /// + /// Implementations of this function are called by PowerShell to complete arguments. + /// + /// The name of the command that needs argument completion. + /// The name of the parameter that needs argument completion. + /// The (possibly empty) word being completed. + /// The command ast in case it is needed for completion. + /// This parameter is similar to $PSBoundParameters, except that sometimes PowerShell cannot + /// or will not attempt to evaluate an argument, in which case you may need to use commandAst. + /// + /// A collection of completion results, most like with ResultType set to ParameterValue. + /// + public global::System.Collections.Generic.IEnumerable CompleteArgument(global::System.String commandName, global::System.String parameterName, global::System.String wordToComplete, global::System.Management.Automation.Language.CommandAst commandAst, global::System.Collections.IDictionary fakeBoundParameters) + { + if (global::System.String.IsNullOrEmpty(wordToComplete) || "Daily".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("Daily", "Daily", global::System.Management.Automation.CompletionResultType.ParameterValue, "Daily"); + } + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/GranularityType.TypeConverter.cs b/src/CostManagement/generated/api/Support/GranularityType.TypeConverter.cs new file mode 100644 index 000000000000..ca85966b8941 --- /dev/null +++ b/src/CostManagement/generated/api/Support/GranularityType.TypeConverter.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// TypeConverter implementation for GranularityType. + public partial class GranularityTypeTypeConverter : + global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => true; + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => GranularityType.CreateFrom(sourceValue); + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/GranularityType.cs b/src/CostManagement/generated/api/Support/GranularityType.cs new file mode 100644 index 000000000000..b56bfd5b8872 --- /dev/null +++ b/src/CostManagement/generated/api/Support/GranularityType.cs @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + public partial struct GranularityType : + System.IEquatable + { + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType Daily = @"Daily"; + + /// the value for an instance of the Enum. + private string _value { get; set; } + + /// Conversion from arbitrary object to GranularityType + /// the value to convert to an instance of . + internal static object CreateFrom(object value) + { + return new GranularityType(System.Convert.ToString(value)); + } + + /// Compares values of enum type GranularityType + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public bool Equals(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType e) + { + return _value.Equals(e._value); + } + + /// Compares values of enum type GranularityType (override for Object) + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public override bool Equals(object obj) + { + return obj is GranularityType && Equals((GranularityType)obj); + } + + /// Returns hashCode for enum GranularityType + /// The hashCode of the value + public override int GetHashCode() + { + return this._value.GetHashCode(); + } + + /// Creates an instance of the + /// the value to create an instance for. + private GranularityType(string underlyingValue) + { + this._value = underlyingValue; + } + + /// Returns string representation for GranularityType + /// A string for this value. + public override string ToString() + { + return this._value; + } + + /// Implicit operator to convert string to GranularityType + /// the value to convert to an instance of . + + public static implicit operator GranularityType(string value) + { + return new GranularityType(value); + } + + /// Implicit operator to convert GranularityType to string + /// the value to convert to an instance of . + + public static implicit operator string(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType e) + { + return e._value; + } + + /// Overriding != operator for enum GranularityType + /// the value to compare against + /// the value to compare against + /// true if the two instances are not equal to the same value + public static bool operator !=(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType e2) + { + return !e2.Equals(e1); + } + + /// Overriding == operator for enum GranularityType + /// the value to compare against + /// the value to compare against + /// true if the two instances are equal to the same value + public static bool operator ==(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType e2) + { + return e2.Equals(e1); + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/KpiType.Completer.cs b/src/CostManagement/generated/api/Support/KpiType.Completer.cs new file mode 100644 index 000000000000..ebe48e0ef737 --- /dev/null +++ b/src/CostManagement/generated/api/Support/KpiType.Completer.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// Argument completer implementation for KpiType. + [System.ComponentModel.TypeConverter(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.KpiTypeTypeConverter))] + public partial struct KpiType : + System.Management.Automation.IArgumentCompleter + { + + /// + /// Implementations of this function are called by PowerShell to complete arguments. + /// + /// The name of the command that needs argument completion. + /// The name of the parameter that needs argument completion. + /// The (possibly empty) word being completed. + /// The command ast in case it is needed for completion. + /// This parameter is similar to $PSBoundParameters, except that sometimes PowerShell cannot + /// or will not attempt to evaluate an argument, in which case you may need to use commandAst. + /// + /// A collection of completion results, most like with ResultType set to ParameterValue. + /// + public global::System.Collections.Generic.IEnumerable CompleteArgument(global::System.String commandName, global::System.String parameterName, global::System.String wordToComplete, global::System.Management.Automation.Language.CommandAst commandAst, global::System.Collections.IDictionary fakeBoundParameters) + { + if (global::System.String.IsNullOrEmpty(wordToComplete) || "Forecast".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("Forecast", "Forecast", global::System.Management.Automation.CompletionResultType.ParameterValue, "Forecast"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "Budget".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("Budget", "Budget", global::System.Management.Automation.CompletionResultType.ParameterValue, "Budget"); + } + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/KpiType.TypeConverter.cs b/src/CostManagement/generated/api/Support/KpiType.TypeConverter.cs new file mode 100644 index 000000000000..0a83e8b4c610 --- /dev/null +++ b/src/CostManagement/generated/api/Support/KpiType.TypeConverter.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// TypeConverter implementation for KpiType. + public partial class KpiTypeTypeConverter : + global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => true; + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => KpiType.CreateFrom(sourceValue); + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/KpiType.cs b/src/CostManagement/generated/api/Support/KpiType.cs new file mode 100644 index 000000000000..812567cdc81e --- /dev/null +++ b/src/CostManagement/generated/api/Support/KpiType.cs @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + public partial struct KpiType : + System.IEquatable + { + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.KpiType Budget = @"Budget"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.KpiType Forecast = @"Forecast"; + + /// the value for an instance of the Enum. + private string _value { get; set; } + + /// Conversion from arbitrary object to KpiType + /// the value to convert to an instance of . + internal static object CreateFrom(object value) + { + return new KpiType(System.Convert.ToString(value)); + } + + /// Compares values of enum type KpiType + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public bool Equals(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.KpiType e) + { + return _value.Equals(e._value); + } + + /// Compares values of enum type KpiType (override for Object) + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public override bool Equals(object obj) + { + return obj is KpiType && Equals((KpiType)obj); + } + + /// Returns hashCode for enum KpiType + /// The hashCode of the value + public override int GetHashCode() + { + return this._value.GetHashCode(); + } + + /// Creates an instance of the + /// the value to create an instance for. + private KpiType(string underlyingValue) + { + this._value = underlyingValue; + } + + /// Returns string representation for KpiType + /// A string for this value. + public override string ToString() + { + return this._value; + } + + /// Implicit operator to convert string to KpiType + /// the value to convert to an instance of . + + public static implicit operator KpiType(string value) + { + return new KpiType(value); + } + + /// Implicit operator to convert KpiType to string + /// the value to convert to an instance of . + + public static implicit operator string(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.KpiType e) + { + return e._value; + } + + /// Overriding != operator for enum KpiType + /// the value to compare against + /// the value to compare against + /// true if the two instances are not equal to the same value + public static bool operator !=(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.KpiType e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.KpiType e2) + { + return !e2.Equals(e1); + } + + /// Overriding == operator for enum KpiType + /// the value to compare against + /// the value to compare against + /// true if the two instances are equal to the same value + public static bool operator ==(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.KpiType e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.KpiType e2) + { + return e2.Equals(e1); + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/MetricType.Completer.cs b/src/CostManagement/generated/api/Support/MetricType.Completer.cs new file mode 100644 index 000000000000..ac9be1edad76 --- /dev/null +++ b/src/CostManagement/generated/api/Support/MetricType.Completer.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// Argument completer implementation for MetricType. + [System.ComponentModel.TypeConverter(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.MetricTypeTypeConverter))] + public partial struct MetricType : + System.Management.Automation.IArgumentCompleter + { + + /// + /// Implementations of this function are called by PowerShell to complete arguments. + /// + /// The name of the command that needs argument completion. + /// The name of the parameter that needs argument completion. + /// The (possibly empty) word being completed. + /// The command ast in case it is needed for completion. + /// This parameter is similar to $PSBoundParameters, except that sometimes PowerShell cannot + /// or will not attempt to evaluate an argument, in which case you may need to use commandAst. + /// + /// A collection of completion results, most like with ResultType set to ParameterValue. + /// + public global::System.Collections.Generic.IEnumerable CompleteArgument(global::System.String commandName, global::System.String parameterName, global::System.String wordToComplete, global::System.Management.Automation.Language.CommandAst commandAst, global::System.Collections.IDictionary fakeBoundParameters) + { + if (global::System.String.IsNullOrEmpty(wordToComplete) || "ActualCost".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("ActualCost", "ActualCost", global::System.Management.Automation.CompletionResultType.ParameterValue, "ActualCost"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "AmortizedCost".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("AmortizedCost", "AmortizedCost", global::System.Management.Automation.CompletionResultType.ParameterValue, "AmortizedCost"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "AHUB".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("AHUB", "AHUB", global::System.Management.Automation.CompletionResultType.ParameterValue, "AHUB"); + } + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/MetricType.TypeConverter.cs b/src/CostManagement/generated/api/Support/MetricType.TypeConverter.cs new file mode 100644 index 000000000000..ea943612ccd5 --- /dev/null +++ b/src/CostManagement/generated/api/Support/MetricType.TypeConverter.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// TypeConverter implementation for MetricType. + public partial class MetricTypeTypeConverter : + global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => true; + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => MetricType.CreateFrom(sourceValue); + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/MetricType.cs b/src/CostManagement/generated/api/Support/MetricType.cs new file mode 100644 index 000000000000..cad12aea408f --- /dev/null +++ b/src/CostManagement/generated/api/Support/MetricType.cs @@ -0,0 +1,99 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + public partial struct MetricType : + System.IEquatable + { + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.MetricType ActualCost = @"ActualCost"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.MetricType Ahub = @"AHUB"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.MetricType AmortizedCost = @"AmortizedCost"; + + /// the value for an instance of the Enum. + private string _value { get; set; } + + /// Conversion from arbitrary object to MetricType + /// the value to convert to an instance of . + internal static object CreateFrom(object value) + { + return new MetricType(System.Convert.ToString(value)); + } + + /// Compares values of enum type MetricType + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public bool Equals(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.MetricType e) + { + return _value.Equals(e._value); + } + + /// Compares values of enum type MetricType (override for Object) + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public override bool Equals(object obj) + { + return obj is MetricType && Equals((MetricType)obj); + } + + /// Returns hashCode for enum MetricType + /// The hashCode of the value + public override int GetHashCode() + { + return this._value.GetHashCode(); + } + + /// Creates an instance of the + /// the value to create an instance for. + private MetricType(string underlyingValue) + { + this._value = underlyingValue; + } + + /// Returns string representation for MetricType + /// A string for this value. + public override string ToString() + { + return this._value; + } + + /// Implicit operator to convert string to MetricType + /// the value to convert to an instance of . + + public static implicit operator MetricType(string value) + { + return new MetricType(value); + } + + /// Implicit operator to convert MetricType to string + /// the value to convert to an instance of . + + public static implicit operator string(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.MetricType e) + { + return e._value; + } + + /// Overriding != operator for enum MetricType + /// the value to compare against + /// the value to compare against + /// true if the two instances are not equal to the same value + public static bool operator !=(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.MetricType e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.MetricType e2) + { + return !e2.Equals(e1); + } + + /// Overriding == operator for enum MetricType + /// the value to compare against + /// the value to compare against + /// true if the two instances are equal to the same value + public static bool operator ==(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.MetricType e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.MetricType e2) + { + return e2.Equals(e1); + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/OperatorType.Completer.cs b/src/CostManagement/generated/api/Support/OperatorType.Completer.cs new file mode 100644 index 000000000000..1091c2e3030b --- /dev/null +++ b/src/CostManagement/generated/api/Support/OperatorType.Completer.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// Argument completer implementation for OperatorType. + [System.ComponentModel.TypeConverter(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.OperatorTypeTypeConverter))] + public partial struct OperatorType : + System.Management.Automation.IArgumentCompleter + { + + /// + /// Implementations of this function are called by PowerShell to complete arguments. + /// + /// The name of the command that needs argument completion. + /// The name of the parameter that needs argument completion. + /// The (possibly empty) word being completed. + /// The command ast in case it is needed for completion. + /// This parameter is similar to $PSBoundParameters, except that sometimes PowerShell cannot + /// or will not attempt to evaluate an argument, in which case you may need to use commandAst. + /// + /// A collection of completion results, most like with ResultType set to ParameterValue. + /// + public global::System.Collections.Generic.IEnumerable CompleteArgument(global::System.String commandName, global::System.String parameterName, global::System.String wordToComplete, global::System.Management.Automation.Language.CommandAst commandAst, global::System.Collections.IDictionary fakeBoundParameters) + { + if (global::System.String.IsNullOrEmpty(wordToComplete) || "In".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("In", "In", global::System.Management.Automation.CompletionResultType.ParameterValue, "In"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "Contains".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("Contains", "Contains", global::System.Management.Automation.CompletionResultType.ParameterValue, "Contains"); + } + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/OperatorType.TypeConverter.cs b/src/CostManagement/generated/api/Support/OperatorType.TypeConverter.cs new file mode 100644 index 000000000000..1db65166a2c9 --- /dev/null +++ b/src/CostManagement/generated/api/Support/OperatorType.TypeConverter.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// TypeConverter implementation for OperatorType. + public partial class OperatorTypeTypeConverter : + global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => true; + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => OperatorType.CreateFrom(sourceValue); + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/OperatorType.cs b/src/CostManagement/generated/api/Support/OperatorType.cs new file mode 100644 index 000000000000..61523feb9208 --- /dev/null +++ b/src/CostManagement/generated/api/Support/OperatorType.cs @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + public partial struct OperatorType : + System.IEquatable + { + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.OperatorType Contains = @"Contains"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.OperatorType In = @"In"; + + /// the value for an instance of the Enum. + private string _value { get; set; } + + /// Conversion from arbitrary object to OperatorType + /// the value to convert to an instance of . + internal static object CreateFrom(object value) + { + return new OperatorType(System.Convert.ToString(value)); + } + + /// Compares values of enum type OperatorType + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public bool Equals(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.OperatorType e) + { + return _value.Equals(e._value); + } + + /// Compares values of enum type OperatorType (override for Object) + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public override bool Equals(object obj) + { + return obj is OperatorType && Equals((OperatorType)obj); + } + + /// Returns hashCode for enum OperatorType + /// The hashCode of the value + public override int GetHashCode() + { + return this._value.GetHashCode(); + } + + /// Creates an instance of the + /// the value to create an instance for. + private OperatorType(string underlyingValue) + { + this._value = underlyingValue; + } + + /// Returns string representation for OperatorType + /// A string for this value. + public override string ToString() + { + return this._value; + } + + /// Implicit operator to convert string to OperatorType + /// the value to convert to an instance of . + + public static implicit operator OperatorType(string value) + { + return new OperatorType(value); + } + + /// Implicit operator to convert OperatorType to string + /// the value to convert to an instance of . + + public static implicit operator string(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.OperatorType e) + { + return e._value; + } + + /// Overriding != operator for enum OperatorType + /// the value to compare against + /// the value to compare against + /// true if the two instances are not equal to the same value + public static bool operator !=(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.OperatorType e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.OperatorType e2) + { + return !e2.Equals(e1); + } + + /// Overriding == operator for enum OperatorType + /// the value to compare against + /// the value to compare against + /// true if the two instances are equal to the same value + public static bool operator ==(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.OperatorType e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.OperatorType e2) + { + return e2.Equals(e1); + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/PivotType.Completer.cs b/src/CostManagement/generated/api/Support/PivotType.Completer.cs new file mode 100644 index 000000000000..bd264960e480 --- /dev/null +++ b/src/CostManagement/generated/api/Support/PivotType.Completer.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// Argument completer implementation for PivotType. + [System.ComponentModel.TypeConverter(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.PivotTypeTypeConverter))] + public partial struct PivotType : + System.Management.Automation.IArgumentCompleter + { + + /// + /// Implementations of this function are called by PowerShell to complete arguments. + /// + /// The name of the command that needs argument completion. + /// The name of the parameter that needs argument completion. + /// The (possibly empty) word being completed. + /// The command ast in case it is needed for completion. + /// This parameter is similar to $PSBoundParameters, except that sometimes PowerShell cannot + /// or will not attempt to evaluate an argument, in which case you may need to use commandAst. + /// + /// A collection of completion results, most like with ResultType set to ParameterValue. + /// + public global::System.Collections.Generic.IEnumerable CompleteArgument(global::System.String commandName, global::System.String parameterName, global::System.String wordToComplete, global::System.Management.Automation.Language.CommandAst commandAst, global::System.Collections.IDictionary fakeBoundParameters) + { + if (global::System.String.IsNullOrEmpty(wordToComplete) || "Dimension".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("Dimension", "Dimension", global::System.Management.Automation.CompletionResultType.ParameterValue, "Dimension"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "TagKey".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("TagKey", "TagKey", global::System.Management.Automation.CompletionResultType.ParameterValue, "TagKey"); + } + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/PivotType.TypeConverter.cs b/src/CostManagement/generated/api/Support/PivotType.TypeConverter.cs new file mode 100644 index 000000000000..a3399ba4e89f --- /dev/null +++ b/src/CostManagement/generated/api/Support/PivotType.TypeConverter.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// TypeConverter implementation for PivotType. + public partial class PivotTypeTypeConverter : + global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => true; + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => PivotType.CreateFrom(sourceValue); + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/PivotType.cs b/src/CostManagement/generated/api/Support/PivotType.cs new file mode 100644 index 000000000000..ed1741363ecf --- /dev/null +++ b/src/CostManagement/generated/api/Support/PivotType.cs @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + public partial struct PivotType : + System.IEquatable + { + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.PivotType Dimension = @"Dimension"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.PivotType TagKey = @"TagKey"; + + /// the value for an instance of the Enum. + private string _value { get; set; } + + /// Conversion from arbitrary object to PivotType + /// the value to convert to an instance of . + internal static object CreateFrom(object value) + { + return new PivotType(System.Convert.ToString(value)); + } + + /// Compares values of enum type PivotType + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public bool Equals(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.PivotType e) + { + return _value.Equals(e._value); + } + + /// Compares values of enum type PivotType (override for Object) + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public override bool Equals(object obj) + { + return obj is PivotType && Equals((PivotType)obj); + } + + /// Returns hashCode for enum PivotType + /// The hashCode of the value + public override int GetHashCode() + { + return this._value.GetHashCode(); + } + + /// Creates an instance of the + /// the value to create an instance for. + private PivotType(string underlyingValue) + { + this._value = underlyingValue; + } + + /// Returns string representation for PivotType + /// A string for this value. + public override string ToString() + { + return this._value; + } + + /// Implicit operator to convert string to PivotType + /// the value to convert to an instance of . + + public static implicit operator PivotType(string value) + { + return new PivotType(value); + } + + /// Implicit operator to convert PivotType to string + /// the value to convert to an instance of . + + public static implicit operator string(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.PivotType e) + { + return e._value; + } + + /// Overriding != operator for enum PivotType + /// the value to compare against + /// the value to compare against + /// true if the two instances are not equal to the same value + public static bool operator !=(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.PivotType e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.PivotType e2) + { + return !e2.Equals(e1); + } + + /// Overriding == operator for enum PivotType + /// the value to compare against + /// the value to compare against + /// true if the two instances are equal to the same value + public static bool operator ==(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.PivotType e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.PivotType e2) + { + return e2.Equals(e1); + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/QueryColumnType.Completer.cs b/src/CostManagement/generated/api/Support/QueryColumnType.Completer.cs new file mode 100644 index 000000000000..1d0d6d8e3017 --- /dev/null +++ b/src/CostManagement/generated/api/Support/QueryColumnType.Completer.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// Argument completer implementation for QueryColumnType. + [System.ComponentModel.TypeConverter(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.QueryColumnTypeTypeConverter))] + public partial struct QueryColumnType : + System.Management.Automation.IArgumentCompleter + { + + /// + /// Implementations of this function are called by PowerShell to complete arguments. + /// + /// The name of the command that needs argument completion. + /// The name of the parameter that needs argument completion. + /// The (possibly empty) word being completed. + /// The command ast in case it is needed for completion. + /// This parameter is similar to $PSBoundParameters, except that sometimes PowerShell cannot + /// or will not attempt to evaluate an argument, in which case you may need to use commandAst. + /// + /// A collection of completion results, most like with ResultType set to ParameterValue. + /// + public global::System.Collections.Generic.IEnumerable CompleteArgument(global::System.String commandName, global::System.String parameterName, global::System.String wordToComplete, global::System.Management.Automation.Language.CommandAst commandAst, global::System.Collections.IDictionary fakeBoundParameters) + { + if (global::System.String.IsNullOrEmpty(wordToComplete) || "Tag".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("Tag", "Tag", global::System.Management.Automation.CompletionResultType.ParameterValue, "Tag"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "Dimension".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("Dimension", "Dimension", global::System.Management.Automation.CompletionResultType.ParameterValue, "Dimension"); + } + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/QueryColumnType.TypeConverter.cs b/src/CostManagement/generated/api/Support/QueryColumnType.TypeConverter.cs new file mode 100644 index 000000000000..b36fb3fac76a --- /dev/null +++ b/src/CostManagement/generated/api/Support/QueryColumnType.TypeConverter.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// TypeConverter implementation for QueryColumnType. + public partial class QueryColumnTypeTypeConverter : + global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => true; + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => QueryColumnType.CreateFrom(sourceValue); + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/QueryColumnType.cs b/src/CostManagement/generated/api/Support/QueryColumnType.cs new file mode 100644 index 000000000000..8fb676dac4f8 --- /dev/null +++ b/src/CostManagement/generated/api/Support/QueryColumnType.cs @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + public partial struct QueryColumnType : + System.IEquatable + { + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.QueryColumnType Dimension = @"Dimension"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.QueryColumnType Tag = @"Tag"; + + /// the value for an instance of the Enum. + private string _value { get; set; } + + /// Conversion from arbitrary object to QueryColumnType + /// the value to convert to an instance of . + internal static object CreateFrom(object value) + { + return new QueryColumnType(System.Convert.ToString(value)); + } + + /// Compares values of enum type QueryColumnType + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public bool Equals(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.QueryColumnType e) + { + return _value.Equals(e._value); + } + + /// Compares values of enum type QueryColumnType (override for Object) + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public override bool Equals(object obj) + { + return obj is QueryColumnType && Equals((QueryColumnType)obj); + } + + /// Returns hashCode for enum QueryColumnType + /// The hashCode of the value + public override int GetHashCode() + { + return this._value.GetHashCode(); + } + + /// Creates an instance of the + /// the value to create an instance for. + private QueryColumnType(string underlyingValue) + { + this._value = underlyingValue; + } + + /// Returns string representation for QueryColumnType + /// A string for this value. + public override string ToString() + { + return this._value; + } + + /// Implicit operator to convert string to QueryColumnType + /// the value to convert to an instance of . + + public static implicit operator QueryColumnType(string value) + { + return new QueryColumnType(value); + } + + /// Implicit operator to convert QueryColumnType to string + /// the value to convert to an instance of . + + public static implicit operator string(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.QueryColumnType e) + { + return e._value; + } + + /// Overriding != operator for enum QueryColumnType + /// the value to compare against + /// the value to compare against + /// true if the two instances are not equal to the same value + public static bool operator !=(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.QueryColumnType e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.QueryColumnType e2) + { + return !e2.Equals(e1); + } + + /// Overriding == operator for enum QueryColumnType + /// the value to compare against + /// the value to compare against + /// true if the two instances are equal to the same value + public static bool operator ==(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.QueryColumnType e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.QueryColumnType e2) + { + return e2.Equals(e1); + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/RecurrenceType.Completer.cs b/src/CostManagement/generated/api/Support/RecurrenceType.Completer.cs new file mode 100644 index 000000000000..3117e18b638d --- /dev/null +++ b/src/CostManagement/generated/api/Support/RecurrenceType.Completer.cs @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// Argument completer implementation for RecurrenceType. + [System.ComponentModel.TypeConverter(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceTypeTypeConverter))] + public partial struct RecurrenceType : + System.Management.Automation.IArgumentCompleter + { + + /// + /// Implementations of this function are called by PowerShell to complete arguments. + /// + /// The name of the command that needs argument completion. + /// The name of the parameter that needs argument completion. + /// The (possibly empty) word being completed. + /// The command ast in case it is needed for completion. + /// This parameter is similar to $PSBoundParameters, except that sometimes PowerShell cannot + /// or will not attempt to evaluate an argument, in which case you may need to use commandAst. + /// + /// A collection of completion results, most like with ResultType set to ParameterValue. + /// + public global::System.Collections.Generic.IEnumerable CompleteArgument(global::System.String commandName, global::System.String parameterName, global::System.String wordToComplete, global::System.Management.Automation.Language.CommandAst commandAst, global::System.Collections.IDictionary fakeBoundParameters) + { + if (global::System.String.IsNullOrEmpty(wordToComplete) || "Daily".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("Daily", "Daily", global::System.Management.Automation.CompletionResultType.ParameterValue, "Daily"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "Weekly".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("Weekly", "Weekly", global::System.Management.Automation.CompletionResultType.ParameterValue, "Weekly"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "Monthly".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("Monthly", "Monthly", global::System.Management.Automation.CompletionResultType.ParameterValue, "Monthly"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "Annually".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("Annually", "Annually", global::System.Management.Automation.CompletionResultType.ParameterValue, "Annually"); + } + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/RecurrenceType.TypeConverter.cs b/src/CostManagement/generated/api/Support/RecurrenceType.TypeConverter.cs new file mode 100644 index 000000000000..794b5cde7692 --- /dev/null +++ b/src/CostManagement/generated/api/Support/RecurrenceType.TypeConverter.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// TypeConverter implementation for RecurrenceType. + public partial class RecurrenceTypeTypeConverter : + global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => true; + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => RecurrenceType.CreateFrom(sourceValue); + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/RecurrenceType.cs b/src/CostManagement/generated/api/Support/RecurrenceType.cs new file mode 100644 index 000000000000..264e9b332cb7 --- /dev/null +++ b/src/CostManagement/generated/api/Support/RecurrenceType.cs @@ -0,0 +1,101 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + public partial struct RecurrenceType : + System.IEquatable + { + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType Annually = @"Annually"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType Daily = @"Daily"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType Monthly = @"Monthly"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType Weekly = @"Weekly"; + + /// the value for an instance of the Enum. + private string _value { get; set; } + + /// Conversion from arbitrary object to RecurrenceType + /// the value to convert to an instance of . + internal static object CreateFrom(object value) + { + return new RecurrenceType(System.Convert.ToString(value)); + } + + /// Compares values of enum type RecurrenceType + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public bool Equals(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType e) + { + return _value.Equals(e._value); + } + + /// Compares values of enum type RecurrenceType (override for Object) + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public override bool Equals(object obj) + { + return obj is RecurrenceType && Equals((RecurrenceType)obj); + } + + /// Returns hashCode for enum RecurrenceType + /// The hashCode of the value + public override int GetHashCode() + { + return this._value.GetHashCode(); + } + + /// Creates an instance of the + /// the value to create an instance for. + private RecurrenceType(string underlyingValue) + { + this._value = underlyingValue; + } + + /// Returns string representation for RecurrenceType + /// A string for this value. + public override string ToString() + { + return this._value; + } + + /// Implicit operator to convert string to RecurrenceType + /// the value to convert to an instance of . + + public static implicit operator RecurrenceType(string value) + { + return new RecurrenceType(value); + } + + /// Implicit operator to convert RecurrenceType to string + /// the value to convert to an instance of . + + public static implicit operator string(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType e) + { + return e._value; + } + + /// Overriding != operator for enum RecurrenceType + /// the value to compare against + /// the value to compare against + /// true if the two instances are not equal to the same value + public static bool operator !=(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType e2) + { + return !e2.Equals(e1); + } + + /// Overriding == operator for enum RecurrenceType + /// the value to compare against + /// the value to compare against + /// true if the two instances are equal to the same value + public static bool operator ==(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType e2) + { + return e2.Equals(e1); + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/ReportConfigColumnType.Completer.cs b/src/CostManagement/generated/api/Support/ReportConfigColumnType.Completer.cs new file mode 100644 index 000000000000..696cc82bd125 --- /dev/null +++ b/src/CostManagement/generated/api/Support/ReportConfigColumnType.Completer.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// Argument completer implementation for ReportConfigColumnType. + [System.ComponentModel.TypeConverter(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportConfigColumnTypeTypeConverter))] + public partial struct ReportConfigColumnType : + System.Management.Automation.IArgumentCompleter + { + + /// + /// Implementations of this function are called by PowerShell to complete arguments. + /// + /// The name of the command that needs argument completion. + /// The name of the parameter that needs argument completion. + /// The (possibly empty) word being completed. + /// The command ast in case it is needed for completion. + /// This parameter is similar to $PSBoundParameters, except that sometimes PowerShell cannot + /// or will not attempt to evaluate an argument, in which case you may need to use commandAst. + /// + /// A collection of completion results, most like with ResultType set to ParameterValue. + /// + public global::System.Collections.Generic.IEnumerable CompleteArgument(global::System.String commandName, global::System.String parameterName, global::System.String wordToComplete, global::System.Management.Automation.Language.CommandAst commandAst, global::System.Collections.IDictionary fakeBoundParameters) + { + if (global::System.String.IsNullOrEmpty(wordToComplete) || "Tag".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("Tag", "Tag", global::System.Management.Automation.CompletionResultType.ParameterValue, "Tag"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "Dimension".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("Dimension", "Dimension", global::System.Management.Automation.CompletionResultType.ParameterValue, "Dimension"); + } + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/ReportConfigColumnType.TypeConverter.cs b/src/CostManagement/generated/api/Support/ReportConfigColumnType.TypeConverter.cs new file mode 100644 index 000000000000..98a3e25b1c54 --- /dev/null +++ b/src/CostManagement/generated/api/Support/ReportConfigColumnType.TypeConverter.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// TypeConverter implementation for ReportConfigColumnType. + public partial class ReportConfigColumnTypeTypeConverter : + global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => true; + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ReportConfigColumnType.CreateFrom(sourceValue); + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/ReportConfigColumnType.cs b/src/CostManagement/generated/api/Support/ReportConfigColumnType.cs new file mode 100644 index 000000000000..5bd4d2038e16 --- /dev/null +++ b/src/CostManagement/generated/api/Support/ReportConfigColumnType.cs @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + public partial struct ReportConfigColumnType : + System.IEquatable + { + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportConfigColumnType Dimension = @"Dimension"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportConfigColumnType Tag = @"Tag"; + + /// the value for an instance of the Enum. + private string _value { get; set; } + + /// Conversion from arbitrary object to ReportConfigColumnType + /// the value to convert to an instance of . + internal static object CreateFrom(object value) + { + return new ReportConfigColumnType(System.Convert.ToString(value)); + } + + /// Compares values of enum type ReportConfigColumnType + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public bool Equals(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportConfigColumnType e) + { + return _value.Equals(e._value); + } + + /// Compares values of enum type ReportConfigColumnType (override for Object) + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public override bool Equals(object obj) + { + return obj is ReportConfigColumnType && Equals((ReportConfigColumnType)obj); + } + + /// Returns hashCode for enum ReportConfigColumnType + /// The hashCode of the value + public override int GetHashCode() + { + return this._value.GetHashCode(); + } + + /// Creates an instance of the + /// the value to create an instance for. + private ReportConfigColumnType(string underlyingValue) + { + this._value = underlyingValue; + } + + /// Returns string representation for ReportConfigColumnType + /// A string for this value. + public override string ToString() + { + return this._value; + } + + /// Implicit operator to convert string to ReportConfigColumnType + /// the value to convert to an instance of . + + public static implicit operator ReportConfigColumnType(string value) + { + return new ReportConfigColumnType(value); + } + + /// Implicit operator to convert ReportConfigColumnType to string + /// the value to convert to an instance of . + + public static implicit operator string(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportConfigColumnType e) + { + return e._value; + } + + /// Overriding != operator for enum ReportConfigColumnType + /// the value to compare against + /// the value to compare against + /// true if the two instances are not equal to the same value + public static bool operator !=(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportConfigColumnType e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportConfigColumnType e2) + { + return !e2.Equals(e1); + } + + /// Overriding == operator for enum ReportConfigColumnType + /// the value to compare against + /// the value to compare against + /// true if the two instances are equal to the same value + public static bool operator ==(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportConfigColumnType e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportConfigColumnType e2) + { + return e2.Equals(e1); + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/ReportGranularityType.Completer.cs b/src/CostManagement/generated/api/Support/ReportGranularityType.Completer.cs new file mode 100644 index 000000000000..5a47d8d13502 --- /dev/null +++ b/src/CostManagement/generated/api/Support/ReportGranularityType.Completer.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// Argument completer implementation for ReportGranularityType. + [System.ComponentModel.TypeConverter(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityTypeTypeConverter))] + public partial struct ReportGranularityType : + System.Management.Automation.IArgumentCompleter + { + + /// + /// Implementations of this function are called by PowerShell to complete arguments. + /// + /// The name of the command that needs argument completion. + /// The name of the parameter that needs argument completion. + /// The (possibly empty) word being completed. + /// The command ast in case it is needed for completion. + /// This parameter is similar to $PSBoundParameters, except that sometimes PowerShell cannot + /// or will not attempt to evaluate an argument, in which case you may need to use commandAst. + /// + /// A collection of completion results, most like with ResultType set to ParameterValue. + /// + public global::System.Collections.Generic.IEnumerable CompleteArgument(global::System.String commandName, global::System.String parameterName, global::System.String wordToComplete, global::System.Management.Automation.Language.CommandAst commandAst, global::System.Collections.IDictionary fakeBoundParameters) + { + if (global::System.String.IsNullOrEmpty(wordToComplete) || "Daily".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("Daily", "Daily", global::System.Management.Automation.CompletionResultType.ParameterValue, "Daily"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "Monthly".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("Monthly", "Monthly", global::System.Management.Automation.CompletionResultType.ParameterValue, "Monthly"); + } + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/ReportGranularityType.TypeConverter.cs b/src/CostManagement/generated/api/Support/ReportGranularityType.TypeConverter.cs new file mode 100644 index 000000000000..dcd38c319b36 --- /dev/null +++ b/src/CostManagement/generated/api/Support/ReportGranularityType.TypeConverter.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// TypeConverter implementation for ReportGranularityType. + public partial class ReportGranularityTypeTypeConverter : + global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => true; + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ReportGranularityType.CreateFrom(sourceValue); + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/ReportGranularityType.cs b/src/CostManagement/generated/api/Support/ReportGranularityType.cs new file mode 100644 index 000000000000..95bae4e605ad --- /dev/null +++ b/src/CostManagement/generated/api/Support/ReportGranularityType.cs @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + public partial struct ReportGranularityType : + System.IEquatable + { + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType Daily = @"Daily"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType Monthly = @"Monthly"; + + /// the value for an instance of the Enum. + private string _value { get; set; } + + /// Conversion from arbitrary object to ReportGranularityType + /// the value to convert to an instance of . + internal static object CreateFrom(object value) + { + return new ReportGranularityType(System.Convert.ToString(value)); + } + + /// Compares values of enum type ReportGranularityType + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public bool Equals(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType e) + { + return _value.Equals(e._value); + } + + /// Compares values of enum type ReportGranularityType (override for Object) + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public override bool Equals(object obj) + { + return obj is ReportGranularityType && Equals((ReportGranularityType)obj); + } + + /// Returns hashCode for enum ReportGranularityType + /// The hashCode of the value + public override int GetHashCode() + { + return this._value.GetHashCode(); + } + + /// Creates an instance of the + /// the value to create an instance for. + private ReportGranularityType(string underlyingValue) + { + this._value = underlyingValue; + } + + /// Returns string representation for ReportGranularityType + /// A string for this value. + public override string ToString() + { + return this._value; + } + + /// Implicit operator to convert string to ReportGranularityType + /// the value to convert to an instance of . + + public static implicit operator ReportGranularityType(string value) + { + return new ReportGranularityType(value); + } + + /// Implicit operator to convert ReportGranularityType to string + /// the value to convert to an instance of . + + public static implicit operator string(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType e) + { + return e._value; + } + + /// Overriding != operator for enum ReportGranularityType + /// the value to compare against + /// the value to compare against + /// true if the two instances are not equal to the same value + public static bool operator !=(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType e2) + { + return !e2.Equals(e1); + } + + /// Overriding == operator for enum ReportGranularityType + /// the value to compare against + /// the value to compare against + /// true if the two instances are equal to the same value + public static bool operator ==(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportGranularityType e2) + { + return e2.Equals(e1); + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/ReportTimeframeType.Completer.cs b/src/CostManagement/generated/api/Support/ReportTimeframeType.Completer.cs new file mode 100644 index 000000000000..ebb3809a0941 --- /dev/null +++ b/src/CostManagement/generated/api/Support/ReportTimeframeType.Completer.cs @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// Argument completer implementation for ReportTimeframeType. + [System.ComponentModel.TypeConverter(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportTimeframeTypeTypeConverter))] + public partial struct ReportTimeframeType : + System.Management.Automation.IArgumentCompleter + { + + /// + /// Implementations of this function are called by PowerShell to complete arguments. + /// + /// The name of the command that needs argument completion. + /// The name of the parameter that needs argument completion. + /// The (possibly empty) word being completed. + /// The command ast in case it is needed for completion. + /// This parameter is similar to $PSBoundParameters, except that sometimes PowerShell cannot + /// or will not attempt to evaluate an argument, in which case you may need to use commandAst. + /// + /// A collection of completion results, most like with ResultType set to ParameterValue. + /// + public global::System.Collections.Generic.IEnumerable CompleteArgument(global::System.String commandName, global::System.String parameterName, global::System.String wordToComplete, global::System.Management.Automation.Language.CommandAst commandAst, global::System.Collections.IDictionary fakeBoundParameters) + { + if (global::System.String.IsNullOrEmpty(wordToComplete) || "WeekToDate".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("WeekToDate", "WeekToDate", global::System.Management.Automation.CompletionResultType.ParameterValue, "WeekToDate"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "MonthToDate".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("MonthToDate", "MonthToDate", global::System.Management.Automation.CompletionResultType.ParameterValue, "MonthToDate"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "YearToDate".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("YearToDate", "YearToDate", global::System.Management.Automation.CompletionResultType.ParameterValue, "YearToDate"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "Custom".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("Custom", "Custom", global::System.Management.Automation.CompletionResultType.ParameterValue, "Custom"); + } + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/ReportTimeframeType.TypeConverter.cs b/src/CostManagement/generated/api/Support/ReportTimeframeType.TypeConverter.cs new file mode 100644 index 000000000000..485db00a705f --- /dev/null +++ b/src/CostManagement/generated/api/Support/ReportTimeframeType.TypeConverter.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// TypeConverter implementation for ReportTimeframeType. + public partial class ReportTimeframeTypeTypeConverter : + global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => true; + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ReportTimeframeType.CreateFrom(sourceValue); + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/ReportTimeframeType.cs b/src/CostManagement/generated/api/Support/ReportTimeframeType.cs new file mode 100644 index 000000000000..b0a91f15e074 --- /dev/null +++ b/src/CostManagement/generated/api/Support/ReportTimeframeType.cs @@ -0,0 +1,101 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + public partial struct ReportTimeframeType : + System.IEquatable + { + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportTimeframeType Custom = @"Custom"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportTimeframeType MonthToDate = @"MonthToDate"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportTimeframeType WeekToDate = @"WeekToDate"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportTimeframeType YearToDate = @"YearToDate"; + + /// the value for an instance of the Enum. + private string _value { get; set; } + + /// Conversion from arbitrary object to ReportTimeframeType + /// the value to convert to an instance of . + internal static object CreateFrom(object value) + { + return new ReportTimeframeType(System.Convert.ToString(value)); + } + + /// Compares values of enum type ReportTimeframeType + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public bool Equals(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportTimeframeType e) + { + return _value.Equals(e._value); + } + + /// Compares values of enum type ReportTimeframeType (override for Object) + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public override bool Equals(object obj) + { + return obj is ReportTimeframeType && Equals((ReportTimeframeType)obj); + } + + /// Returns hashCode for enum ReportTimeframeType + /// The hashCode of the value + public override int GetHashCode() + { + return this._value.GetHashCode(); + } + + /// Creates an instance of the + /// the value to create an instance for. + private ReportTimeframeType(string underlyingValue) + { + this._value = underlyingValue; + } + + /// Returns string representation for ReportTimeframeType + /// A string for this value. + public override string ToString() + { + return this._value; + } + + /// Implicit operator to convert string to ReportTimeframeType + /// the value to convert to an instance of . + + public static implicit operator ReportTimeframeType(string value) + { + return new ReportTimeframeType(value); + } + + /// Implicit operator to convert ReportTimeframeType to string + /// the value to convert to an instance of . + + public static implicit operator string(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportTimeframeType e) + { + return e._value; + } + + /// Overriding != operator for enum ReportTimeframeType + /// the value to compare against + /// the value to compare against + /// true if the two instances are not equal to the same value + public static bool operator !=(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportTimeframeType e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportTimeframeType e2) + { + return !e2.Equals(e1); + } + + /// Overriding == operator for enum ReportTimeframeType + /// the value to compare against + /// the value to compare against + /// true if the two instances are equal to the same value + public static bool operator ==(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportTimeframeType e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ReportTimeframeType e2) + { + return e2.Equals(e1); + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/StatusType.Completer.cs b/src/CostManagement/generated/api/Support/StatusType.Completer.cs new file mode 100644 index 000000000000..a2d1e3884e39 --- /dev/null +++ b/src/CostManagement/generated/api/Support/StatusType.Completer.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// Argument completer implementation for StatusType. + [System.ComponentModel.TypeConverter(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusTypeTypeConverter))] + public partial struct StatusType : + System.Management.Automation.IArgumentCompleter + { + + /// + /// Implementations of this function are called by PowerShell to complete arguments. + /// + /// The name of the command that needs argument completion. + /// The name of the parameter that needs argument completion. + /// The (possibly empty) word being completed. + /// The command ast in case it is needed for completion. + /// This parameter is similar to $PSBoundParameters, except that sometimes PowerShell cannot + /// or will not attempt to evaluate an argument, in which case you may need to use commandAst. + /// + /// A collection of completion results, most like with ResultType set to ParameterValue. + /// + public global::System.Collections.Generic.IEnumerable CompleteArgument(global::System.String commandName, global::System.String parameterName, global::System.String wordToComplete, global::System.Management.Automation.Language.CommandAst commandAst, global::System.Collections.IDictionary fakeBoundParameters) + { + if (global::System.String.IsNullOrEmpty(wordToComplete) || "Active".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("Active", "Active", global::System.Management.Automation.CompletionResultType.ParameterValue, "Active"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "Inactive".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("Inactive", "Inactive", global::System.Management.Automation.CompletionResultType.ParameterValue, "Inactive"); + } + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/StatusType.TypeConverter.cs b/src/CostManagement/generated/api/Support/StatusType.TypeConverter.cs new file mode 100644 index 000000000000..5befd15bc61b --- /dev/null +++ b/src/CostManagement/generated/api/Support/StatusType.TypeConverter.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// TypeConverter implementation for StatusType. + public partial class StatusTypeTypeConverter : + global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => true; + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => StatusType.CreateFrom(sourceValue); + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/StatusType.cs b/src/CostManagement/generated/api/Support/StatusType.cs new file mode 100644 index 000000000000..c047fa32f53e --- /dev/null +++ b/src/CostManagement/generated/api/Support/StatusType.cs @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + public partial struct StatusType : + System.IEquatable + { + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType Active = @"Active"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType Inactive = @"Inactive"; + + /// the value for an instance of the Enum. + private string _value { get; set; } + + /// Conversion from arbitrary object to StatusType + /// the value to convert to an instance of . + internal static object CreateFrom(object value) + { + return new StatusType(System.Convert.ToString(value)); + } + + /// Compares values of enum type StatusType + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public bool Equals(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType e) + { + return _value.Equals(e._value); + } + + /// Compares values of enum type StatusType (override for Object) + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public override bool Equals(object obj) + { + return obj is StatusType && Equals((StatusType)obj); + } + + /// Returns hashCode for enum StatusType + /// The hashCode of the value + public override int GetHashCode() + { + return this._value.GetHashCode(); + } + + /// Creates an instance of the + /// the value to create an instance for. + private StatusType(string underlyingValue) + { + this._value = underlyingValue; + } + + /// Returns string representation for StatusType + /// A string for this value. + public override string ToString() + { + return this._value; + } + + /// Implicit operator to convert string to StatusType + /// the value to convert to an instance of . + + public static implicit operator StatusType(string value) + { + return new StatusType(value); + } + + /// Implicit operator to convert StatusType to string + /// the value to convert to an instance of . + + public static implicit operator string(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType e) + { + return e._value; + } + + /// Overriding != operator for enum StatusType + /// the value to compare against + /// the value to compare against + /// true if the two instances are not equal to the same value + public static bool operator !=(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType e2) + { + return !e2.Equals(e1); + } + + /// Overriding == operator for enum StatusType + /// the value to compare against + /// the value to compare against + /// true if the two instances are equal to the same value + public static bool operator ==(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType e2) + { + return e2.Equals(e1); + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/TimeframeType.Completer.cs b/src/CostManagement/generated/api/Support/TimeframeType.Completer.cs new file mode 100644 index 000000000000..cb7c78026da9 --- /dev/null +++ b/src/CostManagement/generated/api/Support/TimeframeType.Completer.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// Argument completer implementation for TimeframeType. + [System.ComponentModel.TypeConverter(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeTypeTypeConverter))] + public partial struct TimeframeType : + System.Management.Automation.IArgumentCompleter + { + + /// + /// Implementations of this function are called by PowerShell to complete arguments. + /// + /// The name of the command that needs argument completion. + /// The name of the parameter that needs argument completion. + /// The (possibly empty) word being completed. + /// The command ast in case it is needed for completion. + /// This parameter is similar to $PSBoundParameters, except that sometimes PowerShell cannot + /// or will not attempt to evaluate an argument, in which case you may need to use commandAst. + /// + /// A collection of completion results, most like with ResultType set to ParameterValue. + /// + public global::System.Collections.Generic.IEnumerable CompleteArgument(global::System.String commandName, global::System.String parameterName, global::System.String wordToComplete, global::System.Management.Automation.Language.CommandAst commandAst, global::System.Collections.IDictionary fakeBoundParameters) + { + if (global::System.String.IsNullOrEmpty(wordToComplete) || "MonthToDate".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("MonthToDate", "MonthToDate", global::System.Management.Automation.CompletionResultType.ParameterValue, "MonthToDate"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "BillingMonthToDate".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("BillingMonthToDate", "BillingMonthToDate", global::System.Management.Automation.CompletionResultType.ParameterValue, "BillingMonthToDate"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "TheLastMonth".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("TheLastMonth", "TheLastMonth", global::System.Management.Automation.CompletionResultType.ParameterValue, "TheLastMonth"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "TheLastBillingMonth".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("TheLastBillingMonth", "TheLastBillingMonth", global::System.Management.Automation.CompletionResultType.ParameterValue, "TheLastBillingMonth"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "WeekToDate".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("WeekToDate", "WeekToDate", global::System.Management.Automation.CompletionResultType.ParameterValue, "WeekToDate"); + } + if (global::System.String.IsNullOrEmpty(wordToComplete) || "Custom".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) + { + yield return new global::System.Management.Automation.CompletionResult("Custom", "Custom", global::System.Management.Automation.CompletionResultType.ParameterValue, "Custom"); + } + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/TimeframeType.TypeConverter.cs b/src/CostManagement/generated/api/Support/TimeframeType.TypeConverter.cs new file mode 100644 index 000000000000..6dabab4f452e --- /dev/null +++ b/src/CostManagement/generated/api/Support/TimeframeType.TypeConverter.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + /// TypeConverter implementation for TimeframeType. + public partial class TimeframeTypeTypeConverter : + global::System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => true; + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => TimeframeType.CreateFrom(sourceValue); + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/api/Support/TimeframeType.cs b/src/CostManagement/generated/api/Support/TimeframeType.cs new file mode 100644 index 000000000000..3526cce1d523 --- /dev/null +++ b/src/CostManagement/generated/api/Support/TimeframeType.cs @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support +{ + + public partial struct TimeframeType : + System.IEquatable + { + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType BillingMonthToDate = @"BillingMonthToDate"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType Custom = @"Custom"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType MonthToDate = @"MonthToDate"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType TheLastBillingMonth = @"TheLastBillingMonth"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType TheLastMonth = @"TheLastMonth"; + + public static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType WeekToDate = @"WeekToDate"; + + /// the value for an instance of the Enum. + private string _value { get; set; } + + /// Conversion from arbitrary object to TimeframeType + /// the value to convert to an instance of . + internal static object CreateFrom(object value) + { + return new TimeframeType(System.Convert.ToString(value)); + } + + /// Compares values of enum type TimeframeType + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public bool Equals(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType e) + { + return _value.Equals(e._value); + } + + /// Compares values of enum type TimeframeType (override for Object) + /// the value to compare against this instance. + /// true if the two instances are equal to the same value + public override bool Equals(object obj) + { + return obj is TimeframeType && Equals((TimeframeType)obj); + } + + /// Returns hashCode for enum TimeframeType + /// The hashCode of the value + public override int GetHashCode() + { + return this._value.GetHashCode(); + } + + /// Creates an instance of the + /// the value to create an instance for. + private TimeframeType(string underlyingValue) + { + this._value = underlyingValue; + } + + /// Returns string representation for TimeframeType + /// A string for this value. + public override string ToString() + { + return this._value; + } + + /// Implicit operator to convert string to TimeframeType + /// the value to convert to an instance of . + + public static implicit operator TimeframeType(string value) + { + return new TimeframeType(value); + } + + /// Implicit operator to convert TimeframeType to string + /// the value to convert to an instance of . + + public static implicit operator string(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType e) + { + return e._value; + } + + /// Overriding != operator for enum TimeframeType + /// the value to compare against + /// the value to compare against + /// true if the two instances are not equal to the same value + public static bool operator !=(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType e2) + { + return !e2.Equals(e1); + } + + /// Overriding == operator for enum TimeframeType + /// the value to compare against + /// the value to compare against + /// true if the two instances are equal to the same value + public static bool operator ==(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType e1, Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType e2) + { + return e2.Equals(e1); + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/cmdlets/GetAzCostManagementExportExecutionHistory_Get.cs b/src/CostManagement/generated/cmdlets/GetAzCostManagementExportExecutionHistory_Get.cs new file mode 100644 index 000000000000..2f726f8b094b --- /dev/null +++ b/src/CostManagement/generated/cmdlets/GetAzCostManagementExportExecutionHistory_Get.cs @@ -0,0 +1,383 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Cmdlets +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// + /// The operation to get the execution history of an export for the defined scope and export name. + /// + /// + /// [OpenAPI] Exports_GetExecutionHistory=>GET:"/{scope}/providers/Microsoft.CostManagement/exports/{exportName}/runHistory" + /// + [global::System.Management.Automation.Cmdlet(global::System.Management.Automation.VerbsCommon.Get, @"AzCostManagementExportExecutionHistory_Get")] + [global::System.Management.Automation.OutputType(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution))] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Description(@"The operation to get the execution history of an export for the defined scope and export name.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Generated] + public partial class GetAzCostManagementExportExecutionHistory_Get : global::System.Management.Automation.PSCmdlet, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener + { + /// A unique id generatd for the this cmdlet when it is instantiated. + private string __correlationId = System.Guid.NewGuid().ToString(); + + /// A copy of the Invocation Info (necessary to allow asJob to clone this cmdlet) + private global::System.Management.Automation.InvocationInfo __invocationInfo; + + /// A unique id generatd for the this cmdlet when ProcessRecord() is called. + private string __processRecordId; + + /// + /// The for this operation. + /// + private global::System.Threading.CancellationTokenSource _cancellationTokenSource = new global::System.Threading.CancellationTokenSource(); + + /// Wait for .NET debugger to attach + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Wait for .NET debugger to attach")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter Break { get; set; } + + /// The reference to the client API class. + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.CostManagement Client => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Module.Instance.ClientAPI; + + /// + /// The credentials, account, tenant, and subscription used for communication with Azure + /// + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The credentials, account, tenant, and subscription used for communication with Azure.")] + [global::System.Management.Automation.ValidateNotNull] + [global::System.Management.Automation.Alias("AzureRMContext", "AzureCredential")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Azure)] + public global::System.Management.Automation.PSObject DefaultProfile { get; set; } + + /// Backing field for property. + private string _exportName; + + /// Export Name. + [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "Export Name.")] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"Export Name.", + SerializedName = @"exportName", + PossibleTypes = new [] { typeof(string) })] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Path)] + public string ExportName { get => this._exportName; set => this._exportName = value; } + + /// SendAsync Pipeline Steps to be appended to the front of the pipeline + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be appended to the front of the pipeline")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[] HttpPipelineAppend { get; set; } + + /// SendAsync Pipeline Steps to be prepended to the front of the pipeline + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be prepended to the front of the pipeline")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[] HttpPipelinePrepend { get; set; } + + /// Accessor for our copy of the InvocationInfo. + public global::System.Management.Automation.InvocationInfo InvocationInformation { get => __invocationInfo = __invocationInfo ?? this.MyInvocation ; set { __invocationInfo = value; } } + + /// + /// cancellation delegate. Stops the cmdlet when called. + /// + global::System.Action Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener.Cancel => _cancellationTokenSource.Cancel; + + /// cancellation token. + global::System.Threading.CancellationToken Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener.Token => _cancellationTokenSource.Token; + + /// + /// The instance of the that the remote call will use. + /// + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.HttpPipeline Pipeline { get; set; } + + /// The URI for the proxy server to use + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "The URI for the proxy server to use")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Uri Proxy { get; set; } + + /// Credentials for a proxy server to use for the remote call + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Credentials for a proxy server to use for the remote call")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Management.Automation.PSCredential ProxyCredential { get; set; } + + /// Use the default credentials for the proxy + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Use the default credentials for the proxy")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter ProxyUseDefaultCredentials { get; set; } + + /// Backing field for property. + private string _scope; + + /// + /// This parameter defines the scope of costmanagement from different perspectives 'Subscription','ResourceGroup' and 'Provide + /// Service'. + /// + [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "This parameter defines the scope of costmanagement from different perspectives 'Subscription','ResourceGroup' and 'Provide Service'.")] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"This parameter defines the scope of costmanagement from different perspectives 'Subscription','ResourceGroup' and 'Provide Service'.", + SerializedName = @"scope", + PossibleTypes = new [] { typeof(string) })] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Path)] + public string Scope { get => this._scope; set => this._scope = value; } + + /// + /// overrideOnDefault will be called before the regular onDefault has been processed, allowing customization of what + /// happens on that response. Implement this method in a partial class to enable this behavior + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a from the remote call + /// /// Determines if the rest of the onDefault method should be processed, or if the method should + /// return immediately (set to true to skip further processing ) + + partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + + /// + /// overrideOnOk will be called before the regular onOk has been processed, allowing customization of what happens + /// on that response. Implement this method in a partial class to enable this behavior + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a from the remote call + /// /// Determines if the rest of the onOk method should be processed, or if the method should return + /// immediately (set to true to skip further processing ) + + partial void overrideOnOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + + /// + /// (overrides the default BeginProcessing method in global::System.Management.Automation.PSCmdlet) + /// + protected override void BeginProcessing() + { + Module.Instance.SetProxyConfiguration(Proxy, ProxyCredential, ProxyUseDefaultCredentials); + if (Break) + { + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.AttachDebugger.Break(); + } + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletBeginProcessing).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + + /// Performs clean-up after the command execution + protected override void EndProcessing() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletEndProcessing).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + + /// + /// Intializes a new instance of the cmdlet class. + /// + public GetAzCostManagementExportExecutionHistory_Get() + { + + } + + /// Handles/Dispatches events during the call to the REST service. + /// The message id + /// The message cancellation token. When this call is cancelled, this should be true + /// Detailed message data for the message event. + /// + /// A that will be complete when handling of the message is completed. + /// + async global::System.Threading.Tasks.Task Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener.Signal(string id, global::System.Threading.CancellationToken token, global::System.Func messageData) + { + using( NoSynchronizationContext ) + { + if (token.IsCancellationRequested) + { + return ; + } + + switch ( id ) + { + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Verbose: + { + WriteVerbose($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Warning: + { + WriteWarning($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Information: + { + var data = messageData(); + WriteInformation(data, new[] { data.Message }); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Debug: + { + WriteDebug($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Error: + { + WriteError(new global::System.Management.Automation.ErrorRecord( new global::System.Exception(messageData().Message), string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null ) ); + return ; + } + } + await Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Module.Instance.Signal(id, token, messageData, (i,t,m) => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(i,t,()=> Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.EventDataConverter.ConvertFrom( m() ) as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.EventData ), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); + if (token.IsCancellationRequested) + { + return ; + } + WriteDebug($"{id}: {(messageData().Message ?? global::System.String.Empty)}"); + } + } + + /// Performs execution of the command. + protected override void ProcessRecord() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordStart).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + __processRecordId = System.Guid.NewGuid().ToString(); + try + { + // work + using( var asyncCommandRuntime = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.AsyncCommandRuntime(this, ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token) ) + { + asyncCommandRuntime.Wait( ProcessRecordAsync(),((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token); + } + } + catch (global::System.AggregateException aggregateException) + { + // unroll the inner exceptions to get the root cause + foreach( var innerException in aggregateException.Flatten().InnerExceptions ) + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletException, $"{innerException.GetType().Name} - {innerException.Message} : {innerException.StackTrace}").Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + // Write exception out to error channel. + WriteError( new global::System.Management.Automation.ErrorRecord(innerException,string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null) ); + } + } + catch (global::System.Exception exception) when ((exception as System.Management.Automation.PipelineStoppedException)== null || (exception as System.Management.Automation.PipelineStoppedException).InnerException != null) + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletException, $"{exception.GetType().Name} - {exception.Message} : {exception.StackTrace}").Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + // Write exception out to error channel. + WriteError( new global::System.Management.Automation.ErrorRecord(exception,string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null) ); + } + finally + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordEnd).Wait(); + } + } + + /// Performs execution of the command, working asynchronously if required. + /// + /// A that will be complete when handling of the method is completed. + /// + protected async global::System.Threading.Tasks.Task ProcessRecordAsync() + { + using( NoSynchronizationContext ) + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordAsyncStart); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletGetPipeline); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName); + if (null != HttpPipelinePrepend) + { + Pipeline.Prepend((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelinePrepend) ?? HttpPipelinePrepend); + } + if (null != HttpPipelineAppend) + { + Pipeline.Append((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelineAppend) ?? HttpPipelineAppend); + } + // get the client instance + try + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletBeforeAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + await this.Client.ExportsGetExecutionHistory(Scope, ExportName, onOk, onDefault, this, Pipeline); + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletAfterAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + catch (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.UndeclaredResponseException urexception) + { + WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { Scope=Scope,ExportName=ExportName}) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(urexception.Message) { RecommendedAction = urexception.Action } + }); + } + finally + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordAsyncEnd); + } + } + } + + /// Interrupts currently running code within the command. + protected override void StopProcessing() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Cancel(); + base.StopProcessing(); + } + + /// + /// a delegate that is called when the remote service returns default (any response code not handled elsewhere). + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a from the remote call + /// + /// A that will be complete when handling of the method is completed. + /// + private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + { + using( NoSynchronizationContext ) + { + var _returnNow = global::System.Threading.Tasks.Task.FromResult(false); + overrideOnDefault(responseMessage, response, ref _returnNow); + // if overrideOnDefault has returned true, then return right away. + if ((null != _returnNow && await _returnNow)) + { + return ; + } + // Error Response : default + var code = (await response)?.Code; + var message = (await response)?.Message; + if ((null == code || null == message)) + { + // Unrecognized Response. Create an error record based on what we have. + var ex = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.RestException(responseMessage, await response); + WriteError( new global::System.Management.Automation.ErrorRecord(ex, ex.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { Scope=Scope, ExportName=ExportName }) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(ex.Message) { RecommendedAction = ex.Action } + }); + } + else + { + WriteError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception($"[{code}] : {message}"), code?.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { Scope=Scope, ExportName=ExportName }) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(message) { RecommendedAction = global::System.String.Empty } + }); + } + } + } + + /// a delegate that is called when the remote service returns 200 (OK). + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a from the remote call + /// + /// A that will be complete when handling of the method is completed. + /// + private async global::System.Threading.Tasks.Task onOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + { + using( NoSynchronizationContext ) + { + var _returnNow = global::System.Threading.Tasks.Task.FromResult(false); + overrideOnOk(responseMessage, response, ref _returnNow); + // if overrideOnOk has returned true, then return right away. + if ((null != _returnNow && await _returnNow)) + { + return ; + } + // onOk - response for 200 / application/json + // response should be returning an array of some kind. +Pageable + // nested-array / value / + WriteObject((await response).Value, true); + } + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/cmdlets/GetAzCostManagementExportExecutionHistory_GetViaIdentity.cs b/src/CostManagement/generated/cmdlets/GetAzCostManagementExportExecutionHistory_GetViaIdentity.cs new file mode 100644 index 000000000000..9803d23f80d7 --- /dev/null +++ b/src/CostManagement/generated/cmdlets/GetAzCostManagementExportExecutionHistory_GetViaIdentity.cs @@ -0,0 +1,376 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Cmdlets +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// + /// The operation to get the execution history of an export for the defined scope and export name. + /// + /// + /// [OpenAPI] Exports_GetExecutionHistory=>GET:"/{scope}/providers/Microsoft.CostManagement/exports/{exportName}/runHistory" + /// + [global::System.Management.Automation.Cmdlet(global::System.Management.Automation.VerbsCommon.Get, @"AzCostManagementExportExecutionHistory_GetViaIdentity")] + [global::System.Management.Automation.OutputType(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution))] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Description(@"The operation to get the execution history of an export for the defined scope and export name.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Generated] + public partial class GetAzCostManagementExportExecutionHistory_GetViaIdentity : global::System.Management.Automation.PSCmdlet, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener + { + /// A unique id generatd for the this cmdlet when it is instantiated. + private string __correlationId = System.Guid.NewGuid().ToString(); + + /// A copy of the Invocation Info (necessary to allow asJob to clone this cmdlet) + private global::System.Management.Automation.InvocationInfo __invocationInfo; + + /// A unique id generatd for the this cmdlet when ProcessRecord() is called. + private string __processRecordId; + + /// + /// The for this operation. + /// + private global::System.Threading.CancellationTokenSource _cancellationTokenSource = new global::System.Threading.CancellationTokenSource(); + + /// Wait for .NET debugger to attach + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Wait for .NET debugger to attach")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter Break { get; set; } + + /// The reference to the client API class. + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.CostManagement Client => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Module.Instance.ClientAPI; + + /// + /// The credentials, account, tenant, and subscription used for communication with Azure + /// + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The credentials, account, tenant, and subscription used for communication with Azure.")] + [global::System.Management.Automation.ValidateNotNull] + [global::System.Management.Automation.Alias("AzureRMContext", "AzureCredential")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Azure)] + public global::System.Management.Automation.PSObject DefaultProfile { get; set; } + + /// SendAsync Pipeline Steps to be appended to the front of the pipeline + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be appended to the front of the pipeline")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[] HttpPipelineAppend { get; set; } + + /// SendAsync Pipeline Steps to be prepended to the front of the pipeline + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be prepended to the front of the pipeline")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[] HttpPipelinePrepend { get; set; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity _inputObject; + + /// Identity Parameter + [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "Identity Parameter", ValueFromPipeline = true)] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Path)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity InputObject { get => this._inputObject; set => this._inputObject = value; } + + /// Accessor for our copy of the InvocationInfo. + public global::System.Management.Automation.InvocationInfo InvocationInformation { get => __invocationInfo = __invocationInfo ?? this.MyInvocation ; set { __invocationInfo = value; } } + + /// + /// cancellation delegate. Stops the cmdlet when called. + /// + global::System.Action Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener.Cancel => _cancellationTokenSource.Cancel; + + /// cancellation token. + global::System.Threading.CancellationToken Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener.Token => _cancellationTokenSource.Token; + + /// + /// The instance of the that the remote call will use. + /// + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.HttpPipeline Pipeline { get; set; } + + /// The URI for the proxy server to use + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "The URI for the proxy server to use")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Uri Proxy { get; set; } + + /// Credentials for a proxy server to use for the remote call + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Credentials for a proxy server to use for the remote call")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Management.Automation.PSCredential ProxyCredential { get; set; } + + /// Use the default credentials for the proxy + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Use the default credentials for the proxy")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter ProxyUseDefaultCredentials { get; set; } + + /// + /// overrideOnDefault will be called before the regular onDefault has been processed, allowing customization of what + /// happens on that response. Implement this method in a partial class to enable this behavior + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a from the remote call + /// /// Determines if the rest of the onDefault method should be processed, or if the method should + /// return immediately (set to true to skip further processing ) + + partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + + /// + /// overrideOnOk will be called before the regular onOk has been processed, allowing customization of what happens + /// on that response. Implement this method in a partial class to enable this behavior + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a from the remote call + /// /// Determines if the rest of the onOk method should be processed, or if the method should return + /// immediately (set to true to skip further processing ) + + partial void overrideOnOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + + /// + /// (overrides the default BeginProcessing method in global::System.Management.Automation.PSCmdlet) + /// + protected override void BeginProcessing() + { + Module.Instance.SetProxyConfiguration(Proxy, ProxyCredential, ProxyUseDefaultCredentials); + if (Break) + { + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.AttachDebugger.Break(); + } + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletBeginProcessing).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + + /// Performs clean-up after the command execution + protected override void EndProcessing() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletEndProcessing).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + + /// + /// Intializes a new instance of the cmdlet class. + /// + public GetAzCostManagementExportExecutionHistory_GetViaIdentity() + { + + } + + /// Handles/Dispatches events during the call to the REST service. + /// The message id + /// The message cancellation token. When this call is cancelled, this should be true + /// Detailed message data for the message event. + /// + /// A that will be complete when handling of the message is completed. + /// + async global::System.Threading.Tasks.Task Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener.Signal(string id, global::System.Threading.CancellationToken token, global::System.Func messageData) + { + using( NoSynchronizationContext ) + { + if (token.IsCancellationRequested) + { + return ; + } + + switch ( id ) + { + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Verbose: + { + WriteVerbose($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Warning: + { + WriteWarning($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Information: + { + var data = messageData(); + WriteInformation(data, new[] { data.Message }); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Debug: + { + WriteDebug($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Error: + { + WriteError(new global::System.Management.Automation.ErrorRecord( new global::System.Exception(messageData().Message), string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null ) ); + return ; + } + } + await Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Module.Instance.Signal(id, token, messageData, (i,t,m) => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(i,t,()=> Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.EventDataConverter.ConvertFrom( m() ) as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.EventData ), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); + if (token.IsCancellationRequested) + { + return ; + } + WriteDebug($"{id}: {(messageData().Message ?? global::System.String.Empty)}"); + } + } + + /// Performs execution of the command. + protected override void ProcessRecord() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordStart).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + __processRecordId = System.Guid.NewGuid().ToString(); + try + { + // work + using( var asyncCommandRuntime = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.AsyncCommandRuntime(this, ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token) ) + { + asyncCommandRuntime.Wait( ProcessRecordAsync(),((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token); + } + } + catch (global::System.AggregateException aggregateException) + { + // unroll the inner exceptions to get the root cause + foreach( var innerException in aggregateException.Flatten().InnerExceptions ) + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletException, $"{innerException.GetType().Name} - {innerException.Message} : {innerException.StackTrace}").Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + // Write exception out to error channel. + WriteError( new global::System.Management.Automation.ErrorRecord(innerException,string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null) ); + } + } + catch (global::System.Exception exception) when ((exception as System.Management.Automation.PipelineStoppedException)== null || (exception as System.Management.Automation.PipelineStoppedException).InnerException != null) + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletException, $"{exception.GetType().Name} - {exception.Message} : {exception.StackTrace}").Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + // Write exception out to error channel. + WriteError( new global::System.Management.Automation.ErrorRecord(exception,string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null) ); + } + finally + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordEnd).Wait(); + } + } + + /// Performs execution of the command, working asynchronously if required. + /// + /// A that will be complete when handling of the method is completed. + /// + protected async global::System.Threading.Tasks.Task ProcessRecordAsync() + { + using( NoSynchronizationContext ) + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordAsyncStart); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletGetPipeline); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName); + if (null != HttpPipelinePrepend) + { + Pipeline.Prepend((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelinePrepend) ?? HttpPipelinePrepend); + } + if (null != HttpPipelineAppend) + { + Pipeline.Append((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelineAppend) ?? HttpPipelineAppend); + } + // get the client instance + try + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletBeforeAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + if (InputObject?.Id != null) + { + await this.Client.ExportsGetExecutionHistoryViaIdentity(InputObject.Id, onOk, onDefault, this, Pipeline); + } + else + { + // try to call with PATH parameters from Input Object + if (null == InputObject.Scope) + { + ThrowTerminatingError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception("InputObject has null value for InputObject.Scope"),string.Empty, global::System.Management.Automation.ErrorCategory.InvalidArgument, InputObject) ); + } + if (null == InputObject.ExportName) + { + ThrowTerminatingError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception("InputObject has null value for InputObject.ExportName"),string.Empty, global::System.Management.Automation.ErrorCategory.InvalidArgument, InputObject) ); + } + await this.Client.ExportsGetExecutionHistory(InputObject.Scope ?? null, InputObject.ExportName ?? null, onOk, onDefault, this, Pipeline); + } + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletAfterAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + catch (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.UndeclaredResponseException urexception) + { + WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(urexception.Message) { RecommendedAction = urexception.Action } + }); + } + finally + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordAsyncEnd); + } + } + } + + /// Interrupts currently running code within the command. + protected override void StopProcessing() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Cancel(); + base.StopProcessing(); + } + + /// + /// a delegate that is called when the remote service returns default (any response code not handled elsewhere). + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a from the remote call + /// + /// A that will be complete when handling of the method is completed. + /// + private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + { + using( NoSynchronizationContext ) + { + var _returnNow = global::System.Threading.Tasks.Task.FromResult(false); + overrideOnDefault(responseMessage, response, ref _returnNow); + // if overrideOnDefault has returned true, then return right away. + if ((null != _returnNow && await _returnNow)) + { + return ; + } + // Error Response : default + var code = (await response)?.Code; + var message = (await response)?.Message; + if ((null == code || null == message)) + { + // Unrecognized Response. Create an error record based on what we have. + var ex = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.RestException(responseMessage, await response); + WriteError( new global::System.Management.Automation.ErrorRecord(ex, ex.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(ex.Message) { RecommendedAction = ex.Action } + }); + } + else + { + WriteError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception($"[{code}] : {message}"), code?.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(message) { RecommendedAction = global::System.String.Empty } + }); + } + } + } + + /// a delegate that is called when the remote service returns 200 (OK). + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a from the remote call + /// + /// A that will be complete when handling of the method is completed. + /// + private async global::System.Threading.Tasks.Task onOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + { + using( NoSynchronizationContext ) + { + var _returnNow = global::System.Threading.Tasks.Task.FromResult(false); + overrideOnOk(responseMessage, response, ref _returnNow); + // if overrideOnOk has returned true, then return right away. + if ((null != _returnNow && await _returnNow)) + { + return ; + } + // onOk - response for 200 / application/json + // response should be returning an array of some kind. +Pageable + // nested-array / value / + WriteObject((await response).Value, true); + } + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/cmdlets/GetAzCostManagementExport_Get.cs b/src/CostManagement/generated/cmdlets/GetAzCostManagementExport_Get.cs new file mode 100644 index 000000000000..2d58fd9ee31c --- /dev/null +++ b/src/CostManagement/generated/cmdlets/GetAzCostManagementExport_Get.cs @@ -0,0 +1,398 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Cmdlets +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The operation to get the export for the defined scope by export name. + /// + /// [OpenAPI] Exports_Get=>GET:"/{scope}/providers/Microsoft.CostManagement/exports/{exportName}" + /// + [global::System.Management.Automation.Cmdlet(global::System.Management.Automation.VerbsCommon.Get, @"AzCostManagementExport_Get")] + [global::System.Management.Automation.OutputType(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport))] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Description(@"The operation to get the export for the defined scope by export name.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Generated] + public partial class GetAzCostManagementExport_Get : global::System.Management.Automation.PSCmdlet, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener + { + /// A unique id generatd for the this cmdlet when it is instantiated. + private string __correlationId = System.Guid.NewGuid().ToString(); + + /// A copy of the Invocation Info (necessary to allow asJob to clone this cmdlet) + private global::System.Management.Automation.InvocationInfo __invocationInfo; + + /// A unique id generatd for the this cmdlet when ProcessRecord() is called. + private string __processRecordId; + + /// + /// The for this operation. + /// + private global::System.Threading.CancellationTokenSource _cancellationTokenSource = new global::System.Threading.CancellationTokenSource(); + + /// Wait for .NET debugger to attach + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Wait for .NET debugger to attach")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter Break { get; set; } + + /// The reference to the client API class. + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.CostManagement Client => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Module.Instance.ClientAPI; + + /// + /// The credentials, account, tenant, and subscription used for communication with Azure + /// + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The credentials, account, tenant, and subscription used for communication with Azure.")] + [global::System.Management.Automation.ValidateNotNull] + [global::System.Management.Automation.Alias("AzureRMContext", "AzureCredential")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Azure)] + public global::System.Management.Automation.PSObject DefaultProfile { get; set; } + + /// Backing field for property. + private string _expand; + + /// + /// May be used to expand the properties within an export. Currently only 'runHistory' is supported and will return information + /// for the last 10 executions of the export. + /// + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "May be used to expand the properties within an export. Currently only 'runHistory' is supported and will return information for the last 10 executions of the export.")] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"May be used to expand the properties within an export. Currently only 'runHistory' is supported and will return information for the last 10 executions of the export.", + SerializedName = @"$expand", + PossibleTypes = new [] { typeof(string) })] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Query)] + public string Expand { get => this._expand; set => this._expand = value; } + + /// SendAsync Pipeline Steps to be appended to the front of the pipeline + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be appended to the front of the pipeline")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[] HttpPipelineAppend { get; set; } + + /// SendAsync Pipeline Steps to be prepended to the front of the pipeline + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be prepended to the front of the pipeline")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[] HttpPipelinePrepend { get; set; } + + /// Accessor for our copy of the InvocationInfo. + public global::System.Management.Automation.InvocationInfo InvocationInformation { get => __invocationInfo = __invocationInfo ?? this.MyInvocation ; set { __invocationInfo = value; } } + + /// + /// cancellation delegate. Stops the cmdlet when called. + /// + global::System.Action Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener.Cancel => _cancellationTokenSource.Cancel; + + /// cancellation token. + global::System.Threading.CancellationToken Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener.Token => _cancellationTokenSource.Token; + + /// Backing field for property. + private string _name; + + /// Export Name. + [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "Export Name.")] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"Export Name.", + SerializedName = @"exportName", + PossibleTypes = new [] { typeof(string) })] + [global::System.Management.Automation.Alias("ExportName")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Path)] + public string Name { get => this._name; set => this._name = value; } + + /// + /// The instance of the that the remote call will use. + /// + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.HttpPipeline Pipeline { get; set; } + + /// The URI for the proxy server to use + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "The URI for the proxy server to use")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Uri Proxy { get; set; } + + /// Credentials for a proxy server to use for the remote call + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Credentials for a proxy server to use for the remote call")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Management.Automation.PSCredential ProxyCredential { get; set; } + + /// Use the default credentials for the proxy + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Use the default credentials for the proxy")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter ProxyUseDefaultCredentials { get; set; } + + /// Backing field for property. + private string _scope; + + /// + /// This parameter defines the scope of costmanagement from different perspectives 'Subscription','ResourceGroup' and 'Provide + /// Service'. + /// + [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "This parameter defines the scope of costmanagement from different perspectives 'Subscription','ResourceGroup' and 'Provide Service'.")] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"This parameter defines the scope of costmanagement from different perspectives 'Subscription','ResourceGroup' and 'Provide Service'.", + SerializedName = @"scope", + PossibleTypes = new [] { typeof(string) })] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Path)] + public string Scope { get => this._scope; set => this._scope = value; } + + /// + /// overrideOnDefault will be called before the regular onDefault has been processed, allowing customization of what + /// happens on that response. Implement this method in a partial class to enable this behavior + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a from the remote call + /// /// Determines if the rest of the onDefault method should be processed, or if the method should + /// return immediately (set to true to skip further processing ) + + partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + + /// + /// overrideOnOk will be called before the regular onOk has been processed, allowing customization of what happens + /// on that response. Implement this method in a partial class to enable this behavior + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a from the remote call + /// /// Determines if the rest of the onOk method should be processed, or if the method should return + /// immediately (set to true to skip further processing ) + + partial void overrideOnOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + + /// + /// (overrides the default BeginProcessing method in global::System.Management.Automation.PSCmdlet) + /// + protected override void BeginProcessing() + { + Module.Instance.SetProxyConfiguration(Proxy, ProxyCredential, ProxyUseDefaultCredentials); + if (Break) + { + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.AttachDebugger.Break(); + } + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletBeginProcessing).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + + /// Performs clean-up after the command execution + protected override void EndProcessing() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletEndProcessing).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + + /// + /// Intializes a new instance of the cmdlet class. + /// + public GetAzCostManagementExport_Get() + { + + } + + /// Handles/Dispatches events during the call to the REST service. + /// The message id + /// The message cancellation token. When this call is cancelled, this should be true + /// Detailed message data for the message event. + /// + /// A that will be complete when handling of the message is completed. + /// + async global::System.Threading.Tasks.Task Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener.Signal(string id, global::System.Threading.CancellationToken token, global::System.Func messageData) + { + using( NoSynchronizationContext ) + { + if (token.IsCancellationRequested) + { + return ; + } + + switch ( id ) + { + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Verbose: + { + WriteVerbose($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Warning: + { + WriteWarning($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Information: + { + var data = messageData(); + WriteInformation(data, new[] { data.Message }); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Debug: + { + WriteDebug($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Error: + { + WriteError(new global::System.Management.Automation.ErrorRecord( new global::System.Exception(messageData().Message), string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null ) ); + return ; + } + } + await Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Module.Instance.Signal(id, token, messageData, (i,t,m) => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(i,t,()=> Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.EventDataConverter.ConvertFrom( m() ) as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.EventData ), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); + if (token.IsCancellationRequested) + { + return ; + } + WriteDebug($"{id}: {(messageData().Message ?? global::System.String.Empty)}"); + } + } + + /// Performs execution of the command. + protected override void ProcessRecord() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordStart).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + __processRecordId = System.Guid.NewGuid().ToString(); + try + { + // work + using( var asyncCommandRuntime = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.AsyncCommandRuntime(this, ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token) ) + { + asyncCommandRuntime.Wait( ProcessRecordAsync(),((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token); + } + } + catch (global::System.AggregateException aggregateException) + { + // unroll the inner exceptions to get the root cause + foreach( var innerException in aggregateException.Flatten().InnerExceptions ) + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletException, $"{innerException.GetType().Name} - {innerException.Message} : {innerException.StackTrace}").Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + // Write exception out to error channel. + WriteError( new global::System.Management.Automation.ErrorRecord(innerException,string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null) ); + } + } + catch (global::System.Exception exception) when ((exception as System.Management.Automation.PipelineStoppedException)== null || (exception as System.Management.Automation.PipelineStoppedException).InnerException != null) + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletException, $"{exception.GetType().Name} - {exception.Message} : {exception.StackTrace}").Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + // Write exception out to error channel. + WriteError( new global::System.Management.Automation.ErrorRecord(exception,string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null) ); + } + finally + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordEnd).Wait(); + } + } + + /// Performs execution of the command, working asynchronously if required. + /// + /// A that will be complete when handling of the method is completed. + /// + protected async global::System.Threading.Tasks.Task ProcessRecordAsync() + { + using( NoSynchronizationContext ) + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordAsyncStart); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletGetPipeline); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName); + if (null != HttpPipelinePrepend) + { + Pipeline.Prepend((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelinePrepend) ?? HttpPipelinePrepend); + } + if (null != HttpPipelineAppend) + { + Pipeline.Append((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelineAppend) ?? HttpPipelineAppend); + } + // get the client instance + try + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletBeforeAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + await this.Client.ExportsGet(Scope, Name, this.InvocationInformation.BoundParameters.ContainsKey("Expand") ? Expand : null, onOk, onDefault, this, Pipeline); + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletAfterAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + catch (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.UndeclaredResponseException urexception) + { + WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { Scope=Scope,Name=Name,Expand=this.InvocationInformation.BoundParameters.ContainsKey("Expand") ? Expand : null}) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(urexception.Message) { RecommendedAction = urexception.Action } + }); + } + finally + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordAsyncEnd); + } + } + } + + /// Interrupts currently running code within the command. + protected override void StopProcessing() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Cancel(); + base.StopProcessing(); + } + + /// + /// a delegate that is called when the remote service returns default (any response code not handled elsewhere). + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a from the remote call + /// + /// A that will be complete when handling of the method is completed. + /// + private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + { + using( NoSynchronizationContext ) + { + var _returnNow = global::System.Threading.Tasks.Task.FromResult(false); + overrideOnDefault(responseMessage, response, ref _returnNow); + // if overrideOnDefault has returned true, then return right away. + if ((null != _returnNow && await _returnNow)) + { + return ; + } + // Error Response : default + var code = (await response)?.Code; + var message = (await response)?.Message; + if ((null == code || null == message)) + { + // Unrecognized Response. Create an error record based on what we have. + var ex = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.RestException(responseMessage, await response); + WriteError( new global::System.Management.Automation.ErrorRecord(ex, ex.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { Scope=Scope, Name=Name, Expand=this.InvocationInformation.BoundParameters.ContainsKey("Expand") ? Expand : null }) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(ex.Message) { RecommendedAction = ex.Action } + }); + } + else + { + WriteError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception($"[{code}] : {message}"), code?.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { Scope=Scope, Name=Name, Expand=this.InvocationInformation.BoundParameters.ContainsKey("Expand") ? Expand : null }) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(message) { RecommendedAction = global::System.String.Empty } + }); + } + } + } + + /// a delegate that is called when the remote service returns 200 (OK). + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a from the remote call + /// + /// A that will be complete when handling of the method is completed. + /// + private async global::System.Threading.Tasks.Task onOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + { + using( NoSynchronizationContext ) + { + var _returnNow = global::System.Threading.Tasks.Task.FromResult(false); + overrideOnOk(responseMessage, response, ref _returnNow); + // if overrideOnOk has returned true, then return right away. + if ((null != _returnNow && await _returnNow)) + { + return ; + } + // onOk - response for 200 / application/json + // (await response) // should be Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport + WriteObject((await response)); + } + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/cmdlets/GetAzCostManagementExport_GetViaIdentity.cs b/src/CostManagement/generated/cmdlets/GetAzCostManagementExport_GetViaIdentity.cs new file mode 100644 index 000000000000..fd9416e355b1 --- /dev/null +++ b/src/CostManagement/generated/cmdlets/GetAzCostManagementExport_GetViaIdentity.cs @@ -0,0 +1,390 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Cmdlets +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The operation to get the export for the defined scope by export name. + /// + /// [OpenAPI] Exports_Get=>GET:"/{scope}/providers/Microsoft.CostManagement/exports/{exportName}" + /// + [global::System.Management.Automation.Cmdlet(global::System.Management.Automation.VerbsCommon.Get, @"AzCostManagementExport_GetViaIdentity")] + [global::System.Management.Automation.OutputType(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport))] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Description(@"The operation to get the export for the defined scope by export name.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Generated] + public partial class GetAzCostManagementExport_GetViaIdentity : global::System.Management.Automation.PSCmdlet, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener + { + /// A unique id generatd for the this cmdlet when it is instantiated. + private string __correlationId = System.Guid.NewGuid().ToString(); + + /// A copy of the Invocation Info (necessary to allow asJob to clone this cmdlet) + private global::System.Management.Automation.InvocationInfo __invocationInfo; + + /// A unique id generatd for the this cmdlet when ProcessRecord() is called. + private string __processRecordId; + + /// + /// The for this operation. + /// + private global::System.Threading.CancellationTokenSource _cancellationTokenSource = new global::System.Threading.CancellationTokenSource(); + + /// Wait for .NET debugger to attach + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Wait for .NET debugger to attach")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter Break { get; set; } + + /// The reference to the client API class. + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.CostManagement Client => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Module.Instance.ClientAPI; + + /// + /// The credentials, account, tenant, and subscription used for communication with Azure + /// + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The credentials, account, tenant, and subscription used for communication with Azure.")] + [global::System.Management.Automation.ValidateNotNull] + [global::System.Management.Automation.Alias("AzureRMContext", "AzureCredential")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Azure)] + public global::System.Management.Automation.PSObject DefaultProfile { get; set; } + + /// Backing field for property. + private string _expand; + + /// + /// May be used to expand the properties within an export. Currently only 'runHistory' is supported and will return information + /// for the last 10 executions of the export. + /// + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "May be used to expand the properties within an export. Currently only 'runHistory' is supported and will return information for the last 10 executions of the export.")] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"May be used to expand the properties within an export. Currently only 'runHistory' is supported and will return information for the last 10 executions of the export.", + SerializedName = @"$expand", + PossibleTypes = new [] { typeof(string) })] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Query)] + public string Expand { get => this._expand; set => this._expand = value; } + + /// SendAsync Pipeline Steps to be appended to the front of the pipeline + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be appended to the front of the pipeline")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[] HttpPipelineAppend { get; set; } + + /// SendAsync Pipeline Steps to be prepended to the front of the pipeline + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be prepended to the front of the pipeline")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[] HttpPipelinePrepend { get; set; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity _inputObject; + + /// Identity Parameter + [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "Identity Parameter", ValueFromPipeline = true)] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Path)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity InputObject { get => this._inputObject; set => this._inputObject = value; } + + /// Accessor for our copy of the InvocationInfo. + public global::System.Management.Automation.InvocationInfo InvocationInformation { get => __invocationInfo = __invocationInfo ?? this.MyInvocation ; set { __invocationInfo = value; } } + + /// + /// cancellation delegate. Stops the cmdlet when called. + /// + global::System.Action Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener.Cancel => _cancellationTokenSource.Cancel; + + /// cancellation token. + global::System.Threading.CancellationToken Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener.Token => _cancellationTokenSource.Token; + + /// + /// The instance of the that the remote call will use. + /// + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.HttpPipeline Pipeline { get; set; } + + /// The URI for the proxy server to use + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "The URI for the proxy server to use")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Uri Proxy { get; set; } + + /// Credentials for a proxy server to use for the remote call + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Credentials for a proxy server to use for the remote call")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Management.Automation.PSCredential ProxyCredential { get; set; } + + /// Use the default credentials for the proxy + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Use the default credentials for the proxy")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter ProxyUseDefaultCredentials { get; set; } + + /// + /// overrideOnDefault will be called before the regular onDefault has been processed, allowing customization of what + /// happens on that response. Implement this method in a partial class to enable this behavior + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a from the remote call + /// /// Determines if the rest of the onDefault method should be processed, or if the method should + /// return immediately (set to true to skip further processing ) + + partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + + /// + /// overrideOnOk will be called before the regular onOk has been processed, allowing customization of what happens + /// on that response. Implement this method in a partial class to enable this behavior + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a from the remote call + /// /// Determines if the rest of the onOk method should be processed, or if the method should return + /// immediately (set to true to skip further processing ) + + partial void overrideOnOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + + /// + /// (overrides the default BeginProcessing method in global::System.Management.Automation.PSCmdlet) + /// + protected override void BeginProcessing() + { + Module.Instance.SetProxyConfiguration(Proxy, ProxyCredential, ProxyUseDefaultCredentials); + if (Break) + { + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.AttachDebugger.Break(); + } + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletBeginProcessing).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + + /// Performs clean-up after the command execution + protected override void EndProcessing() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletEndProcessing).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + + /// + /// Intializes a new instance of the cmdlet class. + /// + public GetAzCostManagementExport_GetViaIdentity() + { + + } + + /// Handles/Dispatches events during the call to the REST service. + /// The message id + /// The message cancellation token. When this call is cancelled, this should be true + /// Detailed message data for the message event. + /// + /// A that will be complete when handling of the message is completed. + /// + async global::System.Threading.Tasks.Task Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener.Signal(string id, global::System.Threading.CancellationToken token, global::System.Func messageData) + { + using( NoSynchronizationContext ) + { + if (token.IsCancellationRequested) + { + return ; + } + + switch ( id ) + { + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Verbose: + { + WriteVerbose($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Warning: + { + WriteWarning($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Information: + { + var data = messageData(); + WriteInformation(data, new[] { data.Message }); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Debug: + { + WriteDebug($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Error: + { + WriteError(new global::System.Management.Automation.ErrorRecord( new global::System.Exception(messageData().Message), string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null ) ); + return ; + } + } + await Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Module.Instance.Signal(id, token, messageData, (i,t,m) => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(i,t,()=> Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.EventDataConverter.ConvertFrom( m() ) as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.EventData ), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); + if (token.IsCancellationRequested) + { + return ; + } + WriteDebug($"{id}: {(messageData().Message ?? global::System.String.Empty)}"); + } + } + + /// Performs execution of the command. + protected override void ProcessRecord() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordStart).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + __processRecordId = System.Guid.NewGuid().ToString(); + try + { + // work + using( var asyncCommandRuntime = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.AsyncCommandRuntime(this, ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token) ) + { + asyncCommandRuntime.Wait( ProcessRecordAsync(),((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token); + } + } + catch (global::System.AggregateException aggregateException) + { + // unroll the inner exceptions to get the root cause + foreach( var innerException in aggregateException.Flatten().InnerExceptions ) + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletException, $"{innerException.GetType().Name} - {innerException.Message} : {innerException.StackTrace}").Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + // Write exception out to error channel. + WriteError( new global::System.Management.Automation.ErrorRecord(innerException,string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null) ); + } + } + catch (global::System.Exception exception) when ((exception as System.Management.Automation.PipelineStoppedException)== null || (exception as System.Management.Automation.PipelineStoppedException).InnerException != null) + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletException, $"{exception.GetType().Name} - {exception.Message} : {exception.StackTrace}").Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + // Write exception out to error channel. + WriteError( new global::System.Management.Automation.ErrorRecord(exception,string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null) ); + } + finally + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordEnd).Wait(); + } + } + + /// Performs execution of the command, working asynchronously if required. + /// + /// A that will be complete when handling of the method is completed. + /// + protected async global::System.Threading.Tasks.Task ProcessRecordAsync() + { + using( NoSynchronizationContext ) + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordAsyncStart); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletGetPipeline); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName); + if (null != HttpPipelinePrepend) + { + Pipeline.Prepend((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelinePrepend) ?? HttpPipelinePrepend); + } + if (null != HttpPipelineAppend) + { + Pipeline.Append((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelineAppend) ?? HttpPipelineAppend); + } + // get the client instance + try + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletBeforeAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + if (InputObject?.Id != null) + { + await this.Client.ExportsGetViaIdentity(InputObject.Id, this.InvocationInformation.BoundParameters.ContainsKey("Expand") ? Expand : null, onOk, onDefault, this, Pipeline); + } + else + { + // try to call with PATH parameters from Input Object + if (null == InputObject.Scope) + { + ThrowTerminatingError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception("InputObject has null value for InputObject.Scope"),string.Empty, global::System.Management.Automation.ErrorCategory.InvalidArgument, InputObject) ); + } + if (null == InputObject.ExportName) + { + ThrowTerminatingError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception("InputObject has null value for InputObject.ExportName"),string.Empty, global::System.Management.Automation.ErrorCategory.InvalidArgument, InputObject) ); + } + await this.Client.ExportsGet(InputObject.Scope ?? null, InputObject.ExportName ?? null, this.InvocationInformation.BoundParameters.ContainsKey("Expand") ? Expand : null, onOk, onDefault, this, Pipeline); + } + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletAfterAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + catch (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.UndeclaredResponseException urexception) + { + WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { Expand=this.InvocationInformation.BoundParameters.ContainsKey("Expand") ? Expand : null}) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(urexception.Message) { RecommendedAction = urexception.Action } + }); + } + finally + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordAsyncEnd); + } + } + } + + /// Interrupts currently running code within the command. + protected override void StopProcessing() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Cancel(); + base.StopProcessing(); + } + + /// + /// a delegate that is called when the remote service returns default (any response code not handled elsewhere). + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a from the remote call + /// + /// A that will be complete when handling of the method is completed. + /// + private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + { + using( NoSynchronizationContext ) + { + var _returnNow = global::System.Threading.Tasks.Task.FromResult(false); + overrideOnDefault(responseMessage, response, ref _returnNow); + // if overrideOnDefault has returned true, then return right away. + if ((null != _returnNow && await _returnNow)) + { + return ; + } + // Error Response : default + var code = (await response)?.Code; + var message = (await response)?.Message; + if ((null == code || null == message)) + { + // Unrecognized Response. Create an error record based on what we have. + var ex = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.RestException(responseMessage, await response); + WriteError( new global::System.Management.Automation.ErrorRecord(ex, ex.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { Expand=this.InvocationInformation.BoundParameters.ContainsKey("Expand") ? Expand : null }) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(ex.Message) { RecommendedAction = ex.Action } + }); + } + else + { + WriteError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception($"[{code}] : {message}"), code?.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { Expand=this.InvocationInformation.BoundParameters.ContainsKey("Expand") ? Expand : null }) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(message) { RecommendedAction = global::System.String.Empty } + }); + } + } + } + + /// a delegate that is called when the remote service returns 200 (OK). + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a from the remote call + /// + /// A that will be complete when handling of the method is completed. + /// + private async global::System.Threading.Tasks.Task onOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + { + using( NoSynchronizationContext ) + { + var _returnNow = global::System.Threading.Tasks.Task.FromResult(false); + overrideOnOk(responseMessage, response, ref _returnNow); + // if overrideOnOk has returned true, then return right away. + if ((null != _returnNow && await _returnNow)) + { + return ; + } + // onOk - response for 200 / application/json + // (await response) // should be Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport + WriteObject((await response)); + } + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/cmdlets/GetAzCostManagementExport_List.cs b/src/CostManagement/generated/cmdlets/GetAzCostManagementExport_List.cs new file mode 100644 index 000000000000..05fe1b7a4410 --- /dev/null +++ b/src/CostManagement/generated/cmdlets/GetAzCostManagementExport_List.cs @@ -0,0 +1,384 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Cmdlets +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The operation to list all exports at the given scope. + /// + /// [OpenAPI] Exports_List=>GET:"/{scope}/providers/Microsoft.CostManagement/exports" + /// + [global::System.Management.Automation.Cmdlet(global::System.Management.Automation.VerbsCommon.Get, @"AzCostManagementExport_List")] + [global::System.Management.Automation.OutputType(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport))] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Description(@"The operation to list all exports at the given scope.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Generated] + public partial class GetAzCostManagementExport_List : global::System.Management.Automation.PSCmdlet, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener + { + /// A unique id generatd for the this cmdlet when it is instantiated. + private string __correlationId = System.Guid.NewGuid().ToString(); + + /// A copy of the Invocation Info (necessary to allow asJob to clone this cmdlet) + private global::System.Management.Automation.InvocationInfo __invocationInfo; + + /// A unique id generatd for the this cmdlet when ProcessRecord() is called. + private string __processRecordId; + + /// + /// The for this operation. + /// + private global::System.Threading.CancellationTokenSource _cancellationTokenSource = new global::System.Threading.CancellationTokenSource(); + + /// Wait for .NET debugger to attach + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Wait for .NET debugger to attach")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter Break { get; set; } + + /// The reference to the client API class. + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.CostManagement Client => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Module.Instance.ClientAPI; + + /// + /// The credentials, account, tenant, and subscription used for communication with Azure + /// + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The credentials, account, tenant, and subscription used for communication with Azure.")] + [global::System.Management.Automation.ValidateNotNull] + [global::System.Management.Automation.Alias("AzureRMContext", "AzureCredential")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Azure)] + public global::System.Management.Automation.PSObject DefaultProfile { get; set; } + + /// Backing field for property. + private string _expand; + + /// + /// May be used to expand the properties within an export. Currently only 'runHistory' is supported and will return information + /// for the last execution of each export. + /// + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "May be used to expand the properties within an export. Currently only 'runHistory' is supported and will return information for the last execution of each export.")] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"May be used to expand the properties within an export. Currently only 'runHistory' is supported and will return information for the last execution of each export.", + SerializedName = @"$expand", + PossibleTypes = new [] { typeof(string) })] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Query)] + public string Expand { get => this._expand; set => this._expand = value; } + + /// SendAsync Pipeline Steps to be appended to the front of the pipeline + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be appended to the front of the pipeline")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[] HttpPipelineAppend { get; set; } + + /// SendAsync Pipeline Steps to be prepended to the front of the pipeline + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be prepended to the front of the pipeline")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[] HttpPipelinePrepend { get; set; } + + /// Accessor for our copy of the InvocationInfo. + public global::System.Management.Automation.InvocationInfo InvocationInformation { get => __invocationInfo = __invocationInfo ?? this.MyInvocation ; set { __invocationInfo = value; } } + + /// + /// cancellation delegate. Stops the cmdlet when called. + /// + global::System.Action Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener.Cancel => _cancellationTokenSource.Cancel; + + /// cancellation token. + global::System.Threading.CancellationToken Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener.Token => _cancellationTokenSource.Token; + + /// + /// The instance of the that the remote call will use. + /// + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.HttpPipeline Pipeline { get; set; } + + /// The URI for the proxy server to use + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "The URI for the proxy server to use")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Uri Proxy { get; set; } + + /// Credentials for a proxy server to use for the remote call + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Credentials for a proxy server to use for the remote call")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Management.Automation.PSCredential ProxyCredential { get; set; } + + /// Use the default credentials for the proxy + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Use the default credentials for the proxy")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter ProxyUseDefaultCredentials { get; set; } + + /// Backing field for property. + private string _scope; + + /// + /// This parameter defines the scope of costmanagement from different perspectives 'Subscription','ResourceGroup' and 'Provide + /// Service'. + /// + [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "This parameter defines the scope of costmanagement from different perspectives 'Subscription','ResourceGroup' and 'Provide Service'.")] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"This parameter defines the scope of costmanagement from different perspectives 'Subscription','ResourceGroup' and 'Provide Service'.", + SerializedName = @"scope", + PossibleTypes = new [] { typeof(string) })] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Path)] + public string Scope { get => this._scope; set => this._scope = value; } + + /// + /// overrideOnDefault will be called before the regular onDefault has been processed, allowing customization of what + /// happens on that response. Implement this method in a partial class to enable this behavior + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a from the remote call + /// /// Determines if the rest of the onDefault method should be processed, or if the method should + /// return immediately (set to true to skip further processing ) + + partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + + /// + /// overrideOnOk will be called before the regular onOk has been processed, allowing customization of what happens + /// on that response. Implement this method in a partial class to enable this behavior + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a from the remote call + /// /// Determines if the rest of the onOk method should be processed, or if the method should return + /// immediately (set to true to skip further processing ) + + partial void overrideOnOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + + /// + /// (overrides the default BeginProcessing method in global::System.Management.Automation.PSCmdlet) + /// + protected override void BeginProcessing() + { + Module.Instance.SetProxyConfiguration(Proxy, ProxyCredential, ProxyUseDefaultCredentials); + if (Break) + { + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.AttachDebugger.Break(); + } + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletBeginProcessing).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + + /// Performs clean-up after the command execution + protected override void EndProcessing() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletEndProcessing).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + + /// + /// Intializes a new instance of the cmdlet class. + /// + public GetAzCostManagementExport_List() + { + + } + + /// Handles/Dispatches events during the call to the REST service. + /// The message id + /// The message cancellation token. When this call is cancelled, this should be true + /// Detailed message data for the message event. + /// + /// A that will be complete when handling of the message is completed. + /// + async global::System.Threading.Tasks.Task Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener.Signal(string id, global::System.Threading.CancellationToken token, global::System.Func messageData) + { + using( NoSynchronizationContext ) + { + if (token.IsCancellationRequested) + { + return ; + } + + switch ( id ) + { + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Verbose: + { + WriteVerbose($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Warning: + { + WriteWarning($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Information: + { + var data = messageData(); + WriteInformation(data, new[] { data.Message }); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Debug: + { + WriteDebug($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Error: + { + WriteError(new global::System.Management.Automation.ErrorRecord( new global::System.Exception(messageData().Message), string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null ) ); + return ; + } + } + await Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Module.Instance.Signal(id, token, messageData, (i,t,m) => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(i,t,()=> Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.EventDataConverter.ConvertFrom( m() ) as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.EventData ), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); + if (token.IsCancellationRequested) + { + return ; + } + WriteDebug($"{id}: {(messageData().Message ?? global::System.String.Empty)}"); + } + } + + /// Performs execution of the command. + protected override void ProcessRecord() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordStart).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + __processRecordId = System.Guid.NewGuid().ToString(); + try + { + // work + using( var asyncCommandRuntime = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.AsyncCommandRuntime(this, ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token) ) + { + asyncCommandRuntime.Wait( ProcessRecordAsync(),((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token); + } + } + catch (global::System.AggregateException aggregateException) + { + // unroll the inner exceptions to get the root cause + foreach( var innerException in aggregateException.Flatten().InnerExceptions ) + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletException, $"{innerException.GetType().Name} - {innerException.Message} : {innerException.StackTrace}").Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + // Write exception out to error channel. + WriteError( new global::System.Management.Automation.ErrorRecord(innerException,string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null) ); + } + } + catch (global::System.Exception exception) when ((exception as System.Management.Automation.PipelineStoppedException)== null || (exception as System.Management.Automation.PipelineStoppedException).InnerException != null) + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletException, $"{exception.GetType().Name} - {exception.Message} : {exception.StackTrace}").Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + // Write exception out to error channel. + WriteError( new global::System.Management.Automation.ErrorRecord(exception,string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null) ); + } + finally + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordEnd).Wait(); + } + } + + /// Performs execution of the command, working asynchronously if required. + /// + /// A that will be complete when handling of the method is completed. + /// + protected async global::System.Threading.Tasks.Task ProcessRecordAsync() + { + using( NoSynchronizationContext ) + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordAsyncStart); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletGetPipeline); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName); + if (null != HttpPipelinePrepend) + { + Pipeline.Prepend((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelinePrepend) ?? HttpPipelinePrepend); + } + if (null != HttpPipelineAppend) + { + Pipeline.Append((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelineAppend) ?? HttpPipelineAppend); + } + // get the client instance + try + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletBeforeAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + await this.Client.ExportsList(Scope, this.InvocationInformation.BoundParameters.ContainsKey("Expand") ? Expand : null, onOk, onDefault, this, Pipeline); + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletAfterAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + catch (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.UndeclaredResponseException urexception) + { + WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { Scope=Scope,Expand=this.InvocationInformation.BoundParameters.ContainsKey("Expand") ? Expand : null}) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(urexception.Message) { RecommendedAction = urexception.Action } + }); + } + finally + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordAsyncEnd); + } + } + } + + /// Interrupts currently running code within the command. + protected override void StopProcessing() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Cancel(); + base.StopProcessing(); + } + + /// + /// a delegate that is called when the remote service returns default (any response code not handled elsewhere). + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a from the remote call + /// + /// A that will be complete when handling of the method is completed. + /// + private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + { + using( NoSynchronizationContext ) + { + var _returnNow = global::System.Threading.Tasks.Task.FromResult(false); + overrideOnDefault(responseMessage, response, ref _returnNow); + // if overrideOnDefault has returned true, then return right away. + if ((null != _returnNow && await _returnNow)) + { + return ; + } + // Error Response : default + var code = (await response)?.Code; + var message = (await response)?.Message; + if ((null == code || null == message)) + { + // Unrecognized Response. Create an error record based on what we have. + var ex = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.RestException(responseMessage, await response); + WriteError( new global::System.Management.Automation.ErrorRecord(ex, ex.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { Scope=Scope, Expand=this.InvocationInformation.BoundParameters.ContainsKey("Expand") ? Expand : null }) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(ex.Message) { RecommendedAction = ex.Action } + }); + } + else + { + WriteError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception($"[{code}] : {message}"), code?.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { Scope=Scope, Expand=this.InvocationInformation.BoundParameters.ContainsKey("Expand") ? Expand : null }) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(message) { RecommendedAction = global::System.String.Empty } + }); + } + } + } + + /// a delegate that is called when the remote service returns 200 (OK). + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a from the remote call + /// + /// A that will be complete when handling of the method is completed. + /// + private async global::System.Threading.Tasks.Task onOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + { + using( NoSynchronizationContext ) + { + var _returnNow = global::System.Threading.Tasks.Task.FromResult(false); + overrideOnOk(responseMessage, response, ref _returnNow); + // if overrideOnOk has returned true, then return right away. + if ((null != _returnNow && await _returnNow)) + { + return ; + } + // onOk - response for 200 / application/json + // response should be returning an array of some kind. +Pageable + // nested-array / value / + WriteObject((await response).Value, true); + } + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/cmdlets/GetAzCostManagementOperation_List.cs b/src/CostManagement/generated/cmdlets/GetAzCostManagementOperation_List.cs new file mode 100644 index 000000000000..b047230ce493 --- /dev/null +++ b/src/CostManagement/generated/cmdlets/GetAzCostManagementOperation_List.cs @@ -0,0 +1,361 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Cmdlets +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// Lists all of the available cost management REST API operations. + /// + /// [OpenAPI] Operations_List=>GET:"/providers/Microsoft.CostManagement/operations" + /// + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.InternalExport] + [global::System.Management.Automation.Cmdlet(global::System.Management.Automation.VerbsCommon.Get, @"AzCostManagementOperation_List")] + [global::System.Management.Automation.OutputType(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperation))] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Description(@"Lists all of the available cost management REST API operations.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Generated] + public partial class GetAzCostManagementOperation_List : global::System.Management.Automation.PSCmdlet, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener + { + /// A unique id generatd for the this cmdlet when it is instantiated. + private string __correlationId = System.Guid.NewGuid().ToString(); + + /// A copy of the Invocation Info (necessary to allow asJob to clone this cmdlet) + private global::System.Management.Automation.InvocationInfo __invocationInfo; + + /// A unique id generatd for the this cmdlet when ProcessRecord() is called. + private string __processRecordId; + + /// + /// The for this operation. + /// + private global::System.Threading.CancellationTokenSource _cancellationTokenSource = new global::System.Threading.CancellationTokenSource(); + + /// Wait for .NET debugger to attach + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Wait for .NET debugger to attach")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter Break { get; set; } + + /// The reference to the client API class. + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.CostManagement Client => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Module.Instance.ClientAPI; + + /// + /// The credentials, account, tenant, and subscription used for communication with Azure + /// + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The credentials, account, tenant, and subscription used for communication with Azure.")] + [global::System.Management.Automation.ValidateNotNull] + [global::System.Management.Automation.Alias("AzureRMContext", "AzureCredential")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Azure)] + public global::System.Management.Automation.PSObject DefaultProfile { get; set; } + + /// SendAsync Pipeline Steps to be appended to the front of the pipeline + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be appended to the front of the pipeline")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[] HttpPipelineAppend { get; set; } + + /// SendAsync Pipeline Steps to be prepended to the front of the pipeline + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be prepended to the front of the pipeline")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[] HttpPipelinePrepend { get; set; } + + /// Accessor for our copy of the InvocationInfo. + public global::System.Management.Automation.InvocationInfo InvocationInformation { get => __invocationInfo = __invocationInfo ?? this.MyInvocation ; set { __invocationInfo = value; } } + + /// + /// cancellation delegate. Stops the cmdlet when called. + /// + global::System.Action Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener.Cancel => _cancellationTokenSource.Cancel; + + /// cancellation token. + global::System.Threading.CancellationToken Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener.Token => _cancellationTokenSource.Token; + + /// + /// The instance of the that the remote call will use. + /// + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.HttpPipeline Pipeline { get; set; } + + /// The URI for the proxy server to use + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "The URI for the proxy server to use")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Uri Proxy { get; set; } + + /// Credentials for a proxy server to use for the remote call + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Credentials for a proxy server to use for the remote call")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Management.Automation.PSCredential ProxyCredential { get; set; } + + /// Use the default credentials for the proxy + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Use the default credentials for the proxy")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter ProxyUseDefaultCredentials { get; set; } + + /// + /// overrideOnDefault will be called before the regular onDefault has been processed, allowing customization of what + /// happens on that response. Implement this method in a partial class to enable this behavior + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a from the remote call + /// /// Determines if the rest of the onDefault method should be processed, or if the method should + /// return immediately (set to true to skip further processing ) + + partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + + /// + /// overrideOnOk will be called before the regular onOk has been processed, allowing customization of what happens + /// on that response. Implement this method in a partial class to enable this behavior + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a from the remote call + /// /// Determines if the rest of the onOk method should be processed, or if the method should return + /// immediately (set to true to skip further processing ) + + partial void overrideOnOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + + /// + /// (overrides the default BeginProcessing method in global::System.Management.Automation.PSCmdlet) + /// + protected override void BeginProcessing() + { + Module.Instance.SetProxyConfiguration(Proxy, ProxyCredential, ProxyUseDefaultCredentials); + if (Break) + { + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.AttachDebugger.Break(); + } + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletBeginProcessing).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + + /// Performs clean-up after the command execution + protected override void EndProcessing() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletEndProcessing).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + + /// + /// Intializes a new instance of the cmdlet class. + /// + public GetAzCostManagementOperation_List() + { + + } + + /// Handles/Dispatches events during the call to the REST service. + /// The message id + /// The message cancellation token. When this call is cancelled, this should be true + /// Detailed message data for the message event. + /// + /// A that will be complete when handling of the message is completed. + /// + async global::System.Threading.Tasks.Task Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener.Signal(string id, global::System.Threading.CancellationToken token, global::System.Func messageData) + { + using( NoSynchronizationContext ) + { + if (token.IsCancellationRequested) + { + return ; + } + + switch ( id ) + { + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Verbose: + { + WriteVerbose($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Warning: + { + WriteWarning($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Information: + { + var data = messageData(); + WriteInformation(data, new[] { data.Message }); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Debug: + { + WriteDebug($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Error: + { + WriteError(new global::System.Management.Automation.ErrorRecord( new global::System.Exception(messageData().Message), string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null ) ); + return ; + } + } + await Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Module.Instance.Signal(id, token, messageData, (i,t,m) => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(i,t,()=> Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.EventDataConverter.ConvertFrom( m() ) as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.EventData ), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); + if (token.IsCancellationRequested) + { + return ; + } + WriteDebug($"{id}: {(messageData().Message ?? global::System.String.Empty)}"); + } + } + + /// Performs execution of the command. + protected override void ProcessRecord() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordStart).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + __processRecordId = System.Guid.NewGuid().ToString(); + try + { + // work + using( var asyncCommandRuntime = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.AsyncCommandRuntime(this, ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token) ) + { + asyncCommandRuntime.Wait( ProcessRecordAsync(),((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token); + } + } + catch (global::System.AggregateException aggregateException) + { + // unroll the inner exceptions to get the root cause + foreach( var innerException in aggregateException.Flatten().InnerExceptions ) + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletException, $"{innerException.GetType().Name} - {innerException.Message} : {innerException.StackTrace}").Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + // Write exception out to error channel. + WriteError( new global::System.Management.Automation.ErrorRecord(innerException,string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null) ); + } + } + catch (global::System.Exception exception) when ((exception as System.Management.Automation.PipelineStoppedException)== null || (exception as System.Management.Automation.PipelineStoppedException).InnerException != null) + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletException, $"{exception.GetType().Name} - {exception.Message} : {exception.StackTrace}").Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + // Write exception out to error channel. + WriteError( new global::System.Management.Automation.ErrorRecord(exception,string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null) ); + } + finally + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordEnd).Wait(); + } + } + + /// Performs execution of the command, working asynchronously if required. + /// + /// A that will be complete when handling of the method is completed. + /// + protected async global::System.Threading.Tasks.Task ProcessRecordAsync() + { + using( NoSynchronizationContext ) + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordAsyncStart); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletGetPipeline); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName); + if (null != HttpPipelinePrepend) + { + Pipeline.Prepend((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelinePrepend) ?? HttpPipelinePrepend); + } + if (null != HttpPipelineAppend) + { + Pipeline.Append((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelineAppend) ?? HttpPipelineAppend); + } + // get the client instance + try + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletBeforeAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + await this.Client.OperationsList(onOk, onDefault, this, Pipeline); + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletAfterAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + catch (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.UndeclaredResponseException urexception) + { + WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(urexception.Message) { RecommendedAction = urexception.Action } + }); + } + finally + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordAsyncEnd); + } + } + } + + /// Interrupts currently running code within the command. + protected override void StopProcessing() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Cancel(); + base.StopProcessing(); + } + + /// + /// a delegate that is called when the remote service returns default (any response code not handled elsewhere). + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a from the remote call + /// + /// A that will be complete when handling of the method is completed. + /// + private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + { + using( NoSynchronizationContext ) + { + var _returnNow = global::System.Threading.Tasks.Task.FromResult(false); + overrideOnDefault(responseMessage, response, ref _returnNow); + // if overrideOnDefault has returned true, then return right away. + if ((null != _returnNow && await _returnNow)) + { + return ; + } + // Error Response : default + var code = (await response)?.Code; + var message = (await response)?.Message; + if ((null == code || null == message)) + { + // Unrecognized Response. Create an error record based on what we have. + var ex = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.RestException(responseMessage, await response); + WriteError( new global::System.Management.Automation.ErrorRecord(ex, ex.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(ex.Message) { RecommendedAction = ex.Action } + }); + } + else + { + WriteError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception($"[{code}] : {message}"), code?.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(message) { RecommendedAction = global::System.String.Empty } + }); + } + } + } + + /// a delegate that is called when the remote service returns 200 (OK). + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a from the remote call + /// + /// A that will be complete when handling of the method is completed. + /// + private async global::System.Threading.Tasks.Task onOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + { + using( NoSynchronizationContext ) + { + var _returnNow = global::System.Threading.Tasks.Task.FromResult(false); + overrideOnOk(responseMessage, response, ref _returnNow); + // if overrideOnOk has returned true, then return right away. + if ((null != _returnNow && await _returnNow)) + { + return ; + } + // onOk - response for 200 / application/json + // response should be returning an array of some kind. +Pageable + // pageable / value / nextLink + var result = await response; + WriteObject(result.Value,true); + if (result.NextLink != null) + { + if (responseMessage.RequestMessage is System.Net.Http.HttpRequestMessage requestMessage ) + { + requestMessage = requestMessage.Clone(new global::System.Uri( result.NextLink ),Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Method.Get ); + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.FollowingNextLink); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + await this.Client.OperationsList_Call(requestMessage, onOk, onDefault, this, Pipeline); + } + } + } + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/cmdlets/InvokeAzCostManagementExecuteExport_Execute.cs b/src/CostManagement/generated/cmdlets/InvokeAzCostManagementExecuteExport_Execute.cs new file mode 100644 index 000000000000..935b37943f67 --- /dev/null +++ b/src/CostManagement/generated/cmdlets/InvokeAzCostManagementExecuteExport_Execute.cs @@ -0,0 +1,388 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Cmdlets +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The operation to execute an export. + /// + /// [OpenAPI] Exports_Execute=>POST:"/{scope}/providers/Microsoft.CostManagement/exports/{exportName}/run" + /// + [global::System.Management.Automation.Cmdlet(global::System.Management.Automation.VerbsLifecycle.Invoke, @"AzCostManagementExecuteExport_Execute", SupportsShouldProcess = true)] + [global::System.Management.Automation.OutputType(typeof(bool))] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Description(@"The operation to execute an export.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Generated] + public partial class InvokeAzCostManagementExecuteExport_Execute : global::System.Management.Automation.PSCmdlet, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener + { + /// A unique id generatd for the this cmdlet when it is instantiated. + private string __correlationId = System.Guid.NewGuid().ToString(); + + /// A copy of the Invocation Info (necessary to allow asJob to clone this cmdlet) + private global::System.Management.Automation.InvocationInfo __invocationInfo; + + /// A unique id generatd for the this cmdlet when ProcessRecord() is called. + private string __processRecordId; + + /// + /// The for this operation. + /// + private global::System.Threading.CancellationTokenSource _cancellationTokenSource = new global::System.Threading.CancellationTokenSource(); + + /// Wait for .NET debugger to attach + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Wait for .NET debugger to attach")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter Break { get; set; } + + /// The reference to the client API class. + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.CostManagement Client => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Module.Instance.ClientAPI; + + /// + /// The credentials, account, tenant, and subscription used for communication with Azure + /// + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The credentials, account, tenant, and subscription used for communication with Azure.")] + [global::System.Management.Automation.ValidateNotNull] + [global::System.Management.Automation.Alias("AzureRMContext", "AzureCredential")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Azure)] + public global::System.Management.Automation.PSObject DefaultProfile { get; set; } + + /// Backing field for property. + private string _exportName; + + /// Export Name. + [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "Export Name.")] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"Export Name.", + SerializedName = @"exportName", + PossibleTypes = new [] { typeof(string) })] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Path)] + public string ExportName { get => this._exportName; set => this._exportName = value; } + + /// SendAsync Pipeline Steps to be appended to the front of the pipeline + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be appended to the front of the pipeline")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[] HttpPipelineAppend { get; set; } + + /// SendAsync Pipeline Steps to be prepended to the front of the pipeline + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be prepended to the front of the pipeline")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[] HttpPipelinePrepend { get; set; } + + /// Accessor for our copy of the InvocationInfo. + public global::System.Management.Automation.InvocationInfo InvocationInformation { get => __invocationInfo = __invocationInfo ?? this.MyInvocation ; set { __invocationInfo = value; } } + + /// + /// cancellation delegate. Stops the cmdlet when called. + /// + global::System.Action Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener.Cancel => _cancellationTokenSource.Cancel; + + /// cancellation token. + global::System.Threading.CancellationToken Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener.Token => _cancellationTokenSource.Token; + + /// + /// When specified, forces the cmdlet return a 'bool' given that there isn't a return type by default. + /// + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "Returns true when the command succeeds")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter PassThru { get; set; } + + /// + /// The instance of the that the remote call will use. + /// + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.HttpPipeline Pipeline { get; set; } + + /// The URI for the proxy server to use + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "The URI for the proxy server to use")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Uri Proxy { get; set; } + + /// Credentials for a proxy server to use for the remote call + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Credentials for a proxy server to use for the remote call")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Management.Automation.PSCredential ProxyCredential { get; set; } + + /// Use the default credentials for the proxy + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Use the default credentials for the proxy")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter ProxyUseDefaultCredentials { get; set; } + + /// Backing field for property. + private string _scope; + + /// + /// This parameter defines the scope of costmanagement from different perspectives 'Subscription','ResourceGroup' and 'Provide + /// Service'. + /// + [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "This parameter defines the scope of costmanagement from different perspectives 'Subscription','ResourceGroup' and 'Provide Service'.")] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"This parameter defines the scope of costmanagement from different perspectives 'Subscription','ResourceGroup' and 'Provide Service'.", + SerializedName = @"scope", + PossibleTypes = new [] { typeof(string) })] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Path)] + public string Scope { get => this._scope; set => this._scope = value; } + + /// + /// overrideOnDefault will be called before the regular onDefault has been processed, allowing customization of what + /// happens on that response. Implement this method in a partial class to enable this behavior + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a from the remote call + /// /// Determines if the rest of the onDefault method should be processed, or if the method should + /// return immediately (set to true to skip further processing ) + + partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + + /// + /// overrideOnOk will be called before the regular onOk has been processed, allowing customization of what happens + /// on that response. Implement this method in a partial class to enable this behavior + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// /// Determines if the rest of the onOk method should be processed, or if the method should return + /// immediately (set to true to skip further processing ) + + partial void overrideOnOk(global::System.Net.Http.HttpResponseMessage responseMessage, ref global::System.Threading.Tasks.Task returnNow); + + /// + /// (overrides the default BeginProcessing method in global::System.Management.Automation.PSCmdlet) + /// + protected override void BeginProcessing() + { + Module.Instance.SetProxyConfiguration(Proxy, ProxyCredential, ProxyUseDefaultCredentials); + if (Break) + { + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.AttachDebugger.Break(); + } + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletBeginProcessing).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + + /// Performs clean-up after the command execution + protected override void EndProcessing() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletEndProcessing).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + + /// + /// Intializes a new instance of the cmdlet class. + /// + public InvokeAzCostManagementExecuteExport_Execute() + { + + } + + /// Handles/Dispatches events during the call to the REST service. + /// The message id + /// The message cancellation token. When this call is cancelled, this should be true + /// Detailed message data for the message event. + /// + /// A that will be complete when handling of the message is completed. + /// + async global::System.Threading.Tasks.Task Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener.Signal(string id, global::System.Threading.CancellationToken token, global::System.Func messageData) + { + using( NoSynchronizationContext ) + { + if (token.IsCancellationRequested) + { + return ; + } + + switch ( id ) + { + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Verbose: + { + WriteVerbose($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Warning: + { + WriteWarning($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Information: + { + var data = messageData(); + WriteInformation(data, new[] { data.Message }); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Debug: + { + WriteDebug($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Error: + { + WriteError(new global::System.Management.Automation.ErrorRecord( new global::System.Exception(messageData().Message), string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null ) ); + return ; + } + } + await Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Module.Instance.Signal(id, token, messageData, (i,t,m) => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(i,t,()=> Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.EventDataConverter.ConvertFrom( m() ) as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.EventData ), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); + if (token.IsCancellationRequested) + { + return ; + } + WriteDebug($"{id}: {(messageData().Message ?? global::System.String.Empty)}"); + } + } + + /// Performs execution of the command. + protected override void ProcessRecord() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordStart).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + __processRecordId = System.Guid.NewGuid().ToString(); + try + { + // work + if (ShouldProcess($"Call remote 'ExportsExecute' operation")) + { + using( var asyncCommandRuntime = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.AsyncCommandRuntime(this, ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token) ) + { + asyncCommandRuntime.Wait( ProcessRecordAsync(),((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token); + } + } + } + catch (global::System.AggregateException aggregateException) + { + // unroll the inner exceptions to get the root cause + foreach( var innerException in aggregateException.Flatten().InnerExceptions ) + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletException, $"{innerException.GetType().Name} - {innerException.Message} : {innerException.StackTrace}").Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + // Write exception out to error channel. + WriteError( new global::System.Management.Automation.ErrorRecord(innerException,string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null) ); + } + } + catch (global::System.Exception exception) when ((exception as System.Management.Automation.PipelineStoppedException)== null || (exception as System.Management.Automation.PipelineStoppedException).InnerException != null) + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletException, $"{exception.GetType().Name} - {exception.Message} : {exception.StackTrace}").Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + // Write exception out to error channel. + WriteError( new global::System.Management.Automation.ErrorRecord(exception,string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null) ); + } + finally + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordEnd).Wait(); + } + } + + /// Performs execution of the command, working asynchronously if required. + /// + /// A that will be complete when handling of the method is completed. + /// + protected async global::System.Threading.Tasks.Task ProcessRecordAsync() + { + using( NoSynchronizationContext ) + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordAsyncStart); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletGetPipeline); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName); + if (null != HttpPipelinePrepend) + { + Pipeline.Prepend((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelinePrepend) ?? HttpPipelinePrepend); + } + if (null != HttpPipelineAppend) + { + Pipeline.Append((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelineAppend) ?? HttpPipelineAppend); + } + // get the client instance + try + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletBeforeAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + await this.Client.ExportsExecute(Scope, ExportName, onOk, onDefault, this, Pipeline); + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletAfterAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + catch (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.UndeclaredResponseException urexception) + { + WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { Scope=Scope,ExportName=ExportName}) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(urexception.Message) { RecommendedAction = urexception.Action } + }); + } + finally + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordAsyncEnd); + } + } + } + + /// Interrupts currently running code within the command. + protected override void StopProcessing() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Cancel(); + base.StopProcessing(); + } + + /// + /// a delegate that is called when the remote service returns default (any response code not handled elsewhere). + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a from the remote call + /// + /// A that will be complete when handling of the method is completed. + /// + private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + { + using( NoSynchronizationContext ) + { + var _returnNow = global::System.Threading.Tasks.Task.FromResult(false); + overrideOnDefault(responseMessage, response, ref _returnNow); + // if overrideOnDefault has returned true, then return right away. + if ((null != _returnNow && await _returnNow)) + { + return ; + } + // Error Response : default + var code = (await response)?.Code; + var message = (await response)?.Message; + if ((null == code || null == message)) + { + // Unrecognized Response. Create an error record based on what we have. + var ex = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.RestException(responseMessage, await response); + WriteError( new global::System.Management.Automation.ErrorRecord(ex, ex.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { Scope=Scope, ExportName=ExportName }) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(ex.Message) { RecommendedAction = ex.Action } + }); + } + else + { + WriteError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception($"[{code}] : {message}"), code?.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { Scope=Scope, ExportName=ExportName }) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(message) { RecommendedAction = global::System.String.Empty } + }); + } + } + } + + /// a delegate that is called when the remote service returns 200 (OK). + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// + /// A that will be complete when handling of the method is completed. + /// + private async global::System.Threading.Tasks.Task onOk(global::System.Net.Http.HttpResponseMessage responseMessage) + { + using( NoSynchronizationContext ) + { + var _returnNow = global::System.Threading.Tasks.Task.FromResult(false); + overrideOnOk(responseMessage, ref _returnNow); + // if overrideOnOk has returned true, then return right away. + if ((null != _returnNow && await _returnNow)) + { + return ; + } + // onOk - response for 200 / + if (true == MyInvocation?.BoundParameters?.ContainsKey("PassThru")) + { + WriteObject(true); + } + } + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/cmdlets/InvokeAzCostManagementExecuteExport_ExecuteViaIdentity.cs b/src/CostManagement/generated/cmdlets/InvokeAzCostManagementExecuteExport_ExecuteViaIdentity.cs new file mode 100644 index 000000000000..25a8ba5eccd7 --- /dev/null +++ b/src/CostManagement/generated/cmdlets/InvokeAzCostManagementExecuteExport_ExecuteViaIdentity.cs @@ -0,0 +1,381 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Cmdlets +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The operation to execute an export. + /// + /// [OpenAPI] Exports_Execute=>POST:"/{scope}/providers/Microsoft.CostManagement/exports/{exportName}/run" + /// + [global::System.Management.Automation.Cmdlet(global::System.Management.Automation.VerbsLifecycle.Invoke, @"AzCostManagementExecuteExport_ExecuteViaIdentity", SupportsShouldProcess = true)] + [global::System.Management.Automation.OutputType(typeof(bool))] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Description(@"The operation to execute an export.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Generated] + public partial class InvokeAzCostManagementExecuteExport_ExecuteViaIdentity : global::System.Management.Automation.PSCmdlet, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener + { + /// A unique id generatd for the this cmdlet when it is instantiated. + private string __correlationId = System.Guid.NewGuid().ToString(); + + /// A copy of the Invocation Info (necessary to allow asJob to clone this cmdlet) + private global::System.Management.Automation.InvocationInfo __invocationInfo; + + /// A unique id generatd for the this cmdlet when ProcessRecord() is called. + private string __processRecordId; + + /// + /// The for this operation. + /// + private global::System.Threading.CancellationTokenSource _cancellationTokenSource = new global::System.Threading.CancellationTokenSource(); + + /// Wait for .NET debugger to attach + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Wait for .NET debugger to attach")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter Break { get; set; } + + /// The reference to the client API class. + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.CostManagement Client => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Module.Instance.ClientAPI; + + /// + /// The credentials, account, tenant, and subscription used for communication with Azure + /// + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The credentials, account, tenant, and subscription used for communication with Azure.")] + [global::System.Management.Automation.ValidateNotNull] + [global::System.Management.Automation.Alias("AzureRMContext", "AzureCredential")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Azure)] + public global::System.Management.Automation.PSObject DefaultProfile { get; set; } + + /// SendAsync Pipeline Steps to be appended to the front of the pipeline + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be appended to the front of the pipeline")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[] HttpPipelineAppend { get; set; } + + /// SendAsync Pipeline Steps to be prepended to the front of the pipeline + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be prepended to the front of the pipeline")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[] HttpPipelinePrepend { get; set; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity _inputObject; + + /// Identity Parameter + [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "Identity Parameter", ValueFromPipeline = true)] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Path)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity InputObject { get => this._inputObject; set => this._inputObject = value; } + + /// Accessor for our copy of the InvocationInfo. + public global::System.Management.Automation.InvocationInfo InvocationInformation { get => __invocationInfo = __invocationInfo ?? this.MyInvocation ; set { __invocationInfo = value; } } + + /// + /// cancellation delegate. Stops the cmdlet when called. + /// + global::System.Action Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener.Cancel => _cancellationTokenSource.Cancel; + + /// cancellation token. + global::System.Threading.CancellationToken Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener.Token => _cancellationTokenSource.Token; + + /// + /// When specified, forces the cmdlet return a 'bool' given that there isn't a return type by default. + /// + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "Returns true when the command succeeds")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter PassThru { get; set; } + + /// + /// The instance of the that the remote call will use. + /// + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.HttpPipeline Pipeline { get; set; } + + /// The URI for the proxy server to use + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "The URI for the proxy server to use")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Uri Proxy { get; set; } + + /// Credentials for a proxy server to use for the remote call + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Credentials for a proxy server to use for the remote call")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Management.Automation.PSCredential ProxyCredential { get; set; } + + /// Use the default credentials for the proxy + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Use the default credentials for the proxy")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter ProxyUseDefaultCredentials { get; set; } + + /// + /// overrideOnDefault will be called before the regular onDefault has been processed, allowing customization of what + /// happens on that response. Implement this method in a partial class to enable this behavior + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a from the remote call + /// /// Determines if the rest of the onDefault method should be processed, or if the method should + /// return immediately (set to true to skip further processing ) + + partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + + /// + /// overrideOnOk will be called before the regular onOk has been processed, allowing customization of what happens + /// on that response. Implement this method in a partial class to enable this behavior + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// /// Determines if the rest of the onOk method should be processed, or if the method should return + /// immediately (set to true to skip further processing ) + + partial void overrideOnOk(global::System.Net.Http.HttpResponseMessage responseMessage, ref global::System.Threading.Tasks.Task returnNow); + + /// + /// (overrides the default BeginProcessing method in global::System.Management.Automation.PSCmdlet) + /// + protected override void BeginProcessing() + { + Module.Instance.SetProxyConfiguration(Proxy, ProxyCredential, ProxyUseDefaultCredentials); + if (Break) + { + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.AttachDebugger.Break(); + } + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletBeginProcessing).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + + /// Performs clean-up after the command execution + protected override void EndProcessing() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletEndProcessing).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + + /// + /// Intializes a new instance of the cmdlet class. + /// + public InvokeAzCostManagementExecuteExport_ExecuteViaIdentity() + { + + } + + /// Handles/Dispatches events during the call to the REST service. + /// The message id + /// The message cancellation token. When this call is cancelled, this should be true + /// Detailed message data for the message event. + /// + /// A that will be complete when handling of the message is completed. + /// + async global::System.Threading.Tasks.Task Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener.Signal(string id, global::System.Threading.CancellationToken token, global::System.Func messageData) + { + using( NoSynchronizationContext ) + { + if (token.IsCancellationRequested) + { + return ; + } + + switch ( id ) + { + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Verbose: + { + WriteVerbose($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Warning: + { + WriteWarning($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Information: + { + var data = messageData(); + WriteInformation(data, new[] { data.Message }); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Debug: + { + WriteDebug($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Error: + { + WriteError(new global::System.Management.Automation.ErrorRecord( new global::System.Exception(messageData().Message), string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null ) ); + return ; + } + } + await Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Module.Instance.Signal(id, token, messageData, (i,t,m) => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(i,t,()=> Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.EventDataConverter.ConvertFrom( m() ) as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.EventData ), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); + if (token.IsCancellationRequested) + { + return ; + } + WriteDebug($"{id}: {(messageData().Message ?? global::System.String.Empty)}"); + } + } + + /// Performs execution of the command. + protected override void ProcessRecord() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordStart).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + __processRecordId = System.Guid.NewGuid().ToString(); + try + { + // work + if (ShouldProcess($"Call remote 'ExportsExecute' operation")) + { + using( var asyncCommandRuntime = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.AsyncCommandRuntime(this, ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token) ) + { + asyncCommandRuntime.Wait( ProcessRecordAsync(),((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token); + } + } + } + catch (global::System.AggregateException aggregateException) + { + // unroll the inner exceptions to get the root cause + foreach( var innerException in aggregateException.Flatten().InnerExceptions ) + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletException, $"{innerException.GetType().Name} - {innerException.Message} : {innerException.StackTrace}").Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + // Write exception out to error channel. + WriteError( new global::System.Management.Automation.ErrorRecord(innerException,string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null) ); + } + } + catch (global::System.Exception exception) when ((exception as System.Management.Automation.PipelineStoppedException)== null || (exception as System.Management.Automation.PipelineStoppedException).InnerException != null) + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletException, $"{exception.GetType().Name} - {exception.Message} : {exception.StackTrace}").Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + // Write exception out to error channel. + WriteError( new global::System.Management.Automation.ErrorRecord(exception,string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null) ); + } + finally + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordEnd).Wait(); + } + } + + /// Performs execution of the command, working asynchronously if required. + /// + /// A that will be complete when handling of the method is completed. + /// + protected async global::System.Threading.Tasks.Task ProcessRecordAsync() + { + using( NoSynchronizationContext ) + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordAsyncStart); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletGetPipeline); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName); + if (null != HttpPipelinePrepend) + { + Pipeline.Prepend((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelinePrepend) ?? HttpPipelinePrepend); + } + if (null != HttpPipelineAppend) + { + Pipeline.Append((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelineAppend) ?? HttpPipelineAppend); + } + // get the client instance + try + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletBeforeAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + if (InputObject?.Id != null) + { + await this.Client.ExportsExecuteViaIdentity(InputObject.Id, onOk, onDefault, this, Pipeline); + } + else + { + // try to call with PATH parameters from Input Object + if (null == InputObject.Scope) + { + ThrowTerminatingError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception("InputObject has null value for InputObject.Scope"),string.Empty, global::System.Management.Automation.ErrorCategory.InvalidArgument, InputObject) ); + } + if (null == InputObject.ExportName) + { + ThrowTerminatingError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception("InputObject has null value for InputObject.ExportName"),string.Empty, global::System.Management.Automation.ErrorCategory.InvalidArgument, InputObject) ); + } + await this.Client.ExportsExecute(InputObject.Scope ?? null, InputObject.ExportName ?? null, onOk, onDefault, this, Pipeline); + } + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletAfterAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + catch (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.UndeclaredResponseException urexception) + { + WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(urexception.Message) { RecommendedAction = urexception.Action } + }); + } + finally + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordAsyncEnd); + } + } + } + + /// Interrupts currently running code within the command. + protected override void StopProcessing() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Cancel(); + base.StopProcessing(); + } + + /// + /// a delegate that is called when the remote service returns default (any response code not handled elsewhere). + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a from the remote call + /// + /// A that will be complete when handling of the method is completed. + /// + private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + { + using( NoSynchronizationContext ) + { + var _returnNow = global::System.Threading.Tasks.Task.FromResult(false); + overrideOnDefault(responseMessage, response, ref _returnNow); + // if overrideOnDefault has returned true, then return right away. + if ((null != _returnNow && await _returnNow)) + { + return ; + } + // Error Response : default + var code = (await response)?.Code; + var message = (await response)?.Message; + if ((null == code || null == message)) + { + // Unrecognized Response. Create an error record based on what we have. + var ex = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.RestException(responseMessage, await response); + WriteError( new global::System.Management.Automation.ErrorRecord(ex, ex.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(ex.Message) { RecommendedAction = ex.Action } + }); + } + else + { + WriteError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception($"[{code}] : {message}"), code?.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(message) { RecommendedAction = global::System.String.Empty } + }); + } + } + } + + /// a delegate that is called when the remote service returns 200 (OK). + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// + /// A that will be complete when handling of the method is completed. + /// + private async global::System.Threading.Tasks.Task onOk(global::System.Net.Http.HttpResponseMessage responseMessage) + { + using( NoSynchronizationContext ) + { + var _returnNow = global::System.Threading.Tasks.Task.FromResult(false); + overrideOnOk(responseMessage, ref _returnNow); + // if overrideOnOk has returned true, then return right away. + if ((null != _returnNow && await _returnNow)) + { + return ; + } + // onOk - response for 200 / + if (true == MyInvocation?.BoundParameters?.ContainsKey("PassThru")) + { + WriteObject(true); + } + } + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/cmdlets/NewAzCostManagementExport_CreateExpanded.cs b/src/CostManagement/generated/cmdlets/NewAzCostManagementExport_CreateExpanded.cs new file mode 100644 index 000000000000..e966640c0e7a --- /dev/null +++ b/src/CostManagement/generated/cmdlets/NewAzCostManagementExport_CreateExpanded.cs @@ -0,0 +1,615 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Cmdlets +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// + /// The operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain + /// the latest eTag by performing a get operation. Create operation does not require eTag. + /// + /// + /// [OpenAPI] Exports_CreateOrUpdate=>PUT:"/{scope}/providers/Microsoft.CostManagement/exports/{exportName}" + /// + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.InternalExport] + [global::System.Management.Automation.Cmdlet(global::System.Management.Automation.VerbsCommon.New, @"AzCostManagementExport_CreateExpanded", SupportsShouldProcess = true)] + [global::System.Management.Automation.OutputType(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport))] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Description(@"The operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Generated] + public partial class NewAzCostManagementExport_CreateExpanded : global::System.Management.Automation.PSCmdlet, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener + { + /// A unique id generatd for the this cmdlet when it is instantiated. + private string __correlationId = System.Guid.NewGuid().ToString(); + + /// A copy of the Invocation Info (necessary to allow asJob to clone this cmdlet) + private global::System.Management.Automation.InvocationInfo __invocationInfo; + + /// A unique id generatd for the this cmdlet when ProcessRecord() is called. + private string __processRecordId; + + /// + /// The for this operation. + /// + private global::System.Threading.CancellationTokenSource _cancellationTokenSource = new global::System.Threading.CancellationTokenSource(); + + /// Wait for .NET debugger to attach + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Wait for .NET debugger to attach")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter Break { get; set; } + + /// The reference to the client API class. + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.CostManagement Client => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Module.Instance.ClientAPI; + + /// + /// Array of column names to be included in the export. If not provided then the export will include all available columns. + /// The available columns can vary by customer channel (see examples). + /// + [global::System.Management.Automation.AllowEmptyCollection] + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "Array of column names to be included in the export. If not provided then the export will include all available columns. The available columns can vary by customer channel (see examples).")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Body)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Array of column names to be included in the export. If not provided then the export will include all available columns. The available columns can vary by customer channel (see examples).", + SerializedName = @"columns", + PossibleTypes = new [] { typeof(string) })] + public string[] ConfigurationColumn { get => ParametersBody.ConfigurationColumn ?? null /* arrayOf */; set => ParametersBody.ConfigurationColumn = value; } + + /// The granularity of rows in the export. Currently only 'Daily' is supported. + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The granularity of rows in the export. Currently only 'Daily' is supported.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Body)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The granularity of rows in the export. Currently only 'Daily' is supported.", + SerializedName = @"granularity", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType) })] + [global::System.Management.Automation.ArgumentCompleter(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType))] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType DataSetGranularity { get => ParametersBody.DataSetGranularity ?? ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType)""); set => ParametersBody.DataSetGranularity = value; } + + /// + /// The credentials, account, tenant, and subscription used for communication with Azure + /// + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The credentials, account, tenant, and subscription used for communication with Azure.")] + [global::System.Management.Automation.ValidateNotNull] + [global::System.Management.Automation.Alias("AzureRMContext", "AzureCredential")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Azure)] + public global::System.Management.Automation.PSObject DefaultProfile { get; set; } + + /// + /// The time frame for pulling data for the export. If custom, then a specific time period must be provided. + /// + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The time frame for pulling data for the export. If custom, then a specific time period must be provided.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Body)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The time frame for pulling data for the export. If custom, then a specific time period must be provided.", + SerializedName = @"timeframe", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType) })] + [global::System.Management.Automation.ArgumentCompleter(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType))] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType DefinitionTimeframe { get => ParametersBody.DefinitionTimeframe; set => ParametersBody.DefinitionTimeframe = value; } + + /// + /// The type of the export. Note that 'Usage' is equivalent to 'ActualCost' and is applicable to exports that do not yet provide + /// data for charges or amortization for service reservations. + /// + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The type of the export. Note that 'Usage' is equivalent to 'ActualCost' and is applicable to exports that do not yet provide data for charges or amortization for service reservations.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Body)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The type of the export. Note that 'Usage' is equivalent to 'ActualCost' and is applicable to exports that do not yet provide data for charges or amortization for service reservations.", + SerializedName = @"type", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType) })] + [global::System.Management.Automation.ArgumentCompleter(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType))] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType DefinitionType { get => ParametersBody.DefinitionType; set => ParametersBody.DefinitionType = value; } + + /// The name of the container where exports will be uploaded. + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The name of the container where exports will be uploaded.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Body)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The name of the container where exports will be uploaded.", + SerializedName = @"container", + PossibleTypes = new [] { typeof(string) })] + public string DestinationContainer { get => ParametersBody.DestinationContainer ?? null; set => ParametersBody.DestinationContainer = value; } + + /// The resource id of the storage account where exports will be delivered. + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The resource id of the storage account where exports will be delivered.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Body)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The resource id of the storage account where exports will be delivered.", + SerializedName = @"resourceId", + PossibleTypes = new [] { typeof(string) })] + public string DestinationResourceId { get => ParametersBody.DestinationResourceId ?? null; set => ParametersBody.DestinationResourceId = value; } + + /// The name of the directory where exports will be uploaded. + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The name of the directory where exports will be uploaded.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Body)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The name of the directory where exports will be uploaded.", + SerializedName = @"rootFolderPath", + PossibleTypes = new [] { typeof(string) })] + public string DestinationRootFolderPath { get => ParametersBody.DestinationRootFolderPath ?? null; set => ParametersBody.DestinationRootFolderPath = value; } + + /// + /// eTag of the resource. To handle concurrent update scenario, this field will be used to determine whether the user is updating + /// the latest version or not. + /// + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "eTag of the resource. To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Body)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"eTag of the resource. To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not.", + SerializedName = @"eTag", + PossibleTypes = new [] { typeof(string) })] + public string ETag { get => ParametersBody.ETag ?? null; set => ParametersBody.ETag = value; } + + /// The format of the export being delivered. Currently only 'Csv' is supported. + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The format of the export being delivered. Currently only 'Csv' is supported.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Body)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The format of the export being delivered. Currently only 'Csv' is supported.", + SerializedName = @"format", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType) })] + [global::System.Management.Automation.ArgumentCompleter(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType))] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType Format { get => ParametersBody.Format ?? ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType)""); set => ParametersBody.Format = value; } + + /// SendAsync Pipeline Steps to be appended to the front of the pipeline + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be appended to the front of the pipeline")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[] HttpPipelineAppend { get; set; } + + /// SendAsync Pipeline Steps to be prepended to the front of the pipeline + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be prepended to the front of the pipeline")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[] HttpPipelinePrepend { get; set; } + + /// Accessor for our copy of the InvocationInfo. + public global::System.Management.Automation.InvocationInfo InvocationInformation { get => __invocationInfo = __invocationInfo ?? this.MyInvocation ; set { __invocationInfo = value; } } + + /// + /// cancellation delegate. Stops the cmdlet when called. + /// + global::System.Action Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener.Cancel => _cancellationTokenSource.Cancel; + + /// cancellation token. + global::System.Threading.CancellationToken Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener.Token => _cancellationTokenSource.Token; + + /// Backing field for property. + private string _name; + + /// Export Name. + [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "Export Name.")] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"Export Name.", + SerializedName = @"exportName", + PossibleTypes = new [] { typeof(string) })] + [global::System.Management.Automation.Alias("ExportName")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Path)] + public string Name { get => this._name; set => this._name = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport _parametersBody= new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.Export(); + + /// An export resource. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport ParametersBody { get => this._parametersBody; set => this._parametersBody = value; } + + /// + /// The instance of the that the remote call will use. + /// + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.HttpPipeline Pipeline { get; set; } + + /// The URI for the proxy server to use + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "The URI for the proxy server to use")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Uri Proxy { get; set; } + + /// Credentials for a proxy server to use for the remote call + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Credentials for a proxy server to use for the remote call")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Management.Automation.PSCredential ProxyCredential { get; set; } + + /// Use the default credentials for the proxy + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Use the default credentials for the proxy")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter ProxyUseDefaultCredentials { get; set; } + + /// The start date of recurrence. + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The start date of recurrence.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Body)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The start date of recurrence.", + SerializedName = @"from", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + public global::System.DateTime RecurrencePeriodFrom { get => ParametersBody.RecurrencePeriodFrom; set => ParametersBody.RecurrencePeriodFrom = value; } + + /// The end date of recurrence. + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The end date of recurrence.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Body)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The end date of recurrence.", + SerializedName = @"to", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + public global::System.DateTime RecurrencePeriodTo { get => ParametersBody.RecurrencePeriodTo ?? default(global::System.DateTime); set => ParametersBody.RecurrencePeriodTo = value; } + + /// The schedule recurrence. + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The schedule recurrence.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Body)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The schedule recurrence.", + SerializedName = @"recurrence", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType) })] + [global::System.Management.Automation.ArgumentCompleter(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType))] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType ScheduleRecurrence { get => ParametersBody.ScheduleRecurrence; set => ParametersBody.ScheduleRecurrence = value; } + + /// + /// The status of the export's schedule. If 'Inactive', the export's schedule is paused. + /// + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The status of the export's schedule. If 'Inactive', the export's schedule is paused.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Body)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The status of the export's schedule. If 'Inactive', the export's schedule is paused.", + SerializedName = @"status", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType) })] + [global::System.Management.Automation.ArgumentCompleter(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType))] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType ScheduleStatus { get => ParametersBody.ScheduleStatus ?? ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType)""); set => ParametersBody.ScheduleStatus = value; } + + /// Backing field for property. + private string _scope; + + /// + /// This parameter defines the scope of costmanagement from different perspectives 'Subscription','ResourceGroup' and 'Provide + /// Service'. + /// + [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "This parameter defines the scope of costmanagement from different perspectives 'Subscription','ResourceGroup' and 'Provide Service'.")] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"This parameter defines the scope of costmanagement from different perspectives 'Subscription','ResourceGroup' and 'Provide Service'.", + SerializedName = @"scope", + PossibleTypes = new [] { typeof(string) })] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Path)] + public string Scope { get => this._scope; set => this._scope = value; } + + /// The start date for export data. + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The start date for export data.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Body)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The start date for export data.", + SerializedName = @"from", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + public global::System.DateTime TimePeriodFrom { get => ParametersBody.TimePeriodFrom; set => ParametersBody.TimePeriodFrom = value; } + + /// The end date for export data. + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The end date for export data.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Body)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The end date for export data.", + SerializedName = @"to", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + public global::System.DateTime TimePeriodTo { get => ParametersBody.TimePeriodTo; set => ParametersBody.TimePeriodTo = value; } + + /// + /// overrideOnCreated will be called before the regular onCreated has been processed, allowing customization of what + /// happens on that response. Implement this method in a partial class to enable this behavior + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a from the remote call + /// /// Determines if the rest of the onCreated method should be processed, or if the method should + /// return immediately (set to true to skip further processing ) + + partial void overrideOnCreated(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + + /// + /// overrideOnDefault will be called before the regular onDefault has been processed, allowing customization of what + /// happens on that response. Implement this method in a partial class to enable this behavior + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a from the remote call + /// /// Determines if the rest of the onDefault method should be processed, or if the method should + /// return immediately (set to true to skip further processing ) + + partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + + /// + /// overrideOnOk will be called before the regular onOk has been processed, allowing customization of what happens + /// on that response. Implement this method in a partial class to enable this behavior + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a from the remote call + /// /// Determines if the rest of the onOk method should be processed, or if the method should return + /// immediately (set to true to skip further processing ) + + partial void overrideOnOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + + /// + /// (overrides the default BeginProcessing method in global::System.Management.Automation.PSCmdlet) + /// + protected override void BeginProcessing() + { + Module.Instance.SetProxyConfiguration(Proxy, ProxyCredential, ProxyUseDefaultCredentials); + if (Break) + { + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.AttachDebugger.Break(); + } + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletBeginProcessing).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + + /// Performs clean-up after the command execution + protected override void EndProcessing() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletEndProcessing).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + + /// Handles/Dispatches events during the call to the REST service. + /// The message id + /// The message cancellation token. When this call is cancelled, this should be true + /// Detailed message data for the message event. + /// + /// A that will be complete when handling of the message is completed. + /// + async global::System.Threading.Tasks.Task Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener.Signal(string id, global::System.Threading.CancellationToken token, global::System.Func messageData) + { + using( NoSynchronizationContext ) + { + if (token.IsCancellationRequested) + { + return ; + } + + switch ( id ) + { + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Verbose: + { + WriteVerbose($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Warning: + { + WriteWarning($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Information: + { + var data = messageData(); + WriteInformation(data, new[] { data.Message }); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Debug: + { + WriteDebug($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Error: + { + WriteError(new global::System.Management.Automation.ErrorRecord( new global::System.Exception(messageData().Message), string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null ) ); + return ; + } + } + await Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Module.Instance.Signal(id, token, messageData, (i,t,m) => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(i,t,()=> Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.EventDataConverter.ConvertFrom( m() ) as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.EventData ), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); + if (token.IsCancellationRequested) + { + return ; + } + WriteDebug($"{id}: {(messageData().Message ?? global::System.String.Empty)}"); + } + } + + /// + /// Intializes a new instance of the cmdlet class. + /// + public NewAzCostManagementExport_CreateExpanded() + { + + } + + /// Performs execution of the command. + protected override void ProcessRecord() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordStart).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + __processRecordId = System.Guid.NewGuid().ToString(); + try + { + // work + if (ShouldProcess($"Call remote 'ExportsCreateOrUpdate' operation")) + { + using( var asyncCommandRuntime = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.AsyncCommandRuntime(this, ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token) ) + { + asyncCommandRuntime.Wait( ProcessRecordAsync(),((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token); + } + } + } + catch (global::System.AggregateException aggregateException) + { + // unroll the inner exceptions to get the root cause + foreach( var innerException in aggregateException.Flatten().InnerExceptions ) + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletException, $"{innerException.GetType().Name} - {innerException.Message} : {innerException.StackTrace}").Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + // Write exception out to error channel. + WriteError( new global::System.Management.Automation.ErrorRecord(innerException,string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null) ); + } + } + catch (global::System.Exception exception) when ((exception as System.Management.Automation.PipelineStoppedException)== null || (exception as System.Management.Automation.PipelineStoppedException).InnerException != null) + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletException, $"{exception.GetType().Name} - {exception.Message} : {exception.StackTrace}").Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + // Write exception out to error channel. + WriteError( new global::System.Management.Automation.ErrorRecord(exception,string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null) ); + } + finally + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordEnd).Wait(); + } + } + + /// Performs execution of the command, working asynchronously if required. + /// + /// A that will be complete when handling of the method is completed. + /// + protected async global::System.Threading.Tasks.Task ProcessRecordAsync() + { + using( NoSynchronizationContext ) + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordAsyncStart); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletGetPipeline); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName); + if (null != HttpPipelinePrepend) + { + Pipeline.Prepend((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelinePrepend) ?? HttpPipelinePrepend); + } + if (null != HttpPipelineAppend) + { + Pipeline.Append((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelineAppend) ?? HttpPipelineAppend); + } + // get the client instance + try + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletBeforeAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + await this.Client.ExportsCreateOrUpdate(Scope, Name, ParametersBody, onOk, onCreated, onDefault, this, Pipeline); + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletAfterAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + catch (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.UndeclaredResponseException urexception) + { + WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { Scope=Scope,Name=Name,body=ParametersBody}) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(urexception.Message) { RecommendedAction = urexception.Action } + }); + } + finally + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordAsyncEnd); + } + } + } + + /// Interrupts currently running code within the command. + protected override void StopProcessing() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Cancel(); + base.StopProcessing(); + } + + /// a delegate that is called when the remote service returns 201 (Created). + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a from the remote call + /// + /// A that will be complete when handling of the method is completed. + /// + private async global::System.Threading.Tasks.Task onCreated(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + { + using( NoSynchronizationContext ) + { + var _returnNow = global::System.Threading.Tasks.Task.FromResult(false); + overrideOnCreated(responseMessage, response, ref _returnNow); + // if overrideOnCreated has returned true, then return right away. + if ((null != _returnNow && await _returnNow)) + { + return ; + } + // onCreated - response for 201 / application/json + // (await response) // should be Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport + WriteObject((await response)); + } + } + + /// + /// a delegate that is called when the remote service returns default (any response code not handled elsewhere). + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a from the remote call + /// + /// A that will be complete when handling of the method is completed. + /// + private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + { + using( NoSynchronizationContext ) + { + var _returnNow = global::System.Threading.Tasks.Task.FromResult(false); + overrideOnDefault(responseMessage, response, ref _returnNow); + // if overrideOnDefault has returned true, then return right away. + if ((null != _returnNow && await _returnNow)) + { + return ; + } + // Error Response : default + var code = (await response)?.Code; + var message = (await response)?.Message; + if ((null == code || null == message)) + { + // Unrecognized Response. Create an error record based on what we have. + var ex = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.RestException(responseMessage, await response); + WriteError( new global::System.Management.Automation.ErrorRecord(ex, ex.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { Scope=Scope, Name=Name, body=ParametersBody }) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(ex.Message) { RecommendedAction = ex.Action } + }); + } + else + { + WriteError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception($"[{code}] : {message}"), code?.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { Scope=Scope, Name=Name, body=ParametersBody }) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(message) { RecommendedAction = global::System.String.Empty } + }); + } + } + } + + /// a delegate that is called when the remote service returns 200 (OK). + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a from the remote call + /// + /// A that will be complete when handling of the method is completed. + /// + private async global::System.Threading.Tasks.Task onOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + { + using( NoSynchronizationContext ) + { + var _returnNow = global::System.Threading.Tasks.Task.FromResult(false); + overrideOnOk(responseMessage, response, ref _returnNow); + // if overrideOnOk has returned true, then return right away. + if ((null != _returnNow && await _returnNow)) + { + return ; + } + // onOk - response for 200 / application/json + // (await response) // should be Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport + WriteObject((await response)); + } + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/cmdlets/RemoveAzCostManagementExport_Delete.cs b/src/CostManagement/generated/cmdlets/RemoveAzCostManagementExport_Delete.cs new file mode 100644 index 000000000000..a8e1797641ac --- /dev/null +++ b/src/CostManagement/generated/cmdlets/RemoveAzCostManagementExport_Delete.cs @@ -0,0 +1,389 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Cmdlets +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The operation to delete a export. + /// + /// [OpenAPI] Exports_Delete=>DELETE:"/{scope}/providers/Microsoft.CostManagement/exports/{exportName}" + /// + [global::System.Management.Automation.Cmdlet(global::System.Management.Automation.VerbsCommon.Remove, @"AzCostManagementExport_Delete", SupportsShouldProcess = true)] + [global::System.Management.Automation.OutputType(typeof(bool))] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Description(@"The operation to delete a export.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Generated] + public partial class RemoveAzCostManagementExport_Delete : global::System.Management.Automation.PSCmdlet, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener + { + /// A unique id generatd for the this cmdlet when it is instantiated. + private string __correlationId = System.Guid.NewGuid().ToString(); + + /// A copy of the Invocation Info (necessary to allow asJob to clone this cmdlet) + private global::System.Management.Automation.InvocationInfo __invocationInfo; + + /// A unique id generatd for the this cmdlet when ProcessRecord() is called. + private string __processRecordId; + + /// + /// The for this operation. + /// + private global::System.Threading.CancellationTokenSource _cancellationTokenSource = new global::System.Threading.CancellationTokenSource(); + + /// Wait for .NET debugger to attach + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Wait for .NET debugger to attach")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter Break { get; set; } + + /// The reference to the client API class. + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.CostManagement Client => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Module.Instance.ClientAPI; + + /// + /// The credentials, account, tenant, and subscription used for communication with Azure + /// + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The credentials, account, tenant, and subscription used for communication with Azure.")] + [global::System.Management.Automation.ValidateNotNull] + [global::System.Management.Automation.Alias("AzureRMContext", "AzureCredential")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Azure)] + public global::System.Management.Automation.PSObject DefaultProfile { get; set; } + + /// SendAsync Pipeline Steps to be appended to the front of the pipeline + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be appended to the front of the pipeline")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[] HttpPipelineAppend { get; set; } + + /// SendAsync Pipeline Steps to be prepended to the front of the pipeline + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be prepended to the front of the pipeline")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[] HttpPipelinePrepend { get; set; } + + /// Accessor for our copy of the InvocationInfo. + public global::System.Management.Automation.InvocationInfo InvocationInformation { get => __invocationInfo = __invocationInfo ?? this.MyInvocation ; set { __invocationInfo = value; } } + + /// + /// cancellation delegate. Stops the cmdlet when called. + /// + global::System.Action Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener.Cancel => _cancellationTokenSource.Cancel; + + /// cancellation token. + global::System.Threading.CancellationToken Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener.Token => _cancellationTokenSource.Token; + + /// Backing field for property. + private string _name; + + /// Export Name. + [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "Export Name.")] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"Export Name.", + SerializedName = @"exportName", + PossibleTypes = new [] { typeof(string) })] + [global::System.Management.Automation.Alias("ExportName")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Path)] + public string Name { get => this._name; set => this._name = value; } + + /// + /// When specified, forces the cmdlet return a 'bool' given that there isn't a return type by default. + /// + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "Returns true when the command succeeds")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter PassThru { get; set; } + + /// + /// The instance of the that the remote call will use. + /// + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.HttpPipeline Pipeline { get; set; } + + /// The URI for the proxy server to use + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "The URI for the proxy server to use")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Uri Proxy { get; set; } + + /// Credentials for a proxy server to use for the remote call + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Credentials for a proxy server to use for the remote call")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Management.Automation.PSCredential ProxyCredential { get; set; } + + /// Use the default credentials for the proxy + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Use the default credentials for the proxy")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter ProxyUseDefaultCredentials { get; set; } + + /// Backing field for property. + private string _scope; + + /// + /// This parameter defines the scope of costmanagement from different perspectives 'Subscription','ResourceGroup' and 'Provide + /// Service'. + /// + [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "This parameter defines the scope of costmanagement from different perspectives 'Subscription','ResourceGroup' and 'Provide Service'.")] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"This parameter defines the scope of costmanagement from different perspectives 'Subscription','ResourceGroup' and 'Provide Service'.", + SerializedName = @"scope", + PossibleTypes = new [] { typeof(string) })] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Path)] + public string Scope { get => this._scope; set => this._scope = value; } + + /// + /// overrideOnDefault will be called before the regular onDefault has been processed, allowing customization of what + /// happens on that response. Implement this method in a partial class to enable this behavior + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a from the remote call + /// /// Determines if the rest of the onDefault method should be processed, or if the method should + /// return immediately (set to true to skip further processing ) + + partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + + /// + /// overrideOnOk will be called before the regular onOk has been processed, allowing customization of what happens + /// on that response. Implement this method in a partial class to enable this behavior + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// /// Determines if the rest of the onOk method should be processed, or if the method should return + /// immediately (set to true to skip further processing ) + + partial void overrideOnOk(global::System.Net.Http.HttpResponseMessage responseMessage, ref global::System.Threading.Tasks.Task returnNow); + + /// + /// (overrides the default BeginProcessing method in global::System.Management.Automation.PSCmdlet) + /// + protected override void BeginProcessing() + { + Module.Instance.SetProxyConfiguration(Proxy, ProxyCredential, ProxyUseDefaultCredentials); + if (Break) + { + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.AttachDebugger.Break(); + } + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletBeginProcessing).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + + /// Performs clean-up after the command execution + protected override void EndProcessing() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletEndProcessing).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + + /// Handles/Dispatches events during the call to the REST service. + /// The message id + /// The message cancellation token. When this call is cancelled, this should be true + /// Detailed message data for the message event. + /// + /// A that will be complete when handling of the message is completed. + /// + async global::System.Threading.Tasks.Task Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener.Signal(string id, global::System.Threading.CancellationToken token, global::System.Func messageData) + { + using( NoSynchronizationContext ) + { + if (token.IsCancellationRequested) + { + return ; + } + + switch ( id ) + { + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Verbose: + { + WriteVerbose($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Warning: + { + WriteWarning($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Information: + { + var data = messageData(); + WriteInformation(data, new[] { data.Message }); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Debug: + { + WriteDebug($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Error: + { + WriteError(new global::System.Management.Automation.ErrorRecord( new global::System.Exception(messageData().Message), string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null ) ); + return ; + } + } + await Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Module.Instance.Signal(id, token, messageData, (i,t,m) => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(i,t,()=> Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.EventDataConverter.ConvertFrom( m() ) as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.EventData ), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); + if (token.IsCancellationRequested) + { + return ; + } + WriteDebug($"{id}: {(messageData().Message ?? global::System.String.Empty)}"); + } + } + + /// Performs execution of the command. + protected override void ProcessRecord() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordStart).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + __processRecordId = System.Guid.NewGuid().ToString(); + try + { + // work + if (ShouldProcess($"Call remote 'ExportsDelete' operation")) + { + using( var asyncCommandRuntime = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.AsyncCommandRuntime(this, ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token) ) + { + asyncCommandRuntime.Wait( ProcessRecordAsync(),((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token); + } + } + } + catch (global::System.AggregateException aggregateException) + { + // unroll the inner exceptions to get the root cause + foreach( var innerException in aggregateException.Flatten().InnerExceptions ) + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletException, $"{innerException.GetType().Name} - {innerException.Message} : {innerException.StackTrace}").Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + // Write exception out to error channel. + WriteError( new global::System.Management.Automation.ErrorRecord(innerException,string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null) ); + } + } + catch (global::System.Exception exception) when ((exception as System.Management.Automation.PipelineStoppedException)== null || (exception as System.Management.Automation.PipelineStoppedException).InnerException != null) + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletException, $"{exception.GetType().Name} - {exception.Message} : {exception.StackTrace}").Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + // Write exception out to error channel. + WriteError( new global::System.Management.Automation.ErrorRecord(exception,string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null) ); + } + finally + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordEnd).Wait(); + } + } + + /// Performs execution of the command, working asynchronously if required. + /// + /// A that will be complete when handling of the method is completed. + /// + protected async global::System.Threading.Tasks.Task ProcessRecordAsync() + { + using( NoSynchronizationContext ) + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordAsyncStart); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletGetPipeline); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName); + if (null != HttpPipelinePrepend) + { + Pipeline.Prepend((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelinePrepend) ?? HttpPipelinePrepend); + } + if (null != HttpPipelineAppend) + { + Pipeline.Append((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelineAppend) ?? HttpPipelineAppend); + } + // get the client instance + try + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletBeforeAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + await this.Client.ExportsDelete(Scope, Name, onOk, onDefault, this, Pipeline); + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletAfterAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + catch (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.UndeclaredResponseException urexception) + { + WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { Scope=Scope,Name=Name}) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(urexception.Message) { RecommendedAction = urexception.Action } + }); + } + finally + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordAsyncEnd); + } + } + } + + /// + /// Intializes a new instance of the cmdlet class. + /// + public RemoveAzCostManagementExport_Delete() + { + + } + + /// Interrupts currently running code within the command. + protected override void StopProcessing() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Cancel(); + base.StopProcessing(); + } + + /// + /// a delegate that is called when the remote service returns default (any response code not handled elsewhere). + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a from the remote call + /// + /// A that will be complete when handling of the method is completed. + /// + private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + { + using( NoSynchronizationContext ) + { + var _returnNow = global::System.Threading.Tasks.Task.FromResult(false); + overrideOnDefault(responseMessage, response, ref _returnNow); + // if overrideOnDefault has returned true, then return right away. + if ((null != _returnNow && await _returnNow)) + { + return ; + } + // Error Response : default + var code = (await response)?.Code; + var message = (await response)?.Message; + if ((null == code || null == message)) + { + // Unrecognized Response. Create an error record based on what we have. + var ex = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.RestException(responseMessage, await response); + WriteError( new global::System.Management.Automation.ErrorRecord(ex, ex.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { Scope=Scope, Name=Name }) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(ex.Message) { RecommendedAction = ex.Action } + }); + } + else + { + WriteError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception($"[{code}] : {message}"), code?.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { Scope=Scope, Name=Name }) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(message) { RecommendedAction = global::System.String.Empty } + }); + } + } + } + + /// a delegate that is called when the remote service returns 200 (OK). + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// + /// A that will be complete when handling of the method is completed. + /// + private async global::System.Threading.Tasks.Task onOk(global::System.Net.Http.HttpResponseMessage responseMessage) + { + using( NoSynchronizationContext ) + { + var _returnNow = global::System.Threading.Tasks.Task.FromResult(false); + overrideOnOk(responseMessage, ref _returnNow); + // if overrideOnOk has returned true, then return right away. + if ((null != _returnNow && await _returnNow)) + { + return ; + } + // onOk - response for 200 / + if (true == MyInvocation?.BoundParameters?.ContainsKey("PassThru")) + { + WriteObject(true); + } + } + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/cmdlets/RemoveAzCostManagementExport_DeleteViaIdentity.cs b/src/CostManagement/generated/cmdlets/RemoveAzCostManagementExport_DeleteViaIdentity.cs new file mode 100644 index 000000000000..ec1869a34b86 --- /dev/null +++ b/src/CostManagement/generated/cmdlets/RemoveAzCostManagementExport_DeleteViaIdentity.cs @@ -0,0 +1,381 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Cmdlets +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// The operation to delete a export. + /// + /// [OpenAPI] Exports_Delete=>DELETE:"/{scope}/providers/Microsoft.CostManagement/exports/{exportName}" + /// + [global::System.Management.Automation.Cmdlet(global::System.Management.Automation.VerbsCommon.Remove, @"AzCostManagementExport_DeleteViaIdentity", SupportsShouldProcess = true)] + [global::System.Management.Automation.OutputType(typeof(bool))] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Description(@"The operation to delete a export.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Generated] + public partial class RemoveAzCostManagementExport_DeleteViaIdentity : global::System.Management.Automation.PSCmdlet, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener + { + /// A unique id generatd for the this cmdlet when it is instantiated. + private string __correlationId = System.Guid.NewGuid().ToString(); + + /// A copy of the Invocation Info (necessary to allow asJob to clone this cmdlet) + private global::System.Management.Automation.InvocationInfo __invocationInfo; + + /// A unique id generatd for the this cmdlet when ProcessRecord() is called. + private string __processRecordId; + + /// + /// The for this operation. + /// + private global::System.Threading.CancellationTokenSource _cancellationTokenSource = new global::System.Threading.CancellationTokenSource(); + + /// Wait for .NET debugger to attach + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Wait for .NET debugger to attach")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter Break { get; set; } + + /// The reference to the client API class. + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.CostManagement Client => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Module.Instance.ClientAPI; + + /// + /// The credentials, account, tenant, and subscription used for communication with Azure + /// + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The credentials, account, tenant, and subscription used for communication with Azure.")] + [global::System.Management.Automation.ValidateNotNull] + [global::System.Management.Automation.Alias("AzureRMContext", "AzureCredential")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Azure)] + public global::System.Management.Automation.PSObject DefaultProfile { get; set; } + + /// SendAsync Pipeline Steps to be appended to the front of the pipeline + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be appended to the front of the pipeline")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[] HttpPipelineAppend { get; set; } + + /// SendAsync Pipeline Steps to be prepended to the front of the pipeline + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be prepended to the front of the pipeline")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[] HttpPipelinePrepend { get; set; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity _inputObject; + + /// Identity Parameter + [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "Identity Parameter", ValueFromPipeline = true)] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Path)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity InputObject { get => this._inputObject; set => this._inputObject = value; } + + /// Accessor for our copy of the InvocationInfo. + public global::System.Management.Automation.InvocationInfo InvocationInformation { get => __invocationInfo = __invocationInfo ?? this.MyInvocation ; set { __invocationInfo = value; } } + + /// + /// cancellation delegate. Stops the cmdlet when called. + /// + global::System.Action Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener.Cancel => _cancellationTokenSource.Cancel; + + /// cancellation token. + global::System.Threading.CancellationToken Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener.Token => _cancellationTokenSource.Token; + + /// + /// When specified, forces the cmdlet return a 'bool' given that there isn't a return type by default. + /// + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "Returns true when the command succeeds")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter PassThru { get; set; } + + /// + /// The instance of the that the remote call will use. + /// + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.HttpPipeline Pipeline { get; set; } + + /// The URI for the proxy server to use + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "The URI for the proxy server to use")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Uri Proxy { get; set; } + + /// Credentials for a proxy server to use for the remote call + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Credentials for a proxy server to use for the remote call")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Management.Automation.PSCredential ProxyCredential { get; set; } + + /// Use the default credentials for the proxy + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Use the default credentials for the proxy")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter ProxyUseDefaultCredentials { get; set; } + + /// + /// overrideOnDefault will be called before the regular onDefault has been processed, allowing customization of what + /// happens on that response. Implement this method in a partial class to enable this behavior + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a from the remote call + /// /// Determines if the rest of the onDefault method should be processed, or if the method should + /// return immediately (set to true to skip further processing ) + + partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + + /// + /// overrideOnOk will be called before the regular onOk has been processed, allowing customization of what happens + /// on that response. Implement this method in a partial class to enable this behavior + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// /// Determines if the rest of the onOk method should be processed, or if the method should return + /// immediately (set to true to skip further processing ) + + partial void overrideOnOk(global::System.Net.Http.HttpResponseMessage responseMessage, ref global::System.Threading.Tasks.Task returnNow); + + /// + /// (overrides the default BeginProcessing method in global::System.Management.Automation.PSCmdlet) + /// + protected override void BeginProcessing() + { + Module.Instance.SetProxyConfiguration(Proxy, ProxyCredential, ProxyUseDefaultCredentials); + if (Break) + { + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.AttachDebugger.Break(); + } + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletBeginProcessing).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + + /// Performs clean-up after the command execution + protected override void EndProcessing() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletEndProcessing).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + + /// Handles/Dispatches events during the call to the REST service. + /// The message id + /// The message cancellation token. When this call is cancelled, this should be true + /// Detailed message data for the message event. + /// + /// A that will be complete when handling of the message is completed. + /// + async global::System.Threading.Tasks.Task Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener.Signal(string id, global::System.Threading.CancellationToken token, global::System.Func messageData) + { + using( NoSynchronizationContext ) + { + if (token.IsCancellationRequested) + { + return ; + } + + switch ( id ) + { + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Verbose: + { + WriteVerbose($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Warning: + { + WriteWarning($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Information: + { + var data = messageData(); + WriteInformation(data, new[] { data.Message }); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Debug: + { + WriteDebug($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Error: + { + WriteError(new global::System.Management.Automation.ErrorRecord( new global::System.Exception(messageData().Message), string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null ) ); + return ; + } + } + await Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Module.Instance.Signal(id, token, messageData, (i,t,m) => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(i,t,()=> Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.EventDataConverter.ConvertFrom( m() ) as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.EventData ), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); + if (token.IsCancellationRequested) + { + return ; + } + WriteDebug($"{id}: {(messageData().Message ?? global::System.String.Empty)}"); + } + } + + /// Performs execution of the command. + protected override void ProcessRecord() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordStart).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + __processRecordId = System.Guid.NewGuid().ToString(); + try + { + // work + if (ShouldProcess($"Call remote 'ExportsDelete' operation")) + { + using( var asyncCommandRuntime = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.AsyncCommandRuntime(this, ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token) ) + { + asyncCommandRuntime.Wait( ProcessRecordAsync(),((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token); + } + } + } + catch (global::System.AggregateException aggregateException) + { + // unroll the inner exceptions to get the root cause + foreach( var innerException in aggregateException.Flatten().InnerExceptions ) + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletException, $"{innerException.GetType().Name} - {innerException.Message} : {innerException.StackTrace}").Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + // Write exception out to error channel. + WriteError( new global::System.Management.Automation.ErrorRecord(innerException,string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null) ); + } + } + catch (global::System.Exception exception) when ((exception as System.Management.Automation.PipelineStoppedException)== null || (exception as System.Management.Automation.PipelineStoppedException).InnerException != null) + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletException, $"{exception.GetType().Name} - {exception.Message} : {exception.StackTrace}").Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + // Write exception out to error channel. + WriteError( new global::System.Management.Automation.ErrorRecord(exception,string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null) ); + } + finally + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordEnd).Wait(); + } + } + + /// Performs execution of the command, working asynchronously if required. + /// + /// A that will be complete when handling of the method is completed. + /// + protected async global::System.Threading.Tasks.Task ProcessRecordAsync() + { + using( NoSynchronizationContext ) + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordAsyncStart); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletGetPipeline); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName); + if (null != HttpPipelinePrepend) + { + Pipeline.Prepend((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelinePrepend) ?? HttpPipelinePrepend); + } + if (null != HttpPipelineAppend) + { + Pipeline.Append((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelineAppend) ?? HttpPipelineAppend); + } + // get the client instance + try + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletBeforeAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + if (InputObject?.Id != null) + { + await this.Client.ExportsDeleteViaIdentity(InputObject.Id, onOk, onDefault, this, Pipeline); + } + else + { + // try to call with PATH parameters from Input Object + if (null == InputObject.Scope) + { + ThrowTerminatingError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception("InputObject has null value for InputObject.Scope"),string.Empty, global::System.Management.Automation.ErrorCategory.InvalidArgument, InputObject) ); + } + if (null == InputObject.ExportName) + { + ThrowTerminatingError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception("InputObject has null value for InputObject.ExportName"),string.Empty, global::System.Management.Automation.ErrorCategory.InvalidArgument, InputObject) ); + } + await this.Client.ExportsDelete(InputObject.Scope ?? null, InputObject.ExportName ?? null, onOk, onDefault, this, Pipeline); + } + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletAfterAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + catch (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.UndeclaredResponseException urexception) + { + WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(urexception.Message) { RecommendedAction = urexception.Action } + }); + } + finally + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordAsyncEnd); + } + } + } + + /// + /// Intializes a new instance of the cmdlet class. + /// + public RemoveAzCostManagementExport_DeleteViaIdentity() + { + + } + + /// Interrupts currently running code within the command. + protected override void StopProcessing() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Cancel(); + base.StopProcessing(); + } + + /// + /// a delegate that is called when the remote service returns default (any response code not handled elsewhere). + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a from the remote call + /// + /// A that will be complete when handling of the method is completed. + /// + private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + { + using( NoSynchronizationContext ) + { + var _returnNow = global::System.Threading.Tasks.Task.FromResult(false); + overrideOnDefault(responseMessage, response, ref _returnNow); + // if overrideOnDefault has returned true, then return right away. + if ((null != _returnNow && await _returnNow)) + { + return ; + } + // Error Response : default + var code = (await response)?.Code; + var message = (await response)?.Message; + if ((null == code || null == message)) + { + // Unrecognized Response. Create an error record based on what we have. + var ex = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.RestException(responseMessage, await response); + WriteError( new global::System.Management.Automation.ErrorRecord(ex, ex.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(ex.Message) { RecommendedAction = ex.Action } + }); + } + else + { + WriteError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception($"[{code}] : {message}"), code?.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(message) { RecommendedAction = global::System.String.Empty } + }); + } + } + } + + /// a delegate that is called when the remote service returns 200 (OK). + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// + /// A that will be complete when handling of the method is completed. + /// + private async global::System.Threading.Tasks.Task onOk(global::System.Net.Http.HttpResponseMessage responseMessage) + { + using( NoSynchronizationContext ) + { + var _returnNow = global::System.Threading.Tasks.Task.FromResult(false); + overrideOnOk(responseMessage, ref _returnNow); + // if overrideOnOk has returned true, then return right away. + if ((null != _returnNow && await _returnNow)) + { + return ; + } + // onOk - response for 200 / + if (true == MyInvocation?.BoundParameters?.ContainsKey("PassThru")) + { + WriteObject(true); + } + } + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/cmdlets/UpdateAzCostManagementExport_UpdateExpanded.cs b/src/CostManagement/generated/cmdlets/UpdateAzCostManagementExport_UpdateExpanded.cs new file mode 100644 index 000000000000..e823e2ae97cb --- /dev/null +++ b/src/CostManagement/generated/cmdlets/UpdateAzCostManagementExport_UpdateExpanded.cs @@ -0,0 +1,615 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Cmdlets +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// + /// The operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain + /// the latest eTag by performing a get operation. Create operation does not require eTag. + /// + /// + /// [OpenAPI] Exports_CreateOrUpdate=>PUT:"/{scope}/providers/Microsoft.CostManagement/exports/{exportName}" + /// + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.InternalExport] + [global::System.Management.Automation.Cmdlet(global::System.Management.Automation.VerbsData.Update, @"AzCostManagementExport_UpdateExpanded", SupportsShouldProcess = true)] + [global::System.Management.Automation.OutputType(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport))] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Description(@"The operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Generated] + public partial class UpdateAzCostManagementExport_UpdateExpanded : global::System.Management.Automation.PSCmdlet, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener + { + /// A unique id generatd for the this cmdlet when it is instantiated. + private string __correlationId = System.Guid.NewGuid().ToString(); + + /// A copy of the Invocation Info (necessary to allow asJob to clone this cmdlet) + private global::System.Management.Automation.InvocationInfo __invocationInfo; + + /// A unique id generatd for the this cmdlet when ProcessRecord() is called. + private string __processRecordId; + + /// + /// The for this operation. + /// + private global::System.Threading.CancellationTokenSource _cancellationTokenSource = new global::System.Threading.CancellationTokenSource(); + + /// Wait for .NET debugger to attach + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Wait for .NET debugger to attach")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter Break { get; set; } + + /// The reference to the client API class. + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.CostManagement Client => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Module.Instance.ClientAPI; + + /// + /// Array of column names to be included in the export. If not provided then the export will include all available columns. + /// The available columns can vary by customer channel (see examples). + /// + [global::System.Management.Automation.AllowEmptyCollection] + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "Array of column names to be included in the export. If not provided then the export will include all available columns. The available columns can vary by customer channel (see examples).")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Body)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Array of column names to be included in the export. If not provided then the export will include all available columns. The available columns can vary by customer channel (see examples).", + SerializedName = @"columns", + PossibleTypes = new [] { typeof(string) })] + public string[] ConfigurationColumn { get => ParametersBody.ConfigurationColumn ?? null /* arrayOf */; set => ParametersBody.ConfigurationColumn = value; } + + /// The granularity of rows in the export. Currently only 'Daily' is supported. + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The granularity of rows in the export. Currently only 'Daily' is supported.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Body)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The granularity of rows in the export. Currently only 'Daily' is supported.", + SerializedName = @"granularity", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType) })] + [global::System.Management.Automation.ArgumentCompleter(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType))] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType DataSetGranularity { get => ParametersBody.DataSetGranularity ?? ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType)""); set => ParametersBody.DataSetGranularity = value; } + + /// + /// The credentials, account, tenant, and subscription used for communication with Azure + /// + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The credentials, account, tenant, and subscription used for communication with Azure.")] + [global::System.Management.Automation.ValidateNotNull] + [global::System.Management.Automation.Alias("AzureRMContext", "AzureCredential")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Azure)] + public global::System.Management.Automation.PSObject DefaultProfile { get; set; } + + /// + /// The time frame for pulling data for the export. If custom, then a specific time period must be provided. + /// + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The time frame for pulling data for the export. If custom, then a specific time period must be provided.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Body)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The time frame for pulling data for the export. If custom, then a specific time period must be provided.", + SerializedName = @"timeframe", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType) })] + [global::System.Management.Automation.ArgumentCompleter(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType))] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType DefinitionTimeframe { get => ParametersBody.DefinitionTimeframe; set => ParametersBody.DefinitionTimeframe = value; } + + /// + /// The type of the export. Note that 'Usage' is equivalent to 'ActualCost' and is applicable to exports that do not yet provide + /// data for charges or amortization for service reservations. + /// + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The type of the export. Note that 'Usage' is equivalent to 'ActualCost' and is applicable to exports that do not yet provide data for charges or amortization for service reservations.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Body)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The type of the export. Note that 'Usage' is equivalent to 'ActualCost' and is applicable to exports that do not yet provide data for charges or amortization for service reservations.", + SerializedName = @"type", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType) })] + [global::System.Management.Automation.ArgumentCompleter(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType))] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType DefinitionType { get => ParametersBody.DefinitionType; set => ParametersBody.DefinitionType = value; } + + /// The name of the container where exports will be uploaded. + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The name of the container where exports will be uploaded.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Body)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The name of the container where exports will be uploaded.", + SerializedName = @"container", + PossibleTypes = new [] { typeof(string) })] + public string DestinationContainer { get => ParametersBody.DestinationContainer ?? null; set => ParametersBody.DestinationContainer = value; } + + /// The resource id of the storage account where exports will be delivered. + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The resource id of the storage account where exports will be delivered.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Body)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The resource id of the storage account where exports will be delivered.", + SerializedName = @"resourceId", + PossibleTypes = new [] { typeof(string) })] + public string DestinationResourceId { get => ParametersBody.DestinationResourceId ?? null; set => ParametersBody.DestinationResourceId = value; } + + /// The name of the directory where exports will be uploaded. + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The name of the directory where exports will be uploaded.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Body)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The name of the directory where exports will be uploaded.", + SerializedName = @"rootFolderPath", + PossibleTypes = new [] { typeof(string) })] + public string DestinationRootFolderPath { get => ParametersBody.DestinationRootFolderPath ?? null; set => ParametersBody.DestinationRootFolderPath = value; } + + /// + /// eTag of the resource. To handle concurrent update scenario, this field will be used to determine whether the user is updating + /// the latest version or not. + /// + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "eTag of the resource. To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Body)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"eTag of the resource. To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not.", + SerializedName = @"eTag", + PossibleTypes = new [] { typeof(string) })] + public string ETag { get => ParametersBody.ETag ?? null; set => ParametersBody.ETag = value; } + + /// The format of the export being delivered. Currently only 'Csv' is supported. + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The format of the export being delivered. Currently only 'Csv' is supported.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Body)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The format of the export being delivered. Currently only 'Csv' is supported.", + SerializedName = @"format", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType) })] + [global::System.Management.Automation.ArgumentCompleter(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType))] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType Format { get => ParametersBody.Format ?? ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType)""); set => ParametersBody.Format = value; } + + /// SendAsync Pipeline Steps to be appended to the front of the pipeline + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be appended to the front of the pipeline")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[] HttpPipelineAppend { get; set; } + + /// SendAsync Pipeline Steps to be prepended to the front of the pipeline + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be prepended to the front of the pipeline")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[] HttpPipelinePrepend { get; set; } + + /// Accessor for our copy of the InvocationInfo. + public global::System.Management.Automation.InvocationInfo InvocationInformation { get => __invocationInfo = __invocationInfo ?? this.MyInvocation ; set { __invocationInfo = value; } } + + /// + /// cancellation delegate. Stops the cmdlet when called. + /// + global::System.Action Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener.Cancel => _cancellationTokenSource.Cancel; + + /// cancellation token. + global::System.Threading.CancellationToken Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener.Token => _cancellationTokenSource.Token; + + /// Backing field for property. + private string _name; + + /// Export Name. + [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "Export Name.")] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"Export Name.", + SerializedName = @"exportName", + PossibleTypes = new [] { typeof(string) })] + [global::System.Management.Automation.Alias("ExportName")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Path)] + public string Name { get => this._name; set => this._name = value; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport _parametersBody= new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.Export(); + + /// An export resource. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport ParametersBody { get => this._parametersBody; set => this._parametersBody = value; } + + /// + /// The instance of the that the remote call will use. + /// + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.HttpPipeline Pipeline { get; set; } + + /// The URI for the proxy server to use + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "The URI for the proxy server to use")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Uri Proxy { get; set; } + + /// Credentials for a proxy server to use for the remote call + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Credentials for a proxy server to use for the remote call")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Management.Automation.PSCredential ProxyCredential { get; set; } + + /// Use the default credentials for the proxy + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Use the default credentials for the proxy")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter ProxyUseDefaultCredentials { get; set; } + + /// The start date of recurrence. + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The start date of recurrence.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Body)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The start date of recurrence.", + SerializedName = @"from", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + public global::System.DateTime RecurrencePeriodFrom { get => ParametersBody.RecurrencePeriodFrom; set => ParametersBody.RecurrencePeriodFrom = value; } + + /// The end date of recurrence. + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The end date of recurrence.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Body)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The end date of recurrence.", + SerializedName = @"to", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + public global::System.DateTime RecurrencePeriodTo { get => ParametersBody.RecurrencePeriodTo ?? default(global::System.DateTime); set => ParametersBody.RecurrencePeriodTo = value; } + + /// The schedule recurrence. + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The schedule recurrence.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Body)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The schedule recurrence.", + SerializedName = @"recurrence", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType) })] + [global::System.Management.Automation.ArgumentCompleter(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType))] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType ScheduleRecurrence { get => ParametersBody.ScheduleRecurrence; set => ParametersBody.ScheduleRecurrence = value; } + + /// + /// The status of the export's schedule. If 'Inactive', the export's schedule is paused. + /// + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The status of the export's schedule. If 'Inactive', the export's schedule is paused.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Body)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The status of the export's schedule. If 'Inactive', the export's schedule is paused.", + SerializedName = @"status", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType) })] + [global::System.Management.Automation.ArgumentCompleter(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType))] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType ScheduleStatus { get => ParametersBody.ScheduleStatus ?? ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType)""); set => ParametersBody.ScheduleStatus = value; } + + /// Backing field for property. + private string _scope; + + /// + /// This parameter defines the scope of costmanagement from different perspectives 'Subscription','ResourceGroup' and 'Provide + /// Service'. + /// + [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "This parameter defines the scope of costmanagement from different perspectives 'Subscription','ResourceGroup' and 'Provide Service'.")] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"This parameter defines the scope of costmanagement from different perspectives 'Subscription','ResourceGroup' and 'Provide Service'.", + SerializedName = @"scope", + PossibleTypes = new [] { typeof(string) })] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Path)] + public string Scope { get => this._scope; set => this._scope = value; } + + /// The start date for export data. + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The start date for export data.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Body)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The start date for export data.", + SerializedName = @"from", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + public global::System.DateTime TimePeriodFrom { get => ParametersBody.TimePeriodFrom; set => ParametersBody.TimePeriodFrom = value; } + + /// The end date for export data. + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The end date for export data.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Body)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The end date for export data.", + SerializedName = @"to", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + public global::System.DateTime TimePeriodTo { get => ParametersBody.TimePeriodTo; set => ParametersBody.TimePeriodTo = value; } + + /// + /// overrideOnCreated will be called before the regular onCreated has been processed, allowing customization of what + /// happens on that response. Implement this method in a partial class to enable this behavior + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a from the remote call + /// /// Determines if the rest of the onCreated method should be processed, or if the method should + /// return immediately (set to true to skip further processing ) + + partial void overrideOnCreated(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + + /// + /// overrideOnDefault will be called before the regular onDefault has been processed, allowing customization of what + /// happens on that response. Implement this method in a partial class to enable this behavior + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a from the remote call + /// /// Determines if the rest of the onDefault method should be processed, or if the method should + /// return immediately (set to true to skip further processing ) + + partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + + /// + /// overrideOnOk will be called before the regular onOk has been processed, allowing customization of what happens + /// on that response. Implement this method in a partial class to enable this behavior + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a from the remote call + /// /// Determines if the rest of the onOk method should be processed, or if the method should return + /// immediately (set to true to skip further processing ) + + partial void overrideOnOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + + /// + /// (overrides the default BeginProcessing method in global::System.Management.Automation.PSCmdlet) + /// + protected override void BeginProcessing() + { + Module.Instance.SetProxyConfiguration(Proxy, ProxyCredential, ProxyUseDefaultCredentials); + if (Break) + { + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.AttachDebugger.Break(); + } + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletBeginProcessing).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + + /// Performs clean-up after the command execution + protected override void EndProcessing() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletEndProcessing).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + + /// Handles/Dispatches events during the call to the REST service. + /// The message id + /// The message cancellation token. When this call is cancelled, this should be true + /// Detailed message data for the message event. + /// + /// A that will be complete when handling of the message is completed. + /// + async global::System.Threading.Tasks.Task Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener.Signal(string id, global::System.Threading.CancellationToken token, global::System.Func messageData) + { + using( NoSynchronizationContext ) + { + if (token.IsCancellationRequested) + { + return ; + } + + switch ( id ) + { + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Verbose: + { + WriteVerbose($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Warning: + { + WriteWarning($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Information: + { + var data = messageData(); + WriteInformation(data, new[] { data.Message }); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Debug: + { + WriteDebug($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Error: + { + WriteError(new global::System.Management.Automation.ErrorRecord( new global::System.Exception(messageData().Message), string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null ) ); + return ; + } + } + await Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Module.Instance.Signal(id, token, messageData, (i,t,m) => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(i,t,()=> Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.EventDataConverter.ConvertFrom( m() ) as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.EventData ), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); + if (token.IsCancellationRequested) + { + return ; + } + WriteDebug($"{id}: {(messageData().Message ?? global::System.String.Empty)}"); + } + } + + /// Performs execution of the command. + protected override void ProcessRecord() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordStart).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + __processRecordId = System.Guid.NewGuid().ToString(); + try + { + // work + if (ShouldProcess($"Call remote 'ExportsCreateOrUpdate' operation")) + { + using( var asyncCommandRuntime = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.AsyncCommandRuntime(this, ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token) ) + { + asyncCommandRuntime.Wait( ProcessRecordAsync(),((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token); + } + } + } + catch (global::System.AggregateException aggregateException) + { + // unroll the inner exceptions to get the root cause + foreach( var innerException in aggregateException.Flatten().InnerExceptions ) + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletException, $"{innerException.GetType().Name} - {innerException.Message} : {innerException.StackTrace}").Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + // Write exception out to error channel. + WriteError( new global::System.Management.Automation.ErrorRecord(innerException,string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null) ); + } + } + catch (global::System.Exception exception) when ((exception as System.Management.Automation.PipelineStoppedException)== null || (exception as System.Management.Automation.PipelineStoppedException).InnerException != null) + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletException, $"{exception.GetType().Name} - {exception.Message} : {exception.StackTrace}").Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + // Write exception out to error channel. + WriteError( new global::System.Management.Automation.ErrorRecord(exception,string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null) ); + } + finally + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordEnd).Wait(); + } + } + + /// Performs execution of the command, working asynchronously if required. + /// + /// A that will be complete when handling of the method is completed. + /// + protected async global::System.Threading.Tasks.Task ProcessRecordAsync() + { + using( NoSynchronizationContext ) + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordAsyncStart); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletGetPipeline); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName); + if (null != HttpPipelinePrepend) + { + Pipeline.Prepend((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelinePrepend) ?? HttpPipelinePrepend); + } + if (null != HttpPipelineAppend) + { + Pipeline.Append((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelineAppend) ?? HttpPipelineAppend); + } + // get the client instance + try + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletBeforeAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + await this.Client.ExportsCreateOrUpdate(Scope, Name, ParametersBody, onOk, onCreated, onDefault, this, Pipeline); + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletAfterAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + catch (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.UndeclaredResponseException urexception) + { + WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { Scope=Scope,Name=Name,body=ParametersBody}) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(urexception.Message) { RecommendedAction = urexception.Action } + }); + } + finally + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordAsyncEnd); + } + } + } + + /// Interrupts currently running code within the command. + protected override void StopProcessing() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Cancel(); + base.StopProcessing(); + } + + /// + /// Intializes a new instance of the cmdlet class. + /// + public UpdateAzCostManagementExport_UpdateExpanded() + { + + } + + /// a delegate that is called when the remote service returns 201 (Created). + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a from the remote call + /// + /// A that will be complete when handling of the method is completed. + /// + private async global::System.Threading.Tasks.Task onCreated(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + { + using( NoSynchronizationContext ) + { + var _returnNow = global::System.Threading.Tasks.Task.FromResult(false); + overrideOnCreated(responseMessage, response, ref _returnNow); + // if overrideOnCreated has returned true, then return right away. + if ((null != _returnNow && await _returnNow)) + { + return ; + } + // onCreated - response for 201 / application/json + // (await response) // should be Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport + WriteObject((await response)); + } + } + + /// + /// a delegate that is called when the remote service returns default (any response code not handled elsewhere). + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a from the remote call + /// + /// A that will be complete when handling of the method is completed. + /// + private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + { + using( NoSynchronizationContext ) + { + var _returnNow = global::System.Threading.Tasks.Task.FromResult(false); + overrideOnDefault(responseMessage, response, ref _returnNow); + // if overrideOnDefault has returned true, then return right away. + if ((null != _returnNow && await _returnNow)) + { + return ; + } + // Error Response : default + var code = (await response)?.Code; + var message = (await response)?.Message; + if ((null == code || null == message)) + { + // Unrecognized Response. Create an error record based on what we have. + var ex = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.RestException(responseMessage, await response); + WriteError( new global::System.Management.Automation.ErrorRecord(ex, ex.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { Scope=Scope, Name=Name, body=ParametersBody }) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(ex.Message) { RecommendedAction = ex.Action } + }); + } + else + { + WriteError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception($"[{code}] : {message}"), code?.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { Scope=Scope, Name=Name, body=ParametersBody }) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(message) { RecommendedAction = global::System.String.Empty } + }); + } + } + } + + /// a delegate that is called when the remote service returns 200 (OK). + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a from the remote call + /// + /// A that will be complete when handling of the method is completed. + /// + private async global::System.Threading.Tasks.Task onOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + { + using( NoSynchronizationContext ) + { + var _returnNow = global::System.Threading.Tasks.Task.FromResult(false); + overrideOnOk(responseMessage, response, ref _returnNow); + // if overrideOnOk has returned true, then return right away. + if ((null != _returnNow && await _returnNow)) + { + return ; + } + // onOk - response for 200 / application/json + // (await response) // should be Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport + WriteObject((await response)); + } + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/cmdlets/UpdateAzCostManagementExport_UpdateViaIdentityExpanded.cs b/src/CostManagement/generated/cmdlets/UpdateAzCostManagementExport_UpdateViaIdentityExpanded.cs new file mode 100644 index 000000000000..1c248a86009f --- /dev/null +++ b/src/CostManagement/generated/cmdlets/UpdateAzCostManagementExport_UpdateViaIdentityExpanded.cs @@ -0,0 +1,607 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Cmdlets +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + /// + /// The operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain + /// the latest eTag by performing a get operation. Create operation does not require eTag. + /// + /// + /// [OpenAPI] Exports_CreateOrUpdate=>PUT:"/{scope}/providers/Microsoft.CostManagement/exports/{exportName}" + /// + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.InternalExport] + [global::System.Management.Automation.Cmdlet(global::System.Management.Automation.VerbsData.Update, @"AzCostManagementExport_UpdateViaIdentityExpanded", SupportsShouldProcess = true)] + [global::System.Management.Automation.OutputType(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport))] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Description(@"The operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Generated] + public partial class UpdateAzCostManagementExport_UpdateViaIdentityExpanded : global::System.Management.Automation.PSCmdlet, + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener + { + /// A unique id generatd for the this cmdlet when it is instantiated. + private string __correlationId = System.Guid.NewGuid().ToString(); + + /// A copy of the Invocation Info (necessary to allow asJob to clone this cmdlet) + private global::System.Management.Automation.InvocationInfo __invocationInfo; + + /// A unique id generatd for the this cmdlet when ProcessRecord() is called. + private string __processRecordId; + + /// + /// The for this operation. + /// + private global::System.Threading.CancellationTokenSource _cancellationTokenSource = new global::System.Threading.CancellationTokenSource(); + + /// Wait for .NET debugger to attach + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Wait for .NET debugger to attach")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter Break { get; set; } + + /// The reference to the client API class. + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.CostManagement Client => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Module.Instance.ClientAPI; + + /// + /// Array of column names to be included in the export. If not provided then the export will include all available columns. + /// The available columns can vary by customer channel (see examples). + /// + [global::System.Management.Automation.AllowEmptyCollection] + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "Array of column names to be included in the export. If not provided then the export will include all available columns. The available columns can vary by customer channel (see examples).")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Body)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"Array of column names to be included in the export. If not provided then the export will include all available columns. The available columns can vary by customer channel (see examples).", + SerializedName = @"columns", + PossibleTypes = new [] { typeof(string) })] + public string[] ConfigurationColumn { get => ParametersBody.ConfigurationColumn ?? null /* arrayOf */; set => ParametersBody.ConfigurationColumn = value; } + + /// The granularity of rows in the export. Currently only 'Daily' is supported. + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The granularity of rows in the export. Currently only 'Daily' is supported.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Body)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The granularity of rows in the export. Currently only 'Daily' is supported.", + SerializedName = @"granularity", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType) })] + [global::System.Management.Automation.ArgumentCompleter(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType))] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType DataSetGranularity { get => ParametersBody.DataSetGranularity ?? ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType)""); set => ParametersBody.DataSetGranularity = value; } + + /// + /// The credentials, account, tenant, and subscription used for communication with Azure + /// + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The credentials, account, tenant, and subscription used for communication with Azure.")] + [global::System.Management.Automation.ValidateNotNull] + [global::System.Management.Automation.Alias("AzureRMContext", "AzureCredential")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Azure)] + public global::System.Management.Automation.PSObject DefaultProfile { get; set; } + + /// + /// The time frame for pulling data for the export. If custom, then a specific time period must be provided. + /// + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The time frame for pulling data for the export. If custom, then a specific time period must be provided.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Body)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The time frame for pulling data for the export. If custom, then a specific time period must be provided.", + SerializedName = @"timeframe", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType) })] + [global::System.Management.Automation.ArgumentCompleter(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType))] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType DefinitionTimeframe { get => ParametersBody.DefinitionTimeframe; set => ParametersBody.DefinitionTimeframe = value; } + + /// + /// The type of the export. Note that 'Usage' is equivalent to 'ActualCost' and is applicable to exports that do not yet provide + /// data for charges or amortization for service reservations. + /// + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The type of the export. Note that 'Usage' is equivalent to 'ActualCost' and is applicable to exports that do not yet provide data for charges or amortization for service reservations.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Body)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The type of the export. Note that 'Usage' is equivalent to 'ActualCost' and is applicable to exports that do not yet provide data for charges or amortization for service reservations.", + SerializedName = @"type", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType) })] + [global::System.Management.Automation.ArgumentCompleter(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType))] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType DefinitionType { get => ParametersBody.DefinitionType; set => ParametersBody.DefinitionType = value; } + + /// The name of the container where exports will be uploaded. + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The name of the container where exports will be uploaded.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Body)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The name of the container where exports will be uploaded.", + SerializedName = @"container", + PossibleTypes = new [] { typeof(string) })] + public string DestinationContainer { get => ParametersBody.DestinationContainer ?? null; set => ParametersBody.DestinationContainer = value; } + + /// The resource id of the storage account where exports will be delivered. + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The resource id of the storage account where exports will be delivered.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Body)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The resource id of the storage account where exports will be delivered.", + SerializedName = @"resourceId", + PossibleTypes = new [] { typeof(string) })] + public string DestinationResourceId { get => ParametersBody.DestinationResourceId ?? null; set => ParametersBody.DestinationResourceId = value; } + + /// The name of the directory where exports will be uploaded. + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The name of the directory where exports will be uploaded.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Body)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The name of the directory where exports will be uploaded.", + SerializedName = @"rootFolderPath", + PossibleTypes = new [] { typeof(string) })] + public string DestinationRootFolderPath { get => ParametersBody.DestinationRootFolderPath ?? null; set => ParametersBody.DestinationRootFolderPath = value; } + + /// + /// eTag of the resource. To handle concurrent update scenario, this field will be used to determine whether the user is updating + /// the latest version or not. + /// + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "eTag of the resource. To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Body)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"eTag of the resource. To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not.", + SerializedName = @"eTag", + PossibleTypes = new [] { typeof(string) })] + public string ETag { get => ParametersBody.ETag ?? null; set => ParametersBody.ETag = value; } + + /// The format of the export being delivered. Currently only 'Csv' is supported. + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The format of the export being delivered. Currently only 'Csv' is supported.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Body)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The format of the export being delivered. Currently only 'Csv' is supported.", + SerializedName = @"format", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType) })] + [global::System.Management.Automation.ArgumentCompleter(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType))] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType Format { get => ParametersBody.Format ?? ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType)""); set => ParametersBody.Format = value; } + + /// SendAsync Pipeline Steps to be appended to the front of the pipeline + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be appended to the front of the pipeline")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[] HttpPipelineAppend { get; set; } + + /// SendAsync Pipeline Steps to be prepended to the front of the pipeline + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be prepended to the front of the pipeline")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[] HttpPipelinePrepend { get; set; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity _inputObject; + + /// Identity Parameter + [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "Identity Parameter", ValueFromPipeline = true)] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Path)] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity InputObject { get => this._inputObject; set => this._inputObject = value; } + + /// Accessor for our copy of the InvocationInfo. + public global::System.Management.Automation.InvocationInfo InvocationInformation { get => __invocationInfo = __invocationInfo ?? this.MyInvocation ; set { __invocationInfo = value; } } + + /// + /// cancellation delegate. Stops the cmdlet when called. + /// + global::System.Action Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener.Cancel => _cancellationTokenSource.Cancel; + + /// cancellation token. + global::System.Threading.CancellationToken Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener.Token => _cancellationTokenSource.Token; + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport _parametersBody= new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.Export(); + + /// An export resource. + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport ParametersBody { get => this._parametersBody; set => this._parametersBody = value; } + + /// + /// The instance of the that the remote call will use. + /// + private Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.HttpPipeline Pipeline { get; set; } + + /// The URI for the proxy server to use + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "The URI for the proxy server to use")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Uri Proxy { get; set; } + + /// Credentials for a proxy server to use for the remote call + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Credentials for a proxy server to use for the remote call")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Management.Automation.PSCredential ProxyCredential { get; set; } + + /// Use the default credentials for the proxy + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Use the default credentials for the proxy")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter ProxyUseDefaultCredentials { get; set; } + + /// The start date of recurrence. + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The start date of recurrence.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Body)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The start date of recurrence.", + SerializedName = @"from", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + public global::System.DateTime RecurrencePeriodFrom { get => ParametersBody.RecurrencePeriodFrom; set => ParametersBody.RecurrencePeriodFrom = value; } + + /// The end date of recurrence. + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The end date of recurrence.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Body)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The end date of recurrence.", + SerializedName = @"to", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + public global::System.DateTime RecurrencePeriodTo { get => ParametersBody.RecurrencePeriodTo ?? default(global::System.DateTime); set => ParametersBody.RecurrencePeriodTo = value; } + + /// The schedule recurrence. + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The schedule recurrence.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Body)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The schedule recurrence.", + SerializedName = @"recurrence", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType) })] + [global::System.Management.Automation.ArgumentCompleter(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType))] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType ScheduleRecurrence { get => ParametersBody.ScheduleRecurrence; set => ParametersBody.ScheduleRecurrence = value; } + + /// + /// The status of the export's schedule. If 'Inactive', the export's schedule is paused. + /// + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The status of the export's schedule. If 'Inactive', the export's schedule is paused.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Body)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The status of the export's schedule. If 'Inactive', the export's schedule is paused.", + SerializedName = @"status", + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType) })] + [global::System.Management.Automation.ArgumentCompleter(typeof(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType))] + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType ScheduleStatus { get => ParametersBody.ScheduleStatus ?? ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType)""); set => ParametersBody.ScheduleStatus = value; } + + /// The start date for export data. + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The start date for export data.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Body)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The start date for export data.", + SerializedName = @"from", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + public global::System.DateTime TimePeriodFrom { get => ParametersBody.TimePeriodFrom; set => ParametersBody.TimePeriodFrom = value; } + + /// The end date for export data. + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The end date for export data.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CostManagement.ParameterCategory.Body)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The end date for export data.", + SerializedName = @"to", + PossibleTypes = new [] { typeof(global::System.DateTime) })] + public global::System.DateTime TimePeriodTo { get => ParametersBody.TimePeriodTo; set => ParametersBody.TimePeriodTo = value; } + + /// + /// overrideOnCreated will be called before the regular onCreated has been processed, allowing customization of what + /// happens on that response. Implement this method in a partial class to enable this behavior + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a from the remote call + /// /// Determines if the rest of the onCreated method should be processed, or if the method should + /// return immediately (set to true to skip further processing ) + + partial void overrideOnCreated(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + + /// + /// overrideOnDefault will be called before the regular onDefault has been processed, allowing customization of what + /// happens on that response. Implement this method in a partial class to enable this behavior + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a from the remote call + /// /// Determines if the rest of the onDefault method should be processed, or if the method should + /// return immediately (set to true to skip further processing ) + + partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + + /// + /// overrideOnOk will be called before the regular onOk has been processed, allowing customization of what happens + /// on that response. Implement this method in a partial class to enable this behavior + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a from the remote call + /// /// Determines if the rest of the onOk method should be processed, or if the method should return + /// immediately (set to true to skip further processing ) + + partial void overrideOnOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + + /// + /// (overrides the default BeginProcessing method in global::System.Management.Automation.PSCmdlet) + /// + protected override void BeginProcessing() + { + Module.Instance.SetProxyConfiguration(Proxy, ProxyCredential, ProxyUseDefaultCredentials); + if (Break) + { + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.AttachDebugger.Break(); + } + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletBeginProcessing).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + + /// Performs clean-up after the command execution + protected override void EndProcessing() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletEndProcessing).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + + /// Handles/Dispatches events during the call to the REST service. + /// The message id + /// The message cancellation token. When this call is cancelled, this should be true + /// Detailed message data for the message event. + /// + /// A that will be complete when handling of the message is completed. + /// + async global::System.Threading.Tasks.Task Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener.Signal(string id, global::System.Threading.CancellationToken token, global::System.Func messageData) + { + using( NoSynchronizationContext ) + { + if (token.IsCancellationRequested) + { + return ; + } + + switch ( id ) + { + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Verbose: + { + WriteVerbose($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Warning: + { + WriteWarning($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Information: + { + var data = messageData(); + WriteInformation(data, new[] { data.Message }); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Debug: + { + WriteDebug($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.Error: + { + WriteError(new global::System.Management.Automation.ErrorRecord( new global::System.Exception(messageData().Message), string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null ) ); + return ; + } + } + await Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Module.Instance.Signal(id, token, messageData, (i,t,m) => ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(i,t,()=> Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.EventDataConverter.ConvertFrom( m() ) as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.EventData ), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); + if (token.IsCancellationRequested) + { + return ; + } + WriteDebug($"{id}: {(messageData().Message ?? global::System.String.Empty)}"); + } + } + + /// Performs execution of the command. + protected override void ProcessRecord() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordStart).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + __processRecordId = System.Guid.NewGuid().ToString(); + try + { + // work + if (ShouldProcess($"Call remote 'ExportsCreateOrUpdate' operation")) + { + using( var asyncCommandRuntime = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.AsyncCommandRuntime(this, ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token) ) + { + asyncCommandRuntime.Wait( ProcessRecordAsync(),((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token); + } + } + } + catch (global::System.AggregateException aggregateException) + { + // unroll the inner exceptions to get the root cause + foreach( var innerException in aggregateException.Flatten().InnerExceptions ) + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletException, $"{innerException.GetType().Name} - {innerException.Message} : {innerException.StackTrace}").Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + // Write exception out to error channel. + WriteError( new global::System.Management.Automation.ErrorRecord(innerException,string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null) ); + } + } + catch (global::System.Exception exception) when ((exception as System.Management.Automation.PipelineStoppedException)== null || (exception as System.Management.Automation.PipelineStoppedException).InnerException != null) + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletException, $"{exception.GetType().Name} - {exception.Message} : {exception.StackTrace}").Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + // Write exception out to error channel. + WriteError( new global::System.Management.Automation.ErrorRecord(exception,string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null) ); + } + finally + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordEnd).Wait(); + } + } + + /// Performs execution of the command, working asynchronously if required. + /// + /// A that will be complete when handling of the method is completed. + /// + protected async global::System.Threading.Tasks.Task ProcessRecordAsync() + { + using( NoSynchronizationContext ) + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordAsyncStart); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletGetPipeline); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName); + if (null != HttpPipelinePrepend) + { + Pipeline.Prepend((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelinePrepend) ?? HttpPipelinePrepend); + } + if (null != HttpPipelineAppend) + { + Pipeline.Append((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelineAppend) ?? HttpPipelineAppend); + } + // get the client instance + try + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletBeforeAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + if (InputObject?.Id != null) + { + await this.Client.ExportsCreateOrUpdateViaIdentity(InputObject.Id, ParametersBody, onOk, onCreated, onDefault, this, Pipeline); + } + else + { + // try to call with PATH parameters from Input Object + if (null == InputObject.Scope) + { + ThrowTerminatingError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception("InputObject has null value for InputObject.Scope"),string.Empty, global::System.Management.Automation.ErrorCategory.InvalidArgument, InputObject) ); + } + if (null == InputObject.ExportName) + { + ThrowTerminatingError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception("InputObject has null value for InputObject.ExportName"),string.Empty, global::System.Management.Automation.ErrorCategory.InvalidArgument, InputObject) ); + } + await this.Client.ExportsCreateOrUpdate(InputObject.Scope ?? null, InputObject.ExportName ?? null, ParametersBody, onOk, onCreated, onDefault, this, Pipeline); + } + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletAfterAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + catch (Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.UndeclaredResponseException urexception) + { + WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { body=ParametersBody}) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(urexception.Message) { RecommendedAction = urexception.Action } + }); + } + finally + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.CmdletProcessRecordAsyncEnd); + } + } + } + + /// Interrupts currently running code within the command. + protected override void StopProcessing() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener)this).Cancel(); + base.StopProcessing(); + } + + /// + /// Intializes a new instance of the cmdlet class. + /// + public UpdateAzCostManagementExport_UpdateViaIdentityExpanded() + { + + } + + /// a delegate that is called when the remote service returns 201 (Created). + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a from the remote call + /// + /// A that will be complete when handling of the method is completed. + /// + private async global::System.Threading.Tasks.Task onCreated(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + { + using( NoSynchronizationContext ) + { + var _returnNow = global::System.Threading.Tasks.Task.FromResult(false); + overrideOnCreated(responseMessage, response, ref _returnNow); + // if overrideOnCreated has returned true, then return right away. + if ((null != _returnNow && await _returnNow)) + { + return ; + } + // onCreated - response for 201 / application/json + // (await response) // should be Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport + WriteObject((await response)); + } + } + + /// + /// a delegate that is called when the remote service returns default (any response code not handled elsewhere). + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a from the remote call + /// + /// A that will be complete when handling of the method is completed. + /// + private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + { + using( NoSynchronizationContext ) + { + var _returnNow = global::System.Threading.Tasks.Task.FromResult(false); + overrideOnDefault(responseMessage, response, ref _returnNow); + // if overrideOnDefault has returned true, then return right away. + if ((null != _returnNow && await _returnNow)) + { + return ; + } + // Error Response : default + var code = (await response)?.Code; + var message = (await response)?.Message; + if ((null == code || null == message)) + { + // Unrecognized Response. Create an error record based on what we have. + var ex = new Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.RestException(responseMessage, await response); + WriteError( new global::System.Management.Automation.ErrorRecord(ex, ex.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { body=ParametersBody }) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(ex.Message) { RecommendedAction = ex.Action } + }); + } + else + { + WriteError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception($"[{code}] : {message}"), code?.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { body=ParametersBody }) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(message) { RecommendedAction = global::System.String.Empty } + }); + } + } + } + + /// a delegate that is called when the remote service returns 200 (OK). + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a from the remote call + /// + /// A that will be complete when handling of the method is completed. + /// + private async global::System.Threading.Tasks.Task onOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + { + using( NoSynchronizationContext ) + { + var _returnNow = global::System.Threading.Tasks.Task.FromResult(false); + overrideOnOk(responseMessage, response, ref _returnNow); + // if overrideOnOk has returned true, then return right away. + if ((null != _returnNow && await _returnNow)) + { + return ; + } + // onOk - response for 200 / application/json + // (await response) // should be Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport + WriteObject((await response)); + } + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/AsyncCommandRuntime.cs b/src/CostManagement/generated/runtime/AsyncCommandRuntime.cs new file mode 100644 index 000000000000..0f2800036c86 --- /dev/null +++ b/src/CostManagement/generated/runtime/AsyncCommandRuntime.cs @@ -0,0 +1,828 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell +{ + using System.Management.Automation; + using System.Management.Automation.Host; + using System.Threading; + using System.Linq; + + internal interface IAsyncCommandRuntimeExtensions + { + Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep Wrap(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep func); + System.Collections.Generic.IEnumerable Wrap(System.Collections.Generic.IEnumerable funcs); + + T ExecuteSync(System.Func step); + } + + public class AsyncCommandRuntime : System.Management.Automation.ICommandRuntime2, IAsyncCommandRuntimeExtensions, System.IDisposable + { + private ICommandRuntime2 originalCommandRuntime; + private System.Threading.Thread originalThread; + public bool AllowInteractive { get; set; } = false; + + public CancellationToken cancellationToken; + SemaphoreSlim semaphore = new SemaphoreSlim(1, 1); + ManualResetEventSlim readyToRun = new ManualResetEventSlim(false); + ManualResetEventSlim completed = new ManualResetEventSlim(false); + + System.Action runOnMainThread; + + private System.Management.Automation.PSCmdlet cmdlet; + + internal AsyncCommandRuntime(System.Management.Automation.PSCmdlet cmdlet, CancellationToken cancellationToken) + { + this.originalCommandRuntime = cmdlet.CommandRuntime as ICommandRuntime2; + this.originalThread = System.Threading.Thread.CurrentThread; + this.cancellationToken = cancellationToken; + this.cmdlet = cmdlet; + cmdlet.CommandRuntime = this; + } + + public PSHost Host => this.originalCommandRuntime.Host; + + public PSTransactionContext CurrentPSTransaction => this.originalCommandRuntime.CurrentPSTransaction; + + private void CheckForInteractive() + { + // This is an interactive call -- if we are not on the original thread, this will only work if this was done at ACR creation time; + if (!AllowInteractive) + { + throw new System.Exception("AsyncCommandRuntime is not configured for interactive calls"); + } + } + private void WaitOurTurn() + { + // wait for our turn to play + semaphore?.Wait(cancellationToken); + + // ensure that completed is not set + completed.Reset(); + } + + private void WaitForCompletion() + { + // wait for the result (or cancellation!) + WaitHandle.WaitAny(new[] { cancellationToken.WaitHandle, completed?.WaitHandle }); + + // let go of the semaphore + semaphore?.Release(); + + } + + public bool ShouldContinue(string query, string caption, bool hasSecurityImpact, ref bool yesToAll, ref bool noToAll) + { + // if we are on the original thread, just call straight thru. + if (this.originalThread == System.Threading.Thread.CurrentThread) + { + return originalCommandRuntime.ShouldContinue(query, caption, hasSecurityImpact, ref yesToAll, ref noToAll); + } + + CheckForInteractive(); + + // otherwise, queue up the request and wait for the main thread to do the right thing. + try + { + // wait for our turn to talk to the main thread + WaitOurTurn(); + + bool yta = yesToAll; + bool nta = noToAll; + bool result = false; + + // set the function to run + runOnMainThread = () => result = originalCommandRuntime.ShouldContinue(query, caption, hasSecurityImpact, ref yta, ref nta); + + // tell the main thread to go ahead + readyToRun.Set(); + + // wait for the result (or cancellation!) + WaitForCompletion(); + + // set the output variables + yesToAll = yta; + noToAll = nta; + return result; + } + catch (System.OperationCanceledException exception) + { + // maybe don't even worry? + throw exception; + } + } + + public bool ShouldContinue(string query, string caption) + { + // if we are on the original thread, just call straight thru. + if (this.originalThread == System.Threading.Thread.CurrentThread) + { + return originalCommandRuntime.ShouldContinue(query, caption); + } + + CheckForInteractive(); + + // otherwise, queue up the request and wait for the main thread to do the right thing. + try + { + // wait for our turn to talk to the main thread + WaitOurTurn(); + + bool result = false; + + // set the function to run + runOnMainThread = () => result = originalCommandRuntime.ShouldContinue(query, caption); + + // tell the main thread to go ahead + readyToRun.Set(); + + // wait for the result (or cancellation!) + WaitForCompletion(); + + // set the output variables + return result; + } + catch (System.OperationCanceledException exception) + { + // maybe don't even worry? + throw exception; + } + } + + public bool ShouldContinue(string query, string caption, ref bool yesToAll, ref bool noToAll) + { + // if we are on the original thread, just call straight thru. + if (this.originalThread == System.Threading.Thread.CurrentThread) + { + return originalCommandRuntime.ShouldContinue(query, caption, ref yesToAll, ref noToAll); + } + + CheckForInteractive(); + + // otherwise, queue up the request and wait for the main thread to do the right thing. + try + { + // wait for our turn to talk to the main thread + WaitOurTurn(); + + bool yta = yesToAll; + bool nta = noToAll; + bool result = false; + + // set the function to run + runOnMainThread = () => result = originalCommandRuntime.ShouldContinue(query, caption, ref yta, ref nta); + + // tell the main thread to go ahead + readyToRun.Set(); + + // wait for the result (or cancellation!) + WaitForCompletion(); + + // set the output variables + yesToAll = yta; + noToAll = nta; + return result; + } + catch (System.OperationCanceledException exception) + { + // maybe don't even worry? + throw exception; + } + } + + public bool ShouldProcess(string target) + { + // if we are on the original thread, just call straight thru. + if (this.originalThread == System.Threading.Thread.CurrentThread) + { + return originalCommandRuntime.ShouldProcess(target); + } + + CheckForInteractive(); + + // otherwise, queue up the request and wait for the main thread to do the right thing. + try + { + // wait for our turn to talk to the main thread + WaitOurTurn(); + + bool result = false; + + // set the function to run + runOnMainThread = () => result = originalCommandRuntime.ShouldProcess(target); + + // tell the main thread to go ahead + readyToRun.Set(); + + // wait for the result (or cancellation!) + WaitForCompletion(); + + // set the output variables + return result; + } + catch (System.OperationCanceledException exception) + { + // maybe don't even worry? + throw exception; + } + } + + public bool ShouldProcess(string target, string action) + { + // if we are on the original thread, just call straight thru. + if (this.originalThread == System.Threading.Thread.CurrentThread) + { + return originalCommandRuntime.ShouldProcess(target, action); + } + + CheckForInteractive(); + + // otherwise, queue up the request and wait for the main thread to do the right thing. + try + { + // wait for our turn to talk to the main thread + WaitOurTurn(); + + bool result = false; + + // set the function to run + runOnMainThread = () => result = originalCommandRuntime.ShouldProcess(target, action); + + // tell the main thread to go ahead + readyToRun.Set(); + + // wait for the result (or cancellation!) + WaitForCompletion(); + + // set the output variables + return result; + } + catch (System.OperationCanceledException exception) + { + // maybe don't even worry? + throw exception; + } + } + + public bool ShouldProcess(string verboseDescription, string verboseWarning, string caption) + { + // if we are on the original thread, just call straight thru. + if (this.originalThread == System.Threading.Thread.CurrentThread) + { + return originalCommandRuntime.ShouldProcess(verboseDescription, verboseWarning, caption); + } + + CheckForInteractive(); + + // otherwise, queue up the request and wait for the main thread to do the right thing. + try + { + // wait for our turn to talk to the main thread + WaitOurTurn(); + + bool result = false; + + // set the function to run + runOnMainThread = () => result = originalCommandRuntime.ShouldProcess(verboseDescription, verboseWarning, caption); + + // tell the main thread to go ahead + readyToRun.Set(); + + // wait for the result (or cancellation!) + WaitForCompletion(); + + // set the output variables + return result; + } + catch (System.OperationCanceledException exception) + { + // maybe don't even worry? + throw exception; + } + } + + public bool ShouldProcess(string verboseDescription, string verboseWarning, string caption, out ShouldProcessReason shouldProcessReason) + { + // if we are on the original thread, just call straight thru. + if (this.originalThread == System.Threading.Thread.CurrentThread) + { + return originalCommandRuntime.ShouldProcess(verboseDescription, verboseWarning, caption, out shouldProcessReason); + } + + CheckForInteractive(); + + // otherwise, queue up the request and wait for the main thread to do the right thing. + try + { + // wait for our turn to talk to the main thread + WaitOurTurn(); + + bool result = false; + ShouldProcessReason reason = ShouldProcessReason.None; + + // set the function to run + runOnMainThread = () => result = originalCommandRuntime.ShouldProcess(verboseDescription, verboseWarning, caption, out reason); + + // tell the main thread to go ahead + readyToRun.Set(); + + // wait for the result (or cancellation!) + WaitForCompletion(); + + // set the output variables + shouldProcessReason = reason; + return result; + } + catch (System.OperationCanceledException exception) + { + // maybe don't even worry? + throw exception; + } + } + + public void ThrowTerminatingError(ErrorRecord errorRecord) + { + // if we are on the original thread, just call straight thru. + if (this.originalThread == System.Threading.Thread.CurrentThread) + { + originalCommandRuntime.ThrowTerminatingError(errorRecord); + return; + } + + // otherwise, queue up the request and wait for the main thread to do the right thing. + try + { + // wait for our turn to talk to the main thread + WaitOurTurn(); + + // set the function to run + runOnMainThread = () => originalCommandRuntime.ThrowTerminatingError(errorRecord); + + // tell the main thread to go ahead + readyToRun.Set(); + + // wait for the result (or cancellation!) + WaitForCompletion(); + + // return + return; + } + catch (System.OperationCanceledException exception) + { + // maybe don't even worry? + throw exception; + } + } + + public bool TransactionAvailable() + { + // if we are on the original thread, just call straight thru. + if (this.originalThread == System.Threading.Thread.CurrentThread) + { + return originalCommandRuntime.TransactionAvailable(); + } + + // otherwise, queue up the request and wait for the main thread to do the right thing. + try + { + // wait for our turn to talk to the main thread + WaitOurTurn(); + + bool result = false; + + // set the function to run + runOnMainThread = () => result = originalCommandRuntime.TransactionAvailable(); + + // tell the main thread to go ahead + readyToRun.Set(); + + // wait for the result (or cancellation!) + WaitForCompletion(); + + // set the output variables + return result; + } + catch (System.OperationCanceledException exception) + { + // maybe don't even worry? + throw exception; + } + } + + public void WriteCommandDetail(string text) + { + // if we are on the original thread, just call straight thru. + if (this.originalThread == System.Threading.Thread.CurrentThread) + { + originalCommandRuntime.WriteCommandDetail(text); + return; + } + + // otherwise, queue up the request and wait for the main thread to do the right thing. + try + { + // wait for our turn to talk to the main thread + WaitOurTurn(); + + // set the function to run + runOnMainThread = () => originalCommandRuntime.WriteCommandDetail(text); + + // tell the main thread to go ahead + readyToRun.Set(); + + // wait for the result (or cancellation!) + WaitForCompletion(); + + // return + return; + } + catch (System.OperationCanceledException exception) + { + // maybe don't even worry? + throw exception; + } + } + + public void WriteDebug(string text) + { + // if we are on the original thread, just call straight thru. + if (this.originalThread == System.Threading.Thread.CurrentThread) + { + originalCommandRuntime.WriteDebug(text); + return; + } + + // otherwise, queue up the request and wait for the main thread to do the right thing. + try + { + // wait for our turn to talk to the main thread + WaitOurTurn(); + + // set the function to run + runOnMainThread = () => originalCommandRuntime.WriteDebug(text); + + // tell the main thread to go ahead + readyToRun.Set(); + + // wait for the result (or cancellation!) + WaitForCompletion(); + + // return + return; + } + catch (System.OperationCanceledException exception) + { + // maybe don't even worry? + throw exception; + } + } + + public void WriteError(ErrorRecord errorRecord) + { + // if we are on the original thread, just call straight thru. + if (this.originalThread == System.Threading.Thread.CurrentThread) + { + originalCommandRuntime.WriteError(errorRecord); + return; + } + + // otherwise, queue up the request and wait for the main thread to do the right thing. + try + { + // wait for our turn to talk to the main thread + WaitOurTurn(); + + // set the function to run + runOnMainThread = () => originalCommandRuntime.WriteError(errorRecord); + + // tell the main thread to go ahead + readyToRun.Set(); + + // wait for the result (or cancellation!) + WaitForCompletion(); + + // return + return; + } + catch (System.OperationCanceledException exception) + { + // maybe don't even worry? + throw exception; + } + } + + public void WriteInformation(InformationRecord informationRecord) + { + // if we are on the original thread, just call straight thru. + if (this.originalThread == System.Threading.Thread.CurrentThread) + { + originalCommandRuntime.WriteInformation(informationRecord); + return; + } + + // otherwise, queue up the request and wait for the main thread to do the right thing. + try + { + // wait for our turn to talk to the main thread + WaitOurTurn(); + + // set the function to run + runOnMainThread = () => originalCommandRuntime.WriteInformation(informationRecord); + + // tell the main thread to go ahead + readyToRun.Set(); + + // wait for the result (or cancellation!) + WaitForCompletion(); + + // return + return; + } + catch (System.OperationCanceledException exception) + { + // maybe don't even worry? + throw exception; + } + } + + public void WriteObject(object sendToPipeline) + { + // if we are on the original thread, just call straight thru. + if (this.originalThread == System.Threading.Thread.CurrentThread) + { + originalCommandRuntime.WriteObject(sendToPipeline); + return; + } + + // otherwise, queue up the request and wait for the main thread to do the right thing. + try + { + // wait for our turn to talk to the main thread + WaitOurTurn(); + + // set the function to run + runOnMainThread = () => originalCommandRuntime.WriteObject(sendToPipeline); + + // tell the main thread to go ahead + readyToRun.Set(); + + // wait for the result (or cancellation!) + WaitForCompletion(); + + // return + return; + } + catch (System.OperationCanceledException exception) + { + // maybe don't even worry? + throw exception; + } + } + + public void WriteObject(object sendToPipeline, bool enumerateCollection) + { + // if we are on the original thread, just call straight thru. + if (this.originalThread == System.Threading.Thread.CurrentThread) + { + originalCommandRuntime.WriteObject(sendToPipeline, enumerateCollection); + return; + } + + // otherwise, queue up the request and wait for the main thread to do the right thing. + try + { + // wait for our turn to talk to the main thread + WaitOurTurn(); + + // set the function to run + runOnMainThread = () => originalCommandRuntime.WriteObject(sendToPipeline, enumerateCollection); + + // tell the main thread to go ahead + readyToRun.Set(); + + // wait for the result (or cancellation!) + WaitForCompletion(); + + // return + return; + } + catch (System.OperationCanceledException exception) + { + // maybe don't even worry? + throw exception; + } + } + + public void WriteProgress(ProgressRecord progressRecord) + { + // if we are on the original thread, just call straight thru. + if (this.originalThread == System.Threading.Thread.CurrentThread) + { + originalCommandRuntime.WriteProgress(progressRecord); + return; + } + + // otherwise, queue up the request and wait for the main thread to do the right thing. + try + { + // wait for our turn to talk to the main thread + WaitOurTurn(); + + // set the function to run + runOnMainThread = () => originalCommandRuntime.WriteProgress(progressRecord); + + // tell the main thread to go ahead + readyToRun.Set(); + + // wait for the result (or cancellation!) + WaitForCompletion(); + + // return + return; + } + catch (System.OperationCanceledException exception) + { + // maybe don't even worry? + throw exception; + } + } + + public void WriteProgress(long sourceId, ProgressRecord progressRecord) + { + // if we are on the original thread, just call straight thru. + if (this.originalThread == System.Threading.Thread.CurrentThread) + { + originalCommandRuntime.WriteProgress(sourceId, progressRecord); + return; + } + + // otherwise, queue up the request and wait for the main thread to do the right thing. + try + { + // wait for our turn to talk to the main thread + WaitOurTurn(); + + // set the function to run + runOnMainThread = () => originalCommandRuntime.WriteProgress(sourceId, progressRecord); + + // tell the main thread to go ahead + readyToRun.Set(); + + // wait for the result (or cancellation!) + WaitForCompletion(); + + // return + return; + } + catch (System.OperationCanceledException exception) + { + // maybe don't even worry? + throw exception; + } + } + + public void WriteVerbose(string text) + { + // if we are on the original thread, just call straight thru. + if (this.originalThread == System.Threading.Thread.CurrentThread) + { + originalCommandRuntime.WriteVerbose(text); + return; + } + + // otherwise, queue up the request and wait for the main thread to do the right thing. + try + { + // wait for our turn to talk to the main thread + WaitOurTurn(); + + // set the function to run + runOnMainThread = () => originalCommandRuntime.WriteVerbose(text); + + // tell the main thread to go ahead + readyToRun.Set(); + + // wait for the result (or cancellation!) + WaitForCompletion(); + + // return + return; + } + catch (System.OperationCanceledException exception) + { + // maybe don't even worry? + throw exception; + } + } + + public void WriteWarning(string text) + { + // if we are on the original thread, just call straight thru. + if (this.originalThread == System.Threading.Thread.CurrentThread) + { + originalCommandRuntime.WriteWarning(text); + return; + } + + // otherwise, queue up the request and wait for the main thread to do the right thing. + try + { + // wait for our turn to talk to the main thread + WaitOurTurn(); + + // set the function to run + runOnMainThread = () => originalCommandRuntime.WriteWarning(text); + + // tell the main thread to go ahead + readyToRun.Set(); + + // wait for the result (or cancellation!) + WaitForCompletion(); + + // return + return; + } + catch (System.OperationCanceledException exception) + { + // maybe don't even worry? + throw exception; + } + } + + public void Wait(System.Threading.Tasks.Task ProcessRecordAsyncTask, System.Threading.CancellationToken cancellationToken) + { + do + { + WaitHandle.WaitAny(new[] { readyToRun.WaitHandle, ((System.IAsyncResult)ProcessRecordAsyncTask).AsyncWaitHandle }); + if (readyToRun.IsSet) + { + // reset the request for the next time + readyToRun.Reset(); + + // run the delegate on this thread + runOnMainThread(); + + // tell the originator everything is complete + completed.Set(); + } + } + while (!ProcessRecordAsyncTask.IsCompleted); + if (ProcessRecordAsyncTask.IsFaulted) + { + // don't unwrap a Aggregate Exception -- we'll lose the stack trace of the actual exception. + // if( ProcessRecordAsyncTask.Exception is System.AggregateException aggregate ) { + // throw aggregate.InnerException; + // } + throw ProcessRecordAsyncTask.Exception; + } + } + public Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep Wrap(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep func) => func.Target.GetType().Name != "Closure" ? func : (p1, p2, p3) => ExecuteSync>(() => func(p1, p2, p3)); + public System.Collections.Generic.IEnumerable Wrap(System.Collections.Generic.IEnumerable funcs) => funcs?.Select(Wrap); + + public T ExecuteSync(System.Func step) + { + // if we are on the original thread, just call straight thru. + if (this.originalThread == System.Threading.Thread.CurrentThread) + { + return step(); + } + + T result = default(T); + try + { + // wait for our turn to talk to the main thread + WaitOurTurn(); + // set the function to run + runOnMainThread = () => { result = step(); }; + // tell the main thread to go ahead + readyToRun.Set(); + // wait for the result (or cancellation!) + WaitForCompletion(); + // return + return result; + } + catch (System.OperationCanceledException exception) + { + // maybe don't even worry? + throw exception; + } + } + + public void Dispose() + { + if (cmdlet != null) + { + cmdlet.CommandRuntime = this.originalCommandRuntime; + cmdlet = null; + } + + semaphore?.Dispose(); + semaphore = null; + readyToRun?.Dispose(); + readyToRun = null; + completed?.Dispose(); + completed = null; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/AsyncJob.cs b/src/CostManagement/generated/runtime/AsyncJob.cs new file mode 100644 index 000000000000..f0eda2c3202c --- /dev/null +++ b/src/CostManagement/generated/runtime/AsyncJob.cs @@ -0,0 +1,270 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell +{ + using System.Management.Automation; + using System.Management.Automation.Host; + using System.Threading; + + using System.Threading.Tasks; + + public class LongRunningJobCancelledException : System.Exception + { + public LongRunningJobCancelledException(string message) : base(message) + { + + } + } + + public class AsyncJob : Job, System.Management.Automation.ICommandRuntime2 + { + const int MaxRecords = 1000; + + private string _statusMessage = string.Empty; + + public override string StatusMessage => _statusMessage; + + public override bool HasMoreData => Output.Count > 0 || Progress.Count > 0 || Error.Count > 0 || Warning.Count > 0 || Verbose.Count > 0 || Debug.Count > 0; + + public override string Location => "localhost"; + + public PSHost Host => originalCommandRuntime.Host; + + public PSTransactionContext CurrentPSTransaction => originalCommandRuntime.CurrentPSTransaction; + + public override void StopJob() + { + Cancel(); + } + + private readonly PSCmdlet cmdlet; + private readonly ICommandRuntime2 originalCommandRuntime; + private readonly System.Threading.Thread originalThread; + + private void CheckForInteractive() + { + // This is an interactive call -- We should never allow interactivity in AsnycJob cmdlets. + throw new System.Exception("Cmdlets in AsyncJob; interactive calls are not permitted."); + } + private bool IsJobDone => CancellationToken.IsCancellationRequested || this.JobStateInfo.State == JobState.Failed || this.JobStateInfo.State == JobState.Stopped || this.JobStateInfo.State == JobState.Stopping || this.JobStateInfo.State == JobState.Completed; + + private readonly System.Action Cancel; + private readonly CancellationToken CancellationToken; + + internal AsyncJob(PSCmdlet cmdlet, string line, string name, CancellationToken cancellationToken, System.Action cancelMethod) : base(line, name) + { + SetJobState(JobState.NotStarted); + // know how to cancel/check for cancelation + this.CancellationToken = cancellationToken; + this.Cancel = cancelMethod; + + // we might need these. + this.originalCommandRuntime = cmdlet.CommandRuntime as ICommandRuntime2; + this.originalThread = System.Threading.Thread.CurrentThread; + + // the instance of the cmdlet we're going to run + this.cmdlet = cmdlet; + + // set the command runtime to the AsyncJob + cmdlet.CommandRuntime = this; + } + + /// + /// Monitors the task (which should be ProcessRecordAsync) to control + /// the lifetime of the job itself + /// + /// + public void Monitor(Task task) + { + SetJobState(JobState.Running); + task.ContinueWith(antecedent => + { + if (antecedent.IsCanceled) + { + // if the task was canceled, we're just going to call it completed. + SetJobState(JobState.Completed); + } + else if (antecedent.IsFaulted) + { + foreach (var innerException in antecedent.Exception.Flatten().InnerExceptions) + { + WriteError(new System.Management.Automation.ErrorRecord(innerException, string.Empty, System.Management.Automation.ErrorCategory.NotSpecified, null)); + } + + // a fault indicates an actual failure + SetJobState(JobState.Failed); + } + else + { + // otherwiser it's a completed state. + SetJobState(JobState.Completed); + } + }, CancellationToken); + } + + private void CheckForCancellation() + { + if (IsJobDone) + { + throw new LongRunningJobCancelledException("Long running job is canceled or stopping, continuation of the cmdlet is not permitted."); + } + } + + public void WriteInformation(InformationRecord informationRecord) + { + CheckForCancellation(); + + this.Information.Add(informationRecord); + } + + public bool ShouldContinue(string query, string caption, bool hasSecurityImpact, ref bool yesToAll, ref bool noToAll) + { + CheckForInteractive(); + return false; + } + + public void WriteDebug(string text) + { + _statusMessage = text; + CheckForCancellation(); + + if (Debug.IsOpen && Debug.Count < MaxRecords) + { + Debug.Add(new DebugRecord(text)); + } + } + + public void WriteError(ErrorRecord errorRecord) + { + if (Error.IsOpen) + { + Error.Add(errorRecord); + } + } + + public void WriteObject(object sendToPipeline) + { + CheckForCancellation(); + + if (Output.IsOpen) + { + Output.Add(new PSObject(sendToPipeline)); + } + } + + public void WriteObject(object sendToPipeline, bool enumerateCollection) + { + CheckForCancellation(); + + if (enumerateCollection && sendToPipeline is System.Collections.IEnumerable enumerable) + { + foreach (var item in enumerable) + { + WriteObject(item); + } + } + else + { + WriteObject(sendToPipeline); + } + } + + public void WriteProgress(ProgressRecord progressRecord) + { + CheckForCancellation(); + + if (Progress.IsOpen && Progress.Count < MaxRecords) + { + Progress.Add(progressRecord); + } + } + + public void WriteProgress(long sourceId, ProgressRecord progressRecord) + { + CheckForCancellation(); + + if (Progress.IsOpen && Progress.Count < MaxRecords) + { + Progress.Add(progressRecord); + } + } + + public void WriteVerbose(string text) + { + CheckForCancellation(); + + if (Verbose.IsOpen && Verbose.Count < MaxRecords) + { + Verbose.Add(new VerboseRecord(text)); + } + } + + public void WriteWarning(string text) + { + CheckForCancellation(); + + if (Warning.IsOpen && Warning.Count < MaxRecords) + { + Warning.Add(new WarningRecord(text)); + } + } + + public void WriteCommandDetail(string text) + { + WriteVerbose(text); + } + + public bool ShouldProcess(string target) + { + CheckForInteractive(); + return false; + } + + public bool ShouldProcess(string target, string action) + { + CheckForInteractive(); + return false; + } + + public bool ShouldProcess(string verboseDescription, string verboseWarning, string caption) + { + CheckForInteractive(); + return false; + } + + public bool ShouldProcess(string verboseDescription, string verboseWarning, string caption, out ShouldProcessReason shouldProcessReason) + { + CheckForInteractive(); + shouldProcessReason = ShouldProcessReason.None; + return false; + } + + public bool ShouldContinue(string query, string caption) + { + CheckForInteractive(); + return false; + } + + public bool ShouldContinue(string query, string caption, ref bool yesToAll, ref bool noToAll) + { + CheckForInteractive(); + return false; + } + + public bool TransactionAvailable() + { + // interactivity required? + return false; + } + + public void ThrowTerminatingError(ErrorRecord errorRecord) + { + if (Error.IsOpen) + { + Error.Add(errorRecord); + } + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/AsyncOperationResponse.cs b/src/CostManagement/generated/runtime/AsyncOperationResponse.cs new file mode 100644 index 000000000000..86528b60ba5d --- /dev/null +++ b/src/CostManagement/generated/runtime/AsyncOperationResponse.cs @@ -0,0 +1,177 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + [System.ComponentModel.TypeConverter(typeof(AsyncOperationResponseTypeConverter))] + public class AsyncOperationResponse + { + private string _target; + public string Target { get => _target; set => _target = value; } + public AsyncOperationResponse() + { + } + internal AsyncOperationResponse(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json) + { + // pull target + { Target = If(json?.PropertyT("target"), out var _v) ? (string)_v : (string)Target; } + } + public string ToJsonString() + { + return $"{{ \"target\" : \"{this.Target}\" }}"; + } + + public static AsyncOperationResponse FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode node) + { + return node is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject json ? new AsyncOperationResponse(json) : null; + } + + + /// + /// Creates a new instance of , deserializing the content from a json string. + /// + /// a string containing a JSON serialized instance of this model. + /// an instance of the model class. + public static AsyncOperationResponse FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(jsonText)); + + } + + public partial class AsyncOperationResponseTypeConverter : System.Management.Automation.PSTypeConverter + { + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false. + /// + public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue); + + /// + /// Determines if the converter can convert the parameter to the + /// parameter. + /// + /// the instance to check if it can be converted to the type. + /// + /// true if the instance could be converted to a type, otherwise false + /// + public static bool CanConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return true; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + // we say yest to PSObjects + return true; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + // we say yest to Hashtables/dictionaries + return true; + } + try + { + if (null != sourceValue.ToJsonString()) + { + return true; + } + } + catch + { + // Not one of our objects + } + try + { + string text = sourceValue.ToString()?.Trim(); + return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonType.Object; + } + catch + { + // Doesn't look like it can be treated as JSON + } + return false; + } + + /// + /// Determines if the parameter can be converted to the parameter + /// + /// the to convert from + /// the to convert to + /// + /// true if the converter can convert the parameter to the + /// parameter, otherwise false + /// + public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false; + + /// + /// Converts the parameter to the parameter using and + /// + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// + /// an instance of , or null if there is no suitable conversion. + /// + public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Converts the parameter to the parameter using and + /// + /// the value to convert into an instance of . + /// + /// an instance of , or null if there is no suitable conversion. + /// + public static object ConvertFrom(dynamic sourceValue) + { + if (null == sourceValue) + { + return null; + } + global::System.Type type = sourceValue.GetType(); + if (typeof(AsyncOperationResponse).IsAssignableFrom(type)) + { + return sourceValue; + } + try + { + return AsyncOperationResponse.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString()); ; + } + catch + { + // Unable to use JSON pattern + } + + if (typeof(System.Management.Automation.PSObject).IsAssignableFrom(type)) + { + return new AsyncOperationResponse { Target = (sourceValue as System.Management.Automation.PSObject).GetValueForProperty("target", "", global::System.Convert.ToString) }; + } + if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type)) + { + return new AsyncOperationResponse { Target = (sourceValue as global::System.Collections.IDictionary).GetValueForProperty("target", "", global::System.Convert.ToString) }; + } + return null; + } + + /// NotImplemented -- this will return null + /// the to convert from + /// the to convert to + /// not used by this TypeConverter. + /// when set to true, will ignore the case when converting. + /// will always return null. + public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/BuildTime/Cmdlets/ExportCmdletSurface.cs b/src/CostManagement/generated/runtime/BuildTime/Cmdlets/ExportCmdletSurface.cs new file mode 100644 index 000000000000..a352b0676bce --- /dev/null +++ b/src/CostManagement/generated/runtime/BuildTime/Cmdlets/ExportCmdletSurface.cs @@ -0,0 +1,113 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Management.Automation; +using System.Text; +using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.PsHelpers; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell +{ + [Cmdlet(VerbsData.Export, "CmdletSurface")] + [DoNotExport] + public class ExportCmdletSurface : PSCmdlet + { + [Parameter(Mandatory = true)] + [ValidateNotNullOrEmpty] + public string ModuleName { get; set; } + + [Parameter(Mandatory = true)] + [ValidateNotNullOrEmpty] + public string CmdletFolder { get; set; } + + [Parameter(Mandatory = true)] + [ValidateNotNullOrEmpty] + public string OutputFolder { get; set; } + + [Parameter] + public bool IncludeGeneralParameters { get; set; } + + [Parameter] + public bool UseExpandedFormat { get; set; } + + protected override void ProcessRecord() + { + try + { + var variants = GetScriptCmdlets(this, CmdletFolder) + .SelectMany(fi => fi.ToVariants()) + .Where(v => !v.IsDoNotExport) + .ToArray(); + var allProfiles = variants.SelectMany(v => v.Profiles).Distinct().ToArray(); + var profileGroups = allProfiles.Any() + ? variants + .SelectMany(v => (v.Profiles.Any() ? v.Profiles : allProfiles).Select(p => (profile: p, variant: v))) + .GroupBy(pv => pv.profile) + .Select(pvg => new ProfileGroup(pvg.Select(pv => pv.variant).ToArray(), pvg.Key)) + : new[] { new ProfileGroup(variants) }; + foreach (var profileGroup in profileGroups) + { + var variantGroups = profileGroup.Variants + .GroupBy(v => new { v.CmdletName }) + .Select(vg => new VariantGroup(ModuleName, vg.Key.CmdletName, vg.Select(v => v).ToArray(), String.Empty, profileGroup.ProfileName)); + var sb = UseExpandedFormat ? ExpandedFormat(variantGroups) : CondensedFormat(variantGroups); + Directory.CreateDirectory(OutputFolder); + File.WriteAllText(Path.Combine(OutputFolder, $"CmdletSurface-{profileGroup.ProfileName}.md"), sb.ToString()); + } + } + catch (Exception ee) + { + Console.WriteLine($"${ee.GetType().Name}/{ee.StackTrace}"); + throw ee; + } + } + + private StringBuilder ExpandedFormat(IEnumerable variantGroups) + { + var sb = new StringBuilder(); + foreach (var variantGroup in variantGroups.OrderBy(vg => vg.CmdletName)) + { + sb.Append($"### {variantGroup.CmdletName}{Environment.NewLine}"); + var parameterGroups = variantGroup.ParameterGroups + .Where(pg => !pg.DontShow && (IncludeGeneralParameters || (pg.OrderCategory != ParameterCategory.Azure && pg.OrderCategory != ParameterCategory.Runtime))); + foreach (var parameterGroup in parameterGroups) + { + sb.Append($" - {parameterGroup.ParameterName} `{parameterGroup.ParameterType.ToSyntaxTypeName()}`{Environment.NewLine}"); + } + sb.AppendLine(); + } + + return sb; + } + + private StringBuilder CondensedFormat(IEnumerable variantGroups) + { + var sb = new StringBuilder(); + var condensedGroups = variantGroups + .GroupBy(vg => vg.CmdletNoun) + .Select(vgg => ( + CmdletNoun: vgg.Key, + CmdletVerbs: vgg.Select(vg => vg.CmdletVerb).OrderBy(cv => cv).ToArray(), + ParameterGroups: vgg.SelectMany(vg => vg.ParameterGroups).DistinctBy(p => p.ParameterName).ToArray(), + OutputTypes: vgg.SelectMany(vg => vg.OutputTypes).Select(ot => ot.Type).DistinctBy(t => t.Name).Select(t => t.ToSyntaxTypeName()).ToArray())) + .OrderBy(vg => vg.CmdletNoun); + foreach (var condensedGroup in condensedGroups) + { + sb.Append($"### {condensedGroup.CmdletNoun} [{String.Join(", ", condensedGroup.CmdletVerbs)}] `{String.Join(", ", condensedGroup.OutputTypes)}`{Environment.NewLine}"); + var parameterGroups = condensedGroup.ParameterGroups + .Where(pg => !pg.DontShow && (IncludeGeneralParameters || (pg.OrderCategory != ParameterCategory.Azure && pg.OrderCategory != ParameterCategory.Runtime))); + foreach (var parameterGroup in parameterGroups) + { + sb.Append($" - {parameterGroup.ParameterName} `{parameterGroup.ParameterType.ToSyntaxTypeName()}`{Environment.NewLine}"); + } + sb.AppendLine(); + } + + return sb; + } + } +} diff --git a/src/CostManagement/generated/runtime/BuildTime/Cmdlets/ExportExampleStub.cs b/src/CostManagement/generated/runtime/BuildTime/Cmdlets/ExportExampleStub.cs new file mode 100644 index 000000000000..6acfbdc07556 --- /dev/null +++ b/src/CostManagement/generated/runtime/BuildTime/Cmdlets/ExportExampleStub.cs @@ -0,0 +1,74 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; +using System.IO; +using System.Linq; +using System.Management.Automation; +using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.MarkdownTypesExtensions; +using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.PsHelpers; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell +{ + [Cmdlet(VerbsData.Export, "ExampleStub")] + [DoNotExport] + public class ExportExampleStub : PSCmdlet + { + [Parameter(Mandatory = true)] + [ValidateNotNullOrEmpty] + public string ExportsFolder { get; set; } + + [Parameter(Mandatory = true)] + [ValidateNotNullOrEmpty] + public string OutputFolder { get; set; } + + protected override void ProcessRecord() + { + try + { + if (!Directory.Exists(ExportsFolder)) + { + throw new ArgumentException($"Exports folder '{ExportsFolder}' does not exist"); + } + + var exportDirectories = Directory.GetDirectories(ExportsFolder); + if (!exportDirectories.Any()) + { + exportDirectories = new[] { ExportsFolder }; + } + + var exampleText = String.Join(String.Empty, DefaultExampleHelpInfos.Select(ehi => ehi.ToHelpExampleOutput())); + foreach (var exportDirectory in exportDirectories) + { + var outputFolder = OutputFolder; + if (exportDirectory != ExportsFolder) + { + outputFolder = Path.Combine(OutputFolder, Path.GetFileName(exportDirectory)); + Directory.CreateDirectory(outputFolder); + } + + var cmdletFilePaths = GetScriptCmdlets(exportDirectory).Select(fi => Path.Combine(outputFolder, $"{fi.Name}.md")).ToArray(); + var currentExamplesFilePaths = Directory.GetFiles(outputFolder).ToArray(); + // Remove examples of non-existing cmdlets + var removedCmdletFilePaths = currentExamplesFilePaths.Except(cmdletFilePaths); + foreach (var removedCmdletFilePath in removedCmdletFilePaths) + { + File.Delete(removedCmdletFilePath); + } + + // Only create example stubs if they don't exist + foreach (var cmdletFilePath in cmdletFilePaths.Except(currentExamplesFilePaths)) + { + File.WriteAllText(cmdletFilePath, exampleText); + } + } + } + catch (Exception ee) + { + Console.WriteLine($"${ee.GetType().Name}/{ee.StackTrace}"); + throw ee; + } + } + } +} diff --git a/src/CostManagement/generated/runtime/BuildTime/Cmdlets/ExportFormatPs1xml.cs b/src/CostManagement/generated/runtime/BuildTime/Cmdlets/ExportFormatPs1xml.cs new file mode 100644 index 000000000000..6cc17ec884b8 --- /dev/null +++ b/src/CostManagement/generated/runtime/BuildTime/Cmdlets/ExportFormatPs1xml.cs @@ -0,0 +1,99 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Management.Automation; +using System.Reflection; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell +{ + [Cmdlet(VerbsData.Export, "FormatPs1xml")] + [DoNotExport] + public class ExportFormatPs1xml : PSCmdlet + { + [Parameter(Mandatory = true)] + [ValidateNotNullOrEmpty] + public string FilePath { get; set; } + + private const string ModelNamespace = @"Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models"; + private const string SupportNamespace = @"Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support"; + private static readonly bool IsAzure = Convert.ToBoolean(@"true"); + + protected override void ProcessRecord() + { + try + { + var viewModels = GetFilteredViewParameters().Select(CreateViewModel).ToList(); + var ps1xml = new Configuration + { + ViewDefinitions = new ViewDefinitions + { + Views = viewModels + } + }; + File.WriteAllText(FilePath, ps1xml.ToXmlString()); + } + catch (Exception ee) + { + Console.WriteLine($"${ee.GetType().Name}/{ee.StackTrace}"); + throw ee; + } + } + + private static IEnumerable GetFilteredViewParameters() + { + //https://stackoverflow.com/a/79738/294804 + //https://stackoverflow.com/a/949285/294804 + var types = Assembly.GetExecutingAssembly().GetExportedTypes() + .Where(t => t.IsClass + && (t.Namespace.StartsWith(ModelNamespace) || t.Namespace.StartsWith(SupportNamespace)) + && !t.GetCustomAttributes().Any()); + return types.Select(t => new ViewParameters(t, t.GetProperties() + .Select(p => new PropertyFormat(p)) + .Where(pf => !pf.Property.GetCustomAttributes().Any() + && (!IsAzure || pf.Property.Name != "Id") + && (pf.FormatTable != null || (pf.Origin != PropertyOrigin.Inlined && pf.Property.PropertyType.IsPsSimple()))) + .OrderByDescending(pf => pf.Index.HasValue) + .ThenBy(pf => pf.Index) + .ThenByDescending(pf => pf.Origin.HasValue) + .ThenBy(pf => pf.Origin))).Where(vp => vp.Properties.Any()); + } + + private static View CreateViewModel(ViewParameters viewParameters) + { + var entries = viewParameters.Properties.Select(pf => + (TableColumnHeader: new TableColumnHeader { Label = pf.Label, Width = pf.Width }, + TableColumnItem: new TableColumnItem { PropertyName = pf.Property.Name })).ToArray(); + + return new View + { + Name = viewParameters.Type.FullName, + ViewSelectedBy = new ViewSelectedBy + { + TypeName = viewParameters.Type.FullName + }, + TableControl = new TableControl + { + TableHeaders = new TableHeaders + { + TableColumnHeaders = entries.Select(e => e.TableColumnHeader).ToList() + }, + TableRowEntries = new TableRowEntries + { + TableRowEntry = new TableRowEntry + { + TableColumnItems = new TableColumnItems + { + TableItems = entries.Select(e => e.TableColumnItem).ToList() + } + } + } + } + }; + } + } +} diff --git a/src/CostManagement/generated/runtime/BuildTime/Cmdlets/ExportHelpMarkdown.cs b/src/CostManagement/generated/runtime/BuildTime/Cmdlets/ExportHelpMarkdown.cs new file mode 100644 index 000000000000..63941ac08f03 --- /dev/null +++ b/src/CostManagement/generated/runtime/BuildTime/Cmdlets/ExportHelpMarkdown.cs @@ -0,0 +1,53 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; +using System.Linq; +using System.Management.Automation; +using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.MarkdownRenderer; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell +{ + [Cmdlet(VerbsData.Export, "HelpMarkdown")] + [DoNotExport] + public class ExportHelpMarkdown : PSCmdlet + { + [Parameter(Mandatory = true)] + [ValidateNotNullOrEmpty] + public PSModuleInfo ModuleInfo { get; set; } + + [Parameter(Mandatory = true)] + [ValidateNotNullOrEmpty] + public PSObject[] FunctionInfo { get; set; } + + [Parameter(Mandatory = true)] + [ValidateNotNullOrEmpty] + public PSObject[] HelpInfo { get; set; } + + [Parameter(Mandatory = true)] + [ValidateNotNullOrEmpty] + public string DocsFolder { get; set; } + + [Parameter(Mandatory = true)] + [ValidateNotNullOrEmpty] + public string ExamplesFolder { get; set; } + + protected override void ProcessRecord() + { + try + { + var helpInfos = HelpInfo.Select(hi => hi.ToPsHelpInfo()); + var variantGroups = FunctionInfo.Select(fi => fi.BaseObject).Cast() + .Join(helpInfos, fi => fi.Name, phi => phi.CmdletName, (fi, phi) => fi.ToVariants(phi)) + .Select(va => new VariantGroup(ModuleInfo.Name, va.First().CmdletName, va, String.Empty)); + WriteMarkdowns(variantGroups, ModuleInfo.ToModuleInfo(), DocsFolder, ExamplesFolder); + } + catch (Exception ee) + { + Console.WriteLine($"${ee.GetType().Name}/{ee.StackTrace}"); + throw ee; + } + } + } +} diff --git a/src/CostManagement/generated/runtime/BuildTime/Cmdlets/ExportModelSurface.cs b/src/CostManagement/generated/runtime/BuildTime/Cmdlets/ExportModelSurface.cs new file mode 100644 index 000000000000..a17516094711 --- /dev/null +++ b/src/CostManagement/generated/runtime/BuildTime/Cmdlets/ExportModelSurface.cs @@ -0,0 +1,117 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Management.Automation; +using System.Reflection; +using System.Text; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell +{ + [Cmdlet(VerbsData.Export, "ModelSurface")] + [DoNotExport] + public class ExportModelSurface : PSCmdlet + { + [Parameter(Mandatory = true)] + [ValidateNotNullOrEmpty] + public string OutputFolder { get; set; } + + [Parameter] + public bool UseExpandedFormat { get; set; } + + private const string ModelNamespace = @"Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models"; + private const string SupportNamespace = @"Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support"; + + protected override void ProcessRecord() + { + try + { + var types = Assembly.GetExecutingAssembly().GetExportedTypes() + .Where(t => t.IsClass && (t.Namespace.StartsWith(ModelNamespace) || t.Namespace.StartsWith(SupportNamespace))); + var typeInfos = types.Select(t => new ModelTypeInfo + { + Type = t, + TypeName = t.Name, + Properties = t.GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(p => !p.GetIndexParameters().Any()).OrderBy(p => p.Name).ToArray(), + NamespaceGroup = t.Namespace.Split('.').LastOrDefault().EmptyIfNull() + }).Where(mti => mti.Properties.Any()); + var sb = UseExpandedFormat ? ExpandedFormat(typeInfos) : CondensedFormat(typeInfos); + Directory.CreateDirectory(OutputFolder); + File.WriteAllText(Path.Combine(OutputFolder, "ModelSurface.md"), sb.ToString()); + } + catch (Exception ee) + { + Console.WriteLine($"${ee.GetType().Name}/{ee.StackTrace}"); + throw ee; + } + } + + private static StringBuilder ExpandedFormat(IEnumerable typeInfos) + { + var sb = new StringBuilder(); + foreach (var typeInfo in typeInfos.OrderBy(mti => mti.TypeName).ThenBy(mti => mti.NamespaceGroup)) + { + sb.Append($"### {typeInfo.TypeName} [{typeInfo.NamespaceGroup}]{Environment.NewLine}"); + foreach (var property in typeInfo.Properties) + { + sb.Append($" - {property.Name} `{property.PropertyType.ToSyntaxTypeName()}`{Environment.NewLine}"); + } + sb.AppendLine(); + } + + return sb; + } + + private static StringBuilder CondensedFormat(IEnumerable typeInfos) + { + var sb = new StringBuilder(); + var typeGroups = typeInfos + .GroupBy(mti => mti.TypeName) + .Select(tig => ( + Types: tig.Select(mti => mti.Type).ToArray(), + TypeName: tig.Key, + Properties: tig.SelectMany(mti => mti.Properties).DistinctBy(p => p.Name).OrderBy(p => p.Name).ToArray(), + NamespaceGroups: tig.Select(mti => mti.NamespaceGroup).OrderBy(ng => ng).ToArray() + )) + .OrderBy(tg => tg.TypeName); + foreach (var typeGroup in typeGroups) + { + var aType = typeGroup.Types.Select(GetAssociativeType).FirstOrDefault(t => t != null); + var aText = aType != null ? $@" \<{aType.ToSyntaxTypeName()}\>" : String.Empty; + sb.Append($"### {typeGroup.TypeName}{aText} [{String.Join(", ", typeGroup.NamespaceGroups)}]{Environment.NewLine}"); + foreach (var property in typeGroup.Properties) + { + var propertyAType = GetAssociativeType(property.PropertyType); + var propertyAText = propertyAType != null ? $" <{propertyAType.ToSyntaxTypeName()}>" : String.Empty; + var enumNames = GetEnumFieldNames(property.PropertyType.Unwrap()); + var enumNamesText = enumNames.Any() ? $" **{{{String.Join(", ", enumNames)}}}**" : String.Empty; + sb.Append($" - {property.Name} `{property.PropertyType.ToSyntaxTypeName()}{propertyAText}`{enumNamesText}{Environment.NewLine}"); + } + sb.AppendLine(); + } + + return sb; + } + + //https://stackoverflow.com/a/4963190/294804 + private static Type GetAssociativeType(Type type) => + type.GetInterfaces().FirstOrDefault(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IAssociativeArray<>))?.GetGenericArguments().First(); + + private static string[] GetEnumFieldNames(Type type) => + type.IsValueType && !type.IsPrimitive && type != typeof(decimal) && type != typeof(DateTime) + ? type.GetFields(BindingFlags.Public | BindingFlags.Static).Where(f => f.FieldType == type).Select(p => p.Name).ToArray() + : new string[] { }; + + private class ModelTypeInfo + { + public Type Type { get; set; } + public string TypeName { get; set; } + public PropertyInfo[] Properties { get; set; } + public string NamespaceGroup { get; set; } + } + } +} diff --git a/src/CostManagement/generated/runtime/BuildTime/Cmdlets/ExportProxyCmdlet.cs b/src/CostManagement/generated/runtime/BuildTime/Cmdlets/ExportProxyCmdlet.cs new file mode 100644 index 000000000000..47433c2ff0af --- /dev/null +++ b/src/CostManagement/generated/runtime/BuildTime/Cmdlets/ExportProxyCmdlet.cs @@ -0,0 +1,159 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; +using System.IO; +using System.Linq; +using System.Management.Automation; +using System.Text; +using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.PsHelpers; +using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.MarkdownRenderer; +using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.PsProxyTypeExtensions; +using System.Collections.Generic; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell +{ + [Cmdlet(VerbsData.Export, "ProxyCmdlet", DefaultParameterSetName = "Docs")] + [DoNotExport] + public class ExportProxyCmdlet : PSCmdlet + { + [Parameter(Mandatory = true)] + [ValidateNotNullOrEmpty] + public string ModuleName { get; set; } + + [Parameter(Mandatory = true)] + [ValidateNotNullOrEmpty] + public string[] ModulePath { get; set; } + + [Parameter(Mandatory = true)] + [ValidateNotNullOrEmpty] + public string ExportsFolder { get; set; } + + [Parameter(Mandatory = true)] + [ValidateNotNullOrEmpty] + public string InternalFolder { get; set; } + + [Parameter(Mandatory = true, ParameterSetName = "Docs")] + [AllowEmptyString] + public string ModuleDescription { get; set; } + + [Parameter(Mandatory = true, ParameterSetName = "Docs")] + [ValidateNotNullOrEmpty] + public string DocsFolder { get; set; } + + [Parameter(Mandatory = true, ParameterSetName = "Docs")] + [ValidateNotNullOrEmpty] + public string ExamplesFolder { get; set; } + + [Parameter(Mandatory = true, ParameterSetName = "Docs")] + public Guid ModuleGuid { get; set; } + + [Parameter(Mandatory = true, ParameterSetName = "NoDocs")] + public SwitchParameter ExcludeDocs { get; set; } + + protected override void ProcessRecord() + { + try { + var variants = GetModuleCmdletsAndHelpInfo(this, ModulePath).SelectMany(ci => ci.ToVariants()).Where(v => !v.IsDoNotExport).ToArray(); + var allProfiles = variants.SelectMany(v => v.Profiles).Distinct().ToArray(); + var profileGroups = allProfiles.Any() + ? variants + .SelectMany(v => (v.Profiles.Any() ? v.Profiles : allProfiles).Select(p => (profile: p, variant: v))) + .GroupBy(pv => pv.profile) + .Select(pvg => new ProfileGroup(pvg.Select(pv => pv.variant).ToArray(), pvg.Key)) + : new[] { new ProfileGroup(variants) }; + var variantGroups = profileGroups.SelectMany(pg => pg.Variants + .GroupBy(v => new { v.CmdletName, v.IsInternal }) + .Select(vg => new VariantGroup(ModuleName, vg.Key.CmdletName, vg.Select(v => v).ToArray(), + Path.Combine(vg.Key.IsInternal ? InternalFolder : ExportsFolder, pg.ProfileFolder), pg.ProfileName, isInternal: vg.Key.IsInternal))) + .ToArray(); + + foreach (var variantGroup in variantGroups) + { + var parameterGroups = variantGroup.ParameterGroups.ToList(); + var isValidProfile = !String.IsNullOrEmpty(variantGroup.ProfileName) && variantGroup.ProfileName != NoProfiles; + var examplesFolder = isValidProfile ? Path.Combine(ExamplesFolder, variantGroup.ProfileName) : ExamplesFolder; + var markdownInfo = new MarkdownHelpInfo(variantGroup, examplesFolder); + List examples = new List(); + foreach (var it in markdownInfo.Examples) + { + examples.Add(it); + } + variantGroup.HelpInfo.Examples = examples.ToArray(); + var sb = new StringBuilder(); + sb.Append(@" +# ---------------------------------------------------------------------------------- +# +# Copyright Microsoft Corporation +# Licensed under the Apache License, Version 2.0 (the ""License""); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an ""AS IS"" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ---------------------------------------------------------------------------------- +"); + sb.Append($"{Environment.NewLine}"); + sb.Append(variantGroup.ToHelpCommentOutput()); + sb.Append($"function {variantGroup.CmdletName} {{{Environment.NewLine}"); + sb.Append(variantGroup.Aliases.ToAliasOutput()); + sb.Append(variantGroup.OutputTypes.ToOutputTypeOutput()); + sb.Append(variantGroup.ToCmdletBindingOutput()); + sb.Append(variantGroup.ProfileName.ToProfileOutput()); + + sb.Append("param("); + sb.Append($"{(parameterGroups.Any() ? Environment.NewLine : String.Empty)}"); + foreach (var parameterGroup in parameterGroups) + { + var parameters = parameterGroup.HasAllVariants ? parameterGroup.Parameters.Take(1) : parameterGroup.Parameters; + foreach (var parameter in parameters) + { + sb.Append(parameter.ToParameterOutput(variantGroup.HasMultipleVariants, parameterGroup.HasAllVariants)); + } + sb.Append(parameterGroup.Aliases.ToAliasOutput(true)); + sb.Append(parameterGroup.HasValidateNotNull.ToValidateNotNullOutput()); + sb.Append(parameterGroup.CompleterInfo.ToArgumentCompleterOutput()); + sb.Append(parameterGroup.OrderCategory.ToParameterCategoryOutput()); + sb.Append(parameterGroup.InfoAttribute.ToInfoOutput(parameterGroup.ParameterType)); + sb.Append(parameterGroup.ToDefaultInfoOutput()); + sb.Append(parameterGroup.ParameterType.ToParameterTypeOutput()); + sb.Append(parameterGroup.Description.ToParameterDescriptionOutput()); + sb.Append(parameterGroup.ParameterName.ToParameterNameOutput(parameterGroups.IndexOf(parameterGroup) == parameterGroups.Count - 1)); + } + sb.Append($"){Environment.NewLine}{Environment.NewLine}"); + + sb.Append(variantGroup.ToBeginOutput()); + sb.Append(variantGroup.ToProcessOutput()); + sb.Append(variantGroup.ToEndOutput()); + + sb.Append($"}}{Environment.NewLine}"); + + Directory.CreateDirectory(variantGroup.OutputFolder); + File.WriteAllText(variantGroup.FilePath, sb.ToString()); + + File.AppendAllText(Path.Combine(variantGroup.OutputFolder, "ProxyCmdletDefinitions.ps1"), sb.ToString()); + } + + if (!ExcludeDocs) + { + var moduleInfo = new PsModuleHelpInfo(ModuleName, ModuleGuid, ModuleDescription); + foreach (var variantGroupsByProfile in variantGroups.GroupBy(vg => vg.ProfileName)) + { + var profileName = variantGroupsByProfile.Key; + var isValidProfile = !String.IsNullOrEmpty(profileName) && profileName != NoProfiles; + var docsFolder = isValidProfile ? Path.Combine(DocsFolder, profileName) : DocsFolder; + var examplesFolder = isValidProfile ? Path.Combine(ExamplesFolder, profileName) : ExamplesFolder; + WriteMarkdowns(variantGroupsByProfile, moduleInfo, docsFolder, examplesFolder); + } + } + } catch (Exception ee) { + Console.WriteLine($"${ee.GetType().Name}/{ee.StackTrace}"); + throw ee; + } + } + } +} diff --git a/src/CostManagement/generated/runtime/BuildTime/Cmdlets/ExportPsd1.cs b/src/CostManagement/generated/runtime/BuildTime/Cmdlets/ExportPsd1.cs new file mode 100644 index 000000000000..c65f413764fe --- /dev/null +++ b/src/CostManagement/generated/runtime/BuildTime/Cmdlets/ExportPsd1.cs @@ -0,0 +1,125 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; +using System.IO; +using System.Linq; +using System.Management.Automation; +using System.Text; +using System.Text.RegularExpressions; +using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.PsHelpers; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell +{ + [Cmdlet(VerbsData.Export, "Psd1")] + [DoNotExport] + public class ExportPsd1 : PSCmdlet + { + [Parameter(Mandatory = true)] + [ValidateNotNullOrEmpty] + public string ExportsFolder { get; set; } + + [Parameter(Mandatory = true)] + [ValidateNotNullOrEmpty] + public string CustomFolder { get; set; } + + [Parameter(Mandatory = true)] + [ValidateNotNullOrEmpty] + public string Psd1Path { get; set; } + + [Parameter(Mandatory = true)] + public Guid ModuleGuid { get; set; } + + private static readonly bool IsAzure = Convert.ToBoolean(@"true"); + private const string CustomFolderRelative = "./custom"; + private const string Indent = Psd1Indent; + + protected override void ProcessRecord() + { + try + { + if (!Directory.Exists(ExportsFolder)) + { + throw new ArgumentException($"Exports folder '{ExportsFolder}' does not exist"); + } + + if (!Directory.Exists(CustomFolder)) + { + throw new ArgumentException($"Custom folder '{CustomFolder}' does not exist"); + } + + string version = Convert.ToString(@"0.1.0"); + // Validate the module version should be semantic version + // Following regex is official from https://semver.org/ + Regex rx = new Regex(@"^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$", RegexOptions.Compiled); + if (rx.Matches(version).Count != 1) + { + throw new ArgumentException("Module-version is not a valid Semantic Version"); + } + + string previewVersion = null; + if (version.Contains('-')) + { + string[] versions = version.Split("-".ToCharArray(), 2); + version = versions[0]; + previewVersion = versions[1]; + } + + var sb = new StringBuilder(); + sb.AppendLine("@{"); + sb.AppendLine($@"{GuidStart} = '{ModuleGuid}'"); + sb.AppendLine($@"{Indent}RootModule = '{"./Az.CostManagement.psm1"}'"); + sb.AppendLine($@"{Indent}ModuleVersion = '{version}'"); + sb.AppendLine($@"{Indent}CompatiblePSEditions = 'Core', 'Desktop'"); + sb.AppendLine($@"{Indent}Author = '{"Microsoft Corporation"}'"); + sb.AppendLine($@"{Indent}CompanyName = '{"Microsoft Corporation"}'"); + sb.AppendLine($@"{Indent}Copyright = '{"Microsoft Corporation. All rights reserved."}'"); + sb.AppendLine($@"{Indent}Description = '{"Microsoft Azure PowerShell: Cost cmdlets"}'"); + sb.AppendLine($@"{Indent}PowerShellVersion = '5.1'"); + sb.AppendLine($@"{Indent}DotNetFrameworkVersion = '4.7.2'"); + sb.AppendLine($@"{Indent}RequiredAssemblies = '{"./bin/Az.CostManagement.private.dll"}'"); + + var customFormatPs1xmlFiles = Directory.GetFiles(CustomFolder) + .Where(f => f.EndsWith(".format.ps1xml")) + .Select(f => $"{CustomFolderRelative}/{Path.GetFileName(f)}"); + var formatList = customFormatPs1xmlFiles.Prepend("./Az.CostManagement.format.ps1xml").ToPsList(); + sb.AppendLine($@"{Indent}FormatsToProcess = {formatList}"); + + var functionInfos = GetScriptCmdlets(ExportsFolder).ToArray(); + var cmdletsList = functionInfos.Select(fi => fi.Name).Distinct().Append("*").ToPsList(); + sb.AppendLine($@"{Indent}FunctionsToExport = {cmdletsList}"); + var aliasesList = functionInfos.SelectMany(fi => fi.ScriptBlock.Attributes).ToAliasNames().Append("*").ToPsList(); + sb.AppendLine($@"{Indent}AliasesToExport = {aliasesList}"); + + sb.AppendLine($@"{Indent}PrivateData = @{{"); + sb.AppendLine($@"{Indent}{Indent}PSData = @{{"); + + if (previewVersion != null) + { + sb.AppendLine($@"{Indent}{Indent}{Indent}Prerelease = {previewVersion}"); + } + sb.AppendLine($@"{Indent}{Indent}{Indent}Tags = {"Azure ResourceManager ARM PSModule Cost".Split(' ').ToPsList().NullIfEmpty() ?? "''"}"); + sb.AppendLine($@"{Indent}{Indent}{Indent}LicenseUri = '{"https://aka.ms/azps-license"}'"); + sb.AppendLine($@"{Indent}{Indent}{Indent}ProjectUri = '{"https://github.com/Azure/azure-powershell"}'"); + sb.AppendLine($@"{Indent}{Indent}{Indent}ReleaseNotes = ''"); + var profilesList = ""; + if (IsAzure && !String.IsNullOrEmpty(profilesList)) + { + sb.AppendLine($@"{Indent}{Indent}{Indent}Profiles = {profilesList}"); + } + + sb.AppendLine($@"{Indent}{Indent}}}"); + sb.AppendLine($@"{Indent}}}"); + sb.AppendLine(@"}"); + + File.WriteAllText(Psd1Path, sb.ToString()); + } + catch (Exception ee) + { + Console.WriteLine($"${ee.GetType().Name}/{ee.StackTrace}"); + throw ee; + } + } + } +} diff --git a/src/CostManagement/generated/runtime/BuildTime/Cmdlets/ExportTestStub.cs b/src/CostManagement/generated/runtime/BuildTime/Cmdlets/ExportTestStub.cs new file mode 100644 index 000000000000..7ede188afea1 --- /dev/null +++ b/src/CostManagement/generated/runtime/BuildTime/Cmdlets/ExportTestStub.cs @@ -0,0 +1,137 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; +using System.IO; +using System.Linq; +using System.Management.Automation; +using System.Text; +using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.PsProxyOutputExtensions; +using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.PsHelpers; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell +{ + [Cmdlet(VerbsData.Export, "TestStub")] + [DoNotExport] + public class ExportTestStub : PSCmdlet + { + [Parameter(Mandatory = true)] + [ValidateNotNullOrEmpty] + public string ModuleName { get; set; } + + [Parameter(Mandatory = true)] + [ValidateNotNullOrEmpty] + public string ExportsFolder { get; set; } + + [Parameter(Mandatory = true)] + [ValidateNotNullOrEmpty] + public string OutputFolder { get; set; } + + [Parameter] + public SwitchParameter IncludeGenerated { get; set; } + + protected override void ProcessRecord() + { + try + { + if (!Directory.Exists(ExportsFolder)) + { + throw new ArgumentException($"Exports folder '{ExportsFolder}' does not exist"); + } + + var exportDirectories = Directory.GetDirectories(ExportsFolder); + if (!exportDirectories.Any()) + { + exportDirectories = new[] { ExportsFolder }; + } + var utilFile = Path.Combine(OutputFolder, "utils.ps1"); + if (!File.Exists(utilFile)) + { + var sc = new StringBuilder(); + sc.AppendLine(@"function RandomString([bool]$allChars, [int32]$len) { + if ($allChars) { + return -join ((33..126) | Get-Random -Count $len | % {[char]$_}) + } else { + return -join ((48..57) + (97..122) | Get-Random -Count $len | % {[char]$_}) + } +} +$env = @{} +function setupEnv() { + # Preload subscriptionId and tenant from context, which will be used in test + # as default. You could change them if needed. + $env.SubscriptionId = (Get-AzContext).Subscription.Id + $env.Tenant = (Get-AzContext).Tenant.Id + # For any resources you created for test, you should add it to $env here. + $envFile = 'env.json' + if ($TestMode -eq 'live') { + $envFile = 'localEnv.json' + } + set-content -Path (Join-Path $PSScriptRoot $envFile) -Value (ConvertTo-Json $env) +} +function cleanupEnv() { + # Clean resources you create for testing +} +"); + File.WriteAllText(utilFile, sc.ToString()); + } + foreach (var exportDirectory in exportDirectories) + { + var outputFolder = OutputFolder; + if (exportDirectory != ExportsFolder) + { + outputFolder = Path.Combine(OutputFolder, Path.GetFileName(exportDirectory)); + Directory.CreateDirectory(outputFolder); + } + + var variantGroups = GetScriptCmdlets(exportDirectory) + .SelectMany(fi => fi.ToVariants()) + .Where(v => !v.IsDoNotExport) + .GroupBy(v => v.CmdletName) + .Select(vg => new VariantGroup(ModuleName, vg.Key, vg.Select(v => v).ToArray(), outputFolder, isTest: true)) + .Where(vtg => !File.Exists(vtg.FilePath) && (IncludeGenerated || !vtg.IsGenerated)); + + foreach (var variantGroup in variantGroups) + { + var sb = new StringBuilder(); + sb.AppendLine(@"$loadEnvPath = Join-Path $PSScriptRoot 'loadEnv.ps1' +if (-Not (Test-Path -Path $loadEnvPath)) { + $loadEnvPath = Join-Path $PSScriptRoot '..\loadEnv.ps1' +} +. ($loadEnvPath)" +); + sb.AppendLine($@"$TestRecordingFile = Join-Path $PSScriptRoot '{variantGroup.CmdletName}.Recording.json'"); + sb.AppendLine(@"$currentPath = $PSScriptRoot +while(-not $mockingPath) { + $mockingPath = Get-ChildItem -Path $currentPath -Recurse -Include 'HttpPipelineMocking.ps1' -File + $currentPath = Split-Path -Path $currentPath -Parent +} +. ($mockingPath | Select-Object -First 1).FullName +"); + + sb.AppendLine($"Describe '{variantGroup.CmdletName}' {{"); + var variants = variantGroup.Variants + .Where(v => IncludeGenerated || !v.Attributes.OfType().Any()) + .ToList(); + + foreach (var variant in variants) + { + sb.AppendLine($"{Indent}It '{variant.VariantName}' -skip {{"); + sb.AppendLine($"{Indent}{Indent}{{ throw [System.NotImplementedException] }} | Should -Not -Throw"); + var variantSeparator = variants.IndexOf(variant) == variants.Count - 1 ? String.Empty : Environment.NewLine; + sb.AppendLine($"{Indent}}}{variantSeparator}"); + } + sb.AppendLine("}"); + + File.WriteAllText(variantGroup.FilePath, sb.ToString()); + } + } + } + catch (Exception ee) + { + Console.WriteLine($"${ee.GetType().Name}/{ee.StackTrace}"); + throw ee; + } + } + } +} diff --git a/src/CostManagement/generated/runtime/BuildTime/Cmdlets/GetCommonParameter.cs b/src/CostManagement/generated/runtime/BuildTime/Cmdlets/GetCommonParameter.cs new file mode 100644 index 000000000000..850a6a7c1b98 --- /dev/null +++ b/src/CostManagement/generated/runtime/BuildTime/Cmdlets/GetCommonParameter.cs @@ -0,0 +1,52 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System.Collections.Generic; +using System.Linq; +using System.Management.Automation; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell +{ + [Cmdlet(VerbsCommon.Get, "CommonParameter")] + [OutputType(typeof(Dictionary))] + [DoNotExport] + public class GetCommonParameter : PSCmdlet + { + [Parameter(Mandatory = true)] + [ValidateNotNullOrEmpty] + public PSCmdlet PSCmdlet { get; set; } + + [Parameter(Mandatory = true)] + [ValidateNotNullOrEmpty] + public Dictionary PSBoundParameter { get; set; } + + protected override void ProcessRecord() + { + try + { + var variants = PSCmdlet.MyInvocation.MyCommand.ToVariants(); + var commonParameterNames = variants.ToParameterGroups() + .Where(pg => pg.OrderCategory == ParameterCategory.Azure || pg.OrderCategory == ParameterCategory.Runtime) + .Select(pg => pg.ParameterName); + if (variants.Any(v => v.SupportsShouldProcess)) + { + commonParameterNames = commonParameterNames.Append("Confirm").Append("WhatIf"); + } + if (variants.Any(v => v.SupportsPaging)) + { + commonParameterNames = commonParameterNames.Append("First").Append("Skip").Append("IncludeTotalCount"); + } + + var names = commonParameterNames.ToArray(); + var keys = PSBoundParameter.Keys.Where(k => names.Contains(k)); + WriteObject(keys.ToDictionary(key => key, key => PSBoundParameter[key]), true); + } + catch (System.Exception ee) + { + System.Console.WriteLine($"${ee.GetType().Name}/{ee.StackTrace}"); + throw ee; + } + } + } +} diff --git a/src/CostManagement/generated/runtime/BuildTime/Cmdlets/GetModuleGuid.cs b/src/CostManagement/generated/runtime/BuildTime/Cmdlets/GetModuleGuid.cs new file mode 100644 index 000000000000..0506071630f8 --- /dev/null +++ b/src/CostManagement/generated/runtime/BuildTime/Cmdlets/GetModuleGuid.cs @@ -0,0 +1,31 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System.Management.Automation; +using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.PsHelpers; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell +{ + [Cmdlet(VerbsCommon.Get, "ModuleGuid")] + [DoNotExport] + public class GetModuleGuid : PSCmdlet + { + [Parameter(Mandatory = true)] + [ValidateNotNullOrEmpty] + public string Psd1Path { get; set; } + + protected override void ProcessRecord() + { + try + { + WriteObject(ReadGuidFromPsd1(Psd1Path)); + } + catch (System.Exception ee) + { + System.Console.WriteLine($"${ee.GetType().Name}/{ee.StackTrace}"); + throw ee; + } + } + } +} diff --git a/src/CostManagement/generated/runtime/BuildTime/Cmdlets/GetScriptCmdlet.cs b/src/CostManagement/generated/runtime/BuildTime/Cmdlets/GetScriptCmdlet.cs new file mode 100644 index 000000000000..1169ac60c7c7 --- /dev/null +++ b/src/CostManagement/generated/runtime/BuildTime/Cmdlets/GetScriptCmdlet.cs @@ -0,0 +1,53 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System.Linq; +using System.Management.Automation; +using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.PsHelpers; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell +{ + [Cmdlet(VerbsCommon.Get, "ScriptCmdlet")] + [OutputType(typeof(string[]))] + [DoNotExport] + public class GetScriptCmdlet : PSCmdlet + { + [Parameter(Mandatory = true)] + [ValidateNotNullOrEmpty] + public string ScriptFolder { get; set; } + + [Parameter] + public SwitchParameter IncludeDoNotExport { get; set; } + + [Parameter] + public SwitchParameter AsAlias { get; set; } + + [Parameter] + public SwitchParameter AsFunctionInfo { get; set; } + + protected override void ProcessRecord() + { + try + { + var functionInfos = GetScriptCmdlets(this, ScriptFolder) + .Where(fi => IncludeDoNotExport || !fi.ScriptBlock.Attributes.OfType().Any()) + .ToArray(); + if (AsFunctionInfo) + { + WriteObject(functionInfos, true); + return; + } + var aliases = functionInfos.SelectMany(i => i.ScriptBlock.Attributes).ToAliasNames(); + var names = functionInfos.Select(fi => fi.Name).Distinct(); + var output = (AsAlias ? aliases : names).DefaultIfEmpty("''").ToArray(); + WriteObject(output, true); + } + catch (System.Exception ee) + { + System.Console.WriteLine($"${ee.GetType().Name}/{ee.StackTrace}"); + throw ee; + } + } + } +} diff --git a/src/CostManagement/generated/runtime/BuildTime/CollectionExtensions.cs b/src/CostManagement/generated/runtime/BuildTime/CollectionExtensions.cs new file mode 100644 index 000000000000..5b906828ec16 --- /dev/null +++ b/src/CostManagement/generated/runtime/BuildTime/CollectionExtensions.cs @@ -0,0 +1,20 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell +{ + internal static class CollectionExtensions + { + public static T[] NullIfEmpty(this T[] collection) => (collection?.Any() ?? false) ? collection : null; + public static IEnumerable EmptyIfNull(this IEnumerable collection) => collection ?? Enumerable.Empty(); + + // https://stackoverflow.com/a/4158364/294804 + public static IEnumerable DistinctBy(this IEnumerable collection, Func selector) => + collection.GroupBy(selector).Select(group => group.First()); + } +} diff --git a/src/CostManagement/generated/runtime/BuildTime/MarkdownRenderer.cs b/src/CostManagement/generated/runtime/BuildTime/MarkdownRenderer.cs new file mode 100644 index 000000000000..0057e6fae5fc --- /dev/null +++ b/src/CostManagement/generated/runtime/BuildTime/MarkdownRenderer.cs @@ -0,0 +1,121 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.MarkdownTypesExtensions; +using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.PsProxyOutputExtensions; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell +{ + internal static class MarkdownRenderer + { + public static void WriteMarkdowns(IEnumerable variantGroups, PsModuleHelpInfo moduleHelpInfo, string docsFolder, string examplesFolder) + { + Directory.CreateDirectory(docsFolder); + var markdownInfos = variantGroups.Where(vg => !vg.IsInternal).Select(vg => new MarkdownHelpInfo(vg, examplesFolder)).OrderBy(mhi => mhi.CmdletName).ToArray(); + + foreach (var markdownInfo in markdownInfos) + { + var sb = new StringBuilder(); + sb.Append(markdownInfo.ToHelpMetadataOutput()); + sb.Append($"# {markdownInfo.CmdletName}{Environment.NewLine}{Environment.NewLine}"); + sb.Append($"## SYNOPSIS{Environment.NewLine}{markdownInfo.Synopsis.ToDescriptionFormat()}{Environment.NewLine}{Environment.NewLine}"); + + sb.Append($"## SYNTAX{Environment.NewLine}{Environment.NewLine}"); + var hasMultipleParameterSets = markdownInfo.SyntaxInfos.Length > 1; + foreach (var syntaxInfo in markdownInfo.SyntaxInfos) + { + sb.Append(syntaxInfo.ToHelpSyntaxOutput(hasMultipleParameterSets)); + } + + sb.Append($"## DESCRIPTION{Environment.NewLine}{markdownInfo.Description.ToDescriptionFormat()}{Environment.NewLine}{Environment.NewLine}"); + + sb.Append($"## EXAMPLES{Environment.NewLine}{Environment.NewLine}"); + foreach (var exampleInfo in markdownInfo.Examples) + { + sb.Append(exampleInfo.ToHelpExampleOutput()); + } + + sb.Append($"## PARAMETERS{Environment.NewLine}{Environment.NewLine}"); + foreach (var parameter in markdownInfo.Parameters) + { + sb.Append(parameter.ToHelpParameterOutput()); + } + if (markdownInfo.SupportsShouldProcess) + { + foreach (var parameter in SupportsShouldProcessParameters) + { + sb.Append(parameter.ToHelpParameterOutput()); + } + } + if (markdownInfo.SupportsPaging) + { + foreach (var parameter in SupportsPagingParameters) + { + sb.Append(parameter.ToHelpParameterOutput()); + } + } + + sb.Append($"### CommonParameters{Environment.NewLine}This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).{Environment.NewLine}{Environment.NewLine}"); + + sb.Append($"## INPUTS{Environment.NewLine}{Environment.NewLine}"); + foreach (var input in markdownInfo.Inputs) + { + sb.Append($"### {input}{Environment.NewLine}{Environment.NewLine}"); + } + + sb.Append($"## OUTPUTS{Environment.NewLine}{Environment.NewLine}"); + foreach (var output in markdownInfo.Outputs) + { + sb.Append($"### {output}{Environment.NewLine}{Environment.NewLine}"); + } + + sb.Append($"## NOTES{Environment.NewLine}{Environment.NewLine}"); + sb.Append($"ALIASES{Environment.NewLine}{Environment.NewLine}"); + foreach (var alias in markdownInfo.Aliases) + { + sb.Append($"### {alias}{Environment.NewLine}{Environment.NewLine}"); + } + if (markdownInfo.ComplexInterfaceInfos.Any()) + { + sb.Append($"{ComplexParameterHeader}{Environment.NewLine}"); + } + foreach (var complexInterfaceInfo in markdownInfo.ComplexInterfaceInfos) + { + sb.Append($"{complexInterfaceInfo.ToNoteOutput(includeDashes: true, includeBackticks: true)}{Environment.NewLine}{Environment.NewLine}"); + } + + sb.Append($"## RELATED LINKS{Environment.NewLine}{Environment.NewLine}"); + foreach (var relatedLink in markdownInfo.RelatedLinks) + { + sb.Append($"{relatedLink}{Environment.NewLine}{Environment.NewLine}"); + } + + File.WriteAllText(Path.Combine(docsFolder, $"{markdownInfo.CmdletName}.md"), sb.ToString()); + } + + WriteModulePage(moduleHelpInfo, markdownInfos, docsFolder); + } + + private static void WriteModulePage(PsModuleHelpInfo moduleInfo, MarkdownHelpInfo[] markdownInfos, string docsFolder) + { + var sb = new StringBuilder(); + sb.Append(moduleInfo.ToModulePageMetadataOutput()); + sb.Append($"# {moduleInfo.Name} Module{Environment.NewLine}"); + sb.Append($"## Description{Environment.NewLine}{moduleInfo.Description.ToDescriptionFormat()}{Environment.NewLine}{Environment.NewLine}"); + + sb.Append($"## {moduleInfo.Name} Cmdlets{Environment.NewLine}"); + foreach (var markdownInfo in markdownInfos) + { + sb.Append(markdownInfo.ToModulePageCmdletOutput()); + } + + File.WriteAllText(Path.Combine(docsFolder, $"{moduleInfo.Name}.md"), sb.ToString()); + } + } +} diff --git a/src/CostManagement/generated/runtime/BuildTime/Models/PsFormatTypes.cs b/src/CostManagement/generated/runtime/BuildTime/Models/PsFormatTypes.cs new file mode 100644 index 000000000000..af187d2a5676 --- /dev/null +++ b/src/CostManagement/generated/runtime/BuildTime/Models/PsFormatTypes.cs @@ -0,0 +1,138 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Xml.Serialization; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell +{ + internal class ViewParameters + { + public Type Type { get; } + public IEnumerable Properties { get; } + + public ViewParameters(Type type, IEnumerable properties) + { + Type = type; + Properties = properties; + } + } + + internal class PropertyFormat + { + public PropertyInfo Property { get; } + public FormatTableAttribute FormatTable { get; } + + public int? Index { get; } + public string Label { get; } + public int? Width { get; } + public PropertyOrigin? Origin { get; } + + public PropertyFormat(PropertyInfo propertyInfo) + { + Property = propertyInfo; + FormatTable = Property.GetCustomAttributes().FirstOrDefault(); + var origin = Property.GetCustomAttributes().FirstOrDefault(); + + Index = FormatTable?.HasIndex ?? false ? (int?)FormatTable.Index : null; + Label = FormatTable?.Label ?? propertyInfo.Name; + Width = FormatTable?.HasWidth ?? false ? (int?)FormatTable.Width : null; + // If we have an index, we don't want to use Origin. + Origin = FormatTable?.HasIndex ?? false ? null : origin?.Origin; + } + } + + [Serializable] + [XmlRoot(nameof(Configuration))] + public class Configuration + { + [XmlElement("ViewDefinitions")] + public ViewDefinitions ViewDefinitions { get; set; } + } + + [Serializable] + public class ViewDefinitions + { + //https://stackoverflow.com/a/10518657/294804 + [XmlElement("View")] + public List Views { get; set; } + } + + [Serializable] + public class View + { + [XmlElement(nameof(Name))] + public string Name { get; set; } + [XmlElement(nameof(ViewSelectedBy))] + public ViewSelectedBy ViewSelectedBy { get; set; } + [XmlElement(nameof(TableControl))] + public TableControl TableControl { get; set; } + } + + [Serializable] + public class ViewSelectedBy + { + [XmlElement(nameof(TypeName))] + public string TypeName { get; set; } + } + + [Serializable] + public class TableControl + { + [XmlElement(nameof(TableHeaders))] + public TableHeaders TableHeaders { get; set; } + [XmlElement(nameof(TableRowEntries))] + public TableRowEntries TableRowEntries { get; set; } + } + + [Serializable] + public class TableHeaders + { + [XmlElement("TableColumnHeader")] + public List TableColumnHeaders { get; set; } + } + + [Serializable] + public class TableColumnHeader + { + [XmlElement(nameof(Label))] + public string Label { get; set; } + [XmlElement(nameof(Width))] + public int? Width { get; set; } + + //https://stackoverflow.com/a/4095225/294804 + public bool ShouldSerializeWidth() => Width.HasValue; + } + + [Serializable] + public class TableRowEntries + { + [XmlElement(nameof(TableRowEntry))] + public TableRowEntry TableRowEntry { get; set; } + } + + [Serializable] + public class TableRowEntry + { + [XmlElement(nameof(TableColumnItems))] + public TableColumnItems TableColumnItems { get; set; } + } + + [Serializable] + public class TableColumnItems + { + [XmlElement("TableColumnItem")] + public List TableItems { get; set; } + } + + [Serializable] + public class TableColumnItem + { + [XmlElement(nameof(PropertyName))] + public string PropertyName { get; set; } + } +} diff --git a/src/CostManagement/generated/runtime/BuildTime/Models/PsHelpMarkdownOutputs.cs b/src/CostManagement/generated/runtime/BuildTime/Models/PsHelpMarkdownOutputs.cs new file mode 100644 index 000000000000..22b21641bf36 --- /dev/null +++ b/src/CostManagement/generated/runtime/BuildTime/Models/PsHelpMarkdownOutputs.cs @@ -0,0 +1,177 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; +using System.Linq; +using System.Management.Automation; +using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.PsHelpOutputExtensions; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell +{ + internal class HelpMetadataOutput + { + public MarkdownHelpInfo HelpInfo { get; } + + public HelpMetadataOutput(MarkdownHelpInfo helpInfo) + { + HelpInfo = helpInfo; + } + + public override string ToString() => $@"--- +external help file:{(!String.IsNullOrEmpty(HelpInfo.ExternalHelpFilename) ? $" {HelpInfo.ExternalHelpFilename}" : String.Empty)} +Module Name: {HelpInfo.ModuleName} +online version: {HelpInfo.OnlineVersion} +schema: {HelpInfo.Schema.ToString(3)} +--- + +"; + } + + internal class HelpSyntaxOutput + { + public MarkdownSyntaxHelpInfo SyntaxInfo { get; } + public bool HasMultipleParameterSets { get; } + + public HelpSyntaxOutput(MarkdownSyntaxHelpInfo syntaxInfo, bool hasMultipleParameterSets) + { + SyntaxInfo = syntaxInfo; + HasMultipleParameterSets = hasMultipleParameterSets; + } + + public override string ToString() + { + var psnText = HasMultipleParameterSets ? $"### {SyntaxInfo.ParameterSetName}{(SyntaxInfo.IsDefault ? " (Default)" : String.Empty)}{Environment.NewLine}" : String.Empty; + return $@"{psnText}``` +{SyntaxInfo.SyntaxText} +``` + +"; + } + } + + internal class HelpExampleOutput + { + public MarkdownExampleHelpInfo ExampleInfo { get; } + + public HelpExampleOutput(MarkdownExampleHelpInfo exampleInfo) + { + ExampleInfo = exampleInfo; + } + + public override string ToString() => $@"{ExampleNameHeader}{ExampleInfo.Name} +{ExampleCodeHeader} +{ExampleInfo.Code} +{ExampleCodeFooter} + +{ExampleInfo.Description.ToDescriptionFormat()} + +"; + } + + + internal class HelpParameterOutput + { + public MarkdownParameterHelpInfo ParameterInfo { get; } + + public HelpParameterOutput(MarkdownParameterHelpInfo parameterInfo) + { + ParameterInfo = parameterInfo; + } + + public override string ToString() + { + var pipelineInputTypes = new[] + { + ParameterInfo.AcceptsPipelineByValue ? "ByValue" : String.Empty, + ParameterInfo.AcceptsPipelineByPropertyName ? "ByPropertyName" : String.Empty + }.JoinIgnoreEmpty(", "); + var pipelineInput = ParameterInfo.AcceptsPipelineByValue || ParameterInfo.AcceptsPipelineByPropertyName + ? $@"{true} ({pipelineInputTypes})" + : false.ToString(); + + return $@"### -{ParameterInfo.Name} +{ParameterInfo.Description.ToDescriptionFormat()} + +```yaml +Type: {ParameterInfo.Type.FullName} +Parameter Sets: {(ParameterInfo.HasAllParameterSets ? "(All)" : ParameterInfo.ParameterSetNames.JoinIgnoreEmpty(", "))} +Aliases:{(ParameterInfo.Aliases.Any() ? $" {ParameterInfo.Aliases.JoinIgnoreEmpty(", ")}" : String.Empty)} + +Required: {ParameterInfo.IsRequired} +Position: {ParameterInfo.Position} +Default value: {ParameterInfo.DefaultValue} +Accept pipeline input: {pipelineInput} +Accept wildcard characters: {ParameterInfo.AcceptsWildcardCharacters} +``` + +"; + } + } + + internal class ModulePageMetadataOutput + { + public PsModuleHelpInfo ModuleInfo { get; } + + private static string HelpLinkPrefix { get; } = @"https://docs.microsoft.com/en-us/powershell/module/"; + + public ModulePageMetadataOutput(PsModuleHelpInfo moduleInfo) + { + ModuleInfo = moduleInfo; + } + + public override string ToString() => $@"--- +Module Name: {ModuleInfo.Name} +Module Guid: {ModuleInfo.Guid} +Download Help Link: {HelpLinkPrefix}{ModuleInfo.Name.ToLowerInvariant()} +Help Version: 1.0.0.0 +Locale: en-US +--- + +"; + } + + internal class ModulePageCmdletOutput + { + public MarkdownHelpInfo HelpInfo { get; } + + public ModulePageCmdletOutput(MarkdownHelpInfo helpInfo) + { + HelpInfo = helpInfo; + } + + public override string ToString() => $@"### [{HelpInfo.CmdletName}]({HelpInfo.CmdletName}.md) +{HelpInfo.Description.ToDescriptionFormat()} + +"; + } + + internal static class PsHelpOutputExtensions + { + public static string EscapeAngleBrackets(this string text) => text?.Replace("<", @"\<").Replace(">", @"\>"); + public static string ReplaceSentenceEndWithNewline(this string text) => text?.Replace(". ", $".{Environment.NewLine}").Replace(". ", $".{Environment.NewLine}"); + public static string ReplaceBrWithNewline(this string text) => text?.Replace("
", $"{Environment.NewLine}"); + public static string ToDescriptionFormat(this string text, bool escapeAngleBrackets = true) + { + var description = text?.ReplaceBrWithNewline(); + description = escapeAngleBrackets ? description?.EscapeAngleBrackets() : description; + return description?.ReplaceSentenceEndWithNewline().Trim(); + } + + public const string ExampleNameHeader = "### "; + public const string ExampleCodeHeader = "```powershell"; + public const string ExampleCodeFooter = "```"; + + public static HelpMetadataOutput ToHelpMetadataOutput(this MarkdownHelpInfo helpInfo) => new HelpMetadataOutput(helpInfo); + + public static HelpSyntaxOutput ToHelpSyntaxOutput(this MarkdownSyntaxHelpInfo syntaxInfo, bool hasMultipleParameterSets) => new HelpSyntaxOutput(syntaxInfo, hasMultipleParameterSets); + + public static HelpExampleOutput ToHelpExampleOutput(this MarkdownExampleHelpInfo exampleInfo) => new HelpExampleOutput(exampleInfo); + + public static HelpParameterOutput ToHelpParameterOutput(this MarkdownParameterHelpInfo parameterInfo) => new HelpParameterOutput(parameterInfo); + + public static ModulePageMetadataOutput ToModulePageMetadataOutput(this PsModuleHelpInfo moduleInfo) => new ModulePageMetadataOutput(moduleInfo); + + public static ModulePageCmdletOutput ToModulePageCmdletOutput(this MarkdownHelpInfo helpInfo) => new ModulePageCmdletOutput(helpInfo); + } +} diff --git a/src/CostManagement/generated/runtime/BuildTime/Models/PsHelpTypes.cs b/src/CostManagement/generated/runtime/BuildTime/Models/PsHelpTypes.cs new file mode 100644 index 000000000000..1b39c9f2f93b --- /dev/null +++ b/src/CostManagement/generated/runtime/BuildTime/Models/PsHelpTypes.cs @@ -0,0 +1,199 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Management.Automation; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell +{ + internal class PsHelpInfo + { + public string CmdletName { get; } + public string ModuleName { get; } + public string Synopsis { get; } + public string Description { get; } + public string AlertText { get; } + public string Category { get; } + public PsHelpLinkInfo OnlineVersion { get; } + public PsHelpLinkInfo[] RelatedLinks { get; } + public bool? HasCommonParameters { get; } + public bool? HasWorkflowCommonParameters { get; } + + public PsHelpTypeInfo[] InputTypes { get; } + public PsHelpTypeInfo[] OutputTypes { get; } + public PsHelpExampleInfo[] Examples { get; set; } + public string[] Aliases { get; } + + public PsParameterHelpInfo[] Parameters { get; } + public PsHelpSyntaxInfo[] Syntax { get; } + + public object Component { get; } + public object Functionality { get; } + public object PsSnapIn { get; } + public object Role { get; } + public string NonTerminatingErrors { get; } + + public PsHelpInfo(PSObject helpObject = null) + { + helpObject = helpObject ?? new PSObject(); + CmdletName = helpObject.GetProperty("Name").NullIfEmpty() ?? helpObject.GetNestedProperty("details", "name"); + ModuleName = helpObject.GetProperty("ModuleName"); + Synopsis = helpObject.GetProperty("Synopsis"); + Description = helpObject.GetProperty("description").EmptyIfNull().ToDescriptionText().NullIfEmpty() ?? + helpObject.GetNestedProperty("details", "description").EmptyIfNull().ToDescriptionText(); + AlertText = helpObject.GetNestedProperty("alertSet", "alert").EmptyIfNull().ToDescriptionText(); + Category = helpObject.GetProperty("Category"); + HasCommonParameters = helpObject.GetProperty("CommonParameters").ToNullableBool(); + HasWorkflowCommonParameters = helpObject.GetProperty("WorkflowCommonParameters").ToNullableBool(); + + var links = helpObject.GetNestedProperty("relatedLinks", "navigationLink").EmptyIfNull().Select(nl => nl.ToLinkInfo()).ToArray(); + OnlineVersion = links.FirstOrDefault(l => l.Text?.ToLowerInvariant().StartsWith("online version:") ?? links.Length == 1); + RelatedLinks = links.Where(l => !l.Text?.ToLowerInvariant().StartsWith("online version:") ?? links.Length != 1).ToArray(); + + InputTypes = helpObject.GetNestedProperty("inputTypes", "inputType").EmptyIfNull().Select(it => it.ToTypeInfo()).ToArray(); + OutputTypes = helpObject.GetNestedProperty("returnValues", "returnValue").EmptyIfNull().Select(rv => rv.ToTypeInfo()).ToArray(); + Examples = helpObject.GetNestedProperty("examples", "example").EmptyIfNull().Select(e => e.ToExampleInfo()).ToArray(); + Aliases = helpObject.GetProperty("aliases").EmptyIfNull().Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); + + Parameters = helpObject.GetNestedProperty("parameters", "parameter").EmptyIfNull().Select(p => p.ToPsParameterHelpInfo()).ToArray(); + Syntax = helpObject.GetNestedProperty("syntax", "syntaxItem").EmptyIfNull().Select(si => si.ToSyntaxInfo()).ToArray(); + + Component = helpObject.GetProperty("Component"); + Functionality = helpObject.GetProperty("Functionality"); + PsSnapIn = helpObject.GetProperty("PSSnapIn"); + Role = helpObject.GetProperty("Role"); + NonTerminatingErrors = helpObject.GetProperty("nonTerminatingErrors"); + } + } + + internal class PsHelpTypeInfo + { + public string Name { get; } + public string Description { get; } + + public PsHelpTypeInfo(PSObject typeObject) + { + Name = typeObject.GetNestedProperty("type", "name").EmptyIfNull().Trim(); + Description = typeObject.GetProperty("description").EmptyIfNull().ToDescriptionText(); + } + } + + internal class PsHelpLinkInfo + { + public string Uri { get; } + public string Text { get; } + + public PsHelpLinkInfo(PSObject linkObject) + { + Uri = linkObject.GetProperty("uri"); + Text = linkObject.GetProperty("linkText"); + } + } + + internal class PsHelpSyntaxInfo + { + public string CmdletName { get; } + public PsParameterHelpInfo[] Parameters { get; } + + public PsHelpSyntaxInfo(PSObject syntaxObject) + { + CmdletName = syntaxObject.GetProperty("name"); + Parameters = syntaxObject.GetProperty("parameter").EmptyIfNull().Select(p => p.ToPsParameterHelpInfo()).ToArray(); + } + } + + internal class PsHelpExampleInfo + { + public string Title { get; } + public string Code { get; } + public string Remarks { get; } + + public PsHelpExampleInfo(PSObject exampleObject) + { + Title = exampleObject.GetProperty("title"); + Code = exampleObject.GetProperty("code"); + Remarks = exampleObject.GetProperty("remarks").EmptyIfNull().ToDescriptionText(); + } + public PsHelpExampleInfo(MarkdownExampleHelpInfo markdownExample) + { + Title = markdownExample.Name; + Code = markdownExample.Code; + Remarks = markdownExample.Description; + } + + public static implicit operator PsHelpExampleInfo(MarkdownExampleHelpInfo markdownExample) => new PsHelpExampleInfo(markdownExample); + } + + internal class PsParameterHelpInfo + { + public string DefaultValueAsString { get; } + + public string Name { get; } + public string TypeName { get; } + public string Description { get; } + public string SupportsPipelineInput { get; } + public string PositionText { get; } + public string[] ParameterSetNames { get; } + public string[] Aliases { get; } + + public bool? SupportsGlobbing { get; } + public bool? IsRequired { get; } + public bool? IsVariableLength { get; } + public bool? IsDynamic { get; } + + public PsParameterHelpInfo(PSObject parameterHelpObject = null) + { + parameterHelpObject = parameterHelpObject ?? new PSObject(); + DefaultValueAsString = parameterHelpObject.GetProperty("defaultValue"); + Name = parameterHelpObject.GetProperty("name"); + TypeName = parameterHelpObject.GetProperty("parameterValue").NullIfEmpty() ?? parameterHelpObject.GetNestedProperty("type", "name"); + Description = parameterHelpObject.GetProperty("Description").EmptyIfNull().ToDescriptionText(); + SupportsPipelineInput = parameterHelpObject.GetProperty("pipelineInput"); + PositionText = parameterHelpObject.GetProperty("position"); + ParameterSetNames = parameterHelpObject.GetProperty("parameterSetName").EmptyIfNull().Split(new[] { ", " }, StringSplitOptions.RemoveEmptyEntries); + Aliases = parameterHelpObject.GetProperty("aliases").EmptyIfNull().Split(new[] { ", " }, StringSplitOptions.RemoveEmptyEntries); + + SupportsGlobbing = parameterHelpObject.GetProperty("globbing").ToNullableBool(); + IsRequired = parameterHelpObject.GetProperty("required").ToNullableBool(); + IsVariableLength = parameterHelpObject.GetProperty("variableLength").ToNullableBool(); + IsDynamic = parameterHelpObject.GetProperty("isDynamic").ToNullableBool(); + } + } + + internal class PsModuleHelpInfo + { + public string Name { get; } + public Guid Guid { get; } + public string Description { get; } + + public PsModuleHelpInfo(PSModuleInfo moduleInfo) + : this(moduleInfo?.Name ?? String.Empty, moduleInfo?.Guid ?? Guid.NewGuid(), moduleInfo?.Description ?? String.Empty) + { + } + + public PsModuleHelpInfo(string name, Guid guid, string description) + { + Name = name; + Guid = guid; + Description = description; + } + } + + internal static class HelpTypesExtensions + { + public static PsHelpInfo ToPsHelpInfo(this PSObject helpObject) => new PsHelpInfo(helpObject); + public static PsParameterHelpInfo ToPsParameterHelpInfo(this PSObject parameterHelpObject) => new PsParameterHelpInfo(parameterHelpObject); + + public static string ToDescriptionText(this IEnumerable descriptionObject) => descriptionObject != null + ? String.Join(Environment.NewLine, descriptionObject.Select(dl => dl.GetProperty("Text").EmptyIfNull())).NullIfWhiteSpace() + : null; + public static PsHelpTypeInfo ToTypeInfo(this PSObject typeObject) => new PsHelpTypeInfo(typeObject); + public static PsHelpExampleInfo ToExampleInfo(this PSObject exampleObject) => new PsHelpExampleInfo(exampleObject); + public static PsHelpLinkInfo ToLinkInfo(this PSObject linkObject) => new PsHelpLinkInfo(linkObject); + public static PsHelpSyntaxInfo ToSyntaxInfo(this PSObject syntaxObject) => new PsHelpSyntaxInfo(syntaxObject); + public static PsModuleHelpInfo ToModuleInfo(this PSModuleInfo moduleInfo) => new PsModuleHelpInfo(moduleInfo); + } +} diff --git a/src/CostManagement/generated/runtime/BuildTime/Models/PsMarkdownTypes.cs b/src/CostManagement/generated/runtime/BuildTime/Models/PsMarkdownTypes.cs new file mode 100644 index 000000000000..fe251fd52858 --- /dev/null +++ b/src/CostManagement/generated/runtime/BuildTime/Models/PsMarkdownTypes.cs @@ -0,0 +1,291 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Management.Automation; +using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.MarkdownTypesExtensions; +using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.PsHelpOutputExtensions; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell +{ + internal class MarkdownHelpInfo + { + public string ExternalHelpFilename { get; } + public string ModuleName { get; } + public string OnlineVersion { get; } + public Version Schema { get; } + + public string CmdletName { get; } + public string[] Aliases { get; } + public string Synopsis { get; } + public string Description { get; } + + public MarkdownSyntaxHelpInfo[] SyntaxInfos { get; } + public MarkdownExampleHelpInfo[] Examples { get; } + public MarkdownParameterHelpInfo[] Parameters { get; } + + public string[] Inputs { get; } + public string[] Outputs { get; } + public ComplexInterfaceInfo[] ComplexInterfaceInfos { get; } + public string[] RelatedLinks { get; } + + public bool SupportsShouldProcess { get; } + public bool SupportsPaging { get; } + + public MarkdownHelpInfo(VariantGroup variantGroup, string examplesFolder, string externalHelpFilename = "") + { + ExternalHelpFilename = externalHelpFilename; + ModuleName = variantGroup.ModuleName; + var helpInfo = variantGroup.HelpInfo; + var commentInfo = variantGroup.CommentInfo; + Schema = Version.Parse("2.0.0"); + + CmdletName = variantGroup.CmdletName; + Aliases = (variantGroup.Aliases.NullIfEmpty() ?? helpInfo.Aliases).Where(a => a != "None").ToArray(); + Synopsis = commentInfo.Synopsis; + Description = commentInfo.Description; + + SyntaxInfos = variantGroup.Variants + .Select(v => new MarkdownSyntaxHelpInfo(v, variantGroup.ParameterGroups, v.VariantName == variantGroup.DefaultParameterSetName)) + .OrderByDescending(v => v.IsDefault).ThenBy(v => v.ParameterSetName).ToArray(); + Examples = GetExamplesFromMarkdown(examplesFolder).NullIfEmpty() + ?? helpInfo.Examples.Select(e => e.ToExampleHelpInfo()).ToArray().NullIfEmpty() + ?? DefaultExampleHelpInfos; + + Parameters = variantGroup.ParameterGroups + .Where(pg => !pg.DontShow) + .Select(pg => new MarkdownParameterHelpInfo( + variantGroup.Variants.SelectMany(v => v.HelpInfo.Parameters).Where(phi => phi.Name == pg.ParameterName).ToArray(), pg)) + .OrderBy(phi => phi.Name).ToArray(); + + Inputs = commentInfo.Inputs; + Outputs = commentInfo.Outputs; + + ComplexInterfaceInfos = variantGroup.ComplexInterfaceInfos; + OnlineVersion = commentInfo.OnlineVersion; + RelatedLinks = commentInfo.RelatedLinks; + + SupportsShouldProcess = variantGroup.SupportsShouldProcess; + SupportsPaging = variantGroup.SupportsPaging; + } + + private MarkdownExampleHelpInfo[] GetExamplesFromMarkdown(string examplesFolder) + { + var filePath = Path.Combine(examplesFolder, $"{CmdletName}.md"); + if (!Directory.Exists(examplesFolder) || !File.Exists(filePath)) return null; + + var lines = File.ReadAllLines(filePath); + var nameIndices = lines.Select((l, i) => l.StartsWith(ExampleNameHeader) ? i : -1).Where(i => i != -1).ToArray(); + //https://codereview.stackexchange.com/a/187148/68772 + var indexCountGroups = nameIndices.Skip(1).Append(lines.Length).Zip(nameIndices, (next, current) => (NameIndex: current, LineCount: next - current)); + var exampleGroups = indexCountGroups.Select(icg => lines.Skip(icg.NameIndex).Take(icg.LineCount).ToArray()); + return exampleGroups.Select(eg => + { + var name = eg.First().Replace(ExampleNameHeader, String.Empty); + var codeStartIndex = eg.Select((l, i) => l.StartsWith(ExampleCodeHeader) ? (int?)i : null).FirstOrDefault(i => i.HasValue); + var codeEndIndex = eg.Select((l, i) => l.StartsWith(ExampleCodeFooter) ? (int?)i : null).FirstOrDefault(i => i.HasValue && i != codeStartIndex); + var code = codeStartIndex.HasValue && codeEndIndex.HasValue + ? String.Join(Environment.NewLine, eg.Skip(codeStartIndex.Value + 1).Take(codeEndIndex.Value - (codeStartIndex.Value + 1))) + : String.Empty; + var descriptionStartIndex = (codeEndIndex ?? 0) + 1; + descriptionStartIndex = String.IsNullOrWhiteSpace(eg[descriptionStartIndex]) ? descriptionStartIndex + 1 : descriptionStartIndex; + var descriptionEndIndex = eg.Length - 1; + descriptionEndIndex = String.IsNullOrWhiteSpace(eg[descriptionEndIndex]) ? descriptionEndIndex - 1 : descriptionEndIndex; + var description = String.Join(Environment.NewLine, eg.Skip(descriptionStartIndex).Take((descriptionEndIndex + 1) - descriptionStartIndex)); + return new MarkdownExampleHelpInfo(name, code, description); + }).ToArray(); + } + } + + internal class MarkdownSyntaxHelpInfo + { + public Variant Variant { get; } + public bool IsDefault { get; } + public string ParameterSetName { get; } + public Parameter[] Parameters { get; } + public string SyntaxText { get; } + + public MarkdownSyntaxHelpInfo(Variant variant, ParameterGroup[] parameterGroups, bool isDefault) + { + Variant = variant; + IsDefault = isDefault; + ParameterSetName = Variant.VariantName; + Parameters = Variant.Parameters + .Where(p => !p.DontShow).OrderByDescending(p => p.IsMandatory) + //https://stackoverflow.com/a/6461526/294804 + .ThenByDescending(p => p.Position.HasValue).ThenBy(p => p.Position) + // Use the OrderCategory of the parameter group because the final order category is the highest of the group, and not the order category of the individual parameters from the variants. + .ThenBy(p => parameterGroups.First(pg => pg.ParameterName == p.ParameterName).OrderCategory).ThenBy(p => p.ParameterName).ToArray(); + SyntaxText = CreateSyntaxFormat(); + } + + //https://github.com/PowerShell/platyPS/blob/a607a926bfffe1e1a1e53c19e0057eddd0c07611/src/Markdown.MAML/Renderer/Markdownv2Renderer.cs#L29-L32 + private const int SyntaxLineWidth = 110; + private string CreateSyntaxFormat() + { + var parameterStrings = Parameters.Select(p => p.ToPropertySyntaxOutput().ToString()); + if (Variant.SupportsShouldProcess) + { + parameterStrings = parameterStrings.Append(" [-Confirm]").Append(" [-WhatIf]"); + } + if (Variant.SupportsPaging) + { + parameterStrings = parameterStrings.Append(" [-First ]").Append(" [-IncludeTotalCount]").Append(" [-Skip ]"); + } + parameterStrings = parameterStrings.Append(" []"); + + var lines = new List(20); + return parameterStrings.Aggregate(Variant.CmdletName, (current, ps) => + { + var combined = current + ps; + if (combined.Length <= SyntaxLineWidth) return combined; + + lines.Add(current); + return ps; + }, last => + { + lines.Add(last); + return String.Join(Environment.NewLine, lines); + }); + } + } + + internal class MarkdownExampleHelpInfo + { + public string Name { get; } + public string Code { get; } + public string Description { get; } + + public MarkdownExampleHelpInfo(string name, string code, string description) + { + Name = name; + Code = code; + Description = description; + } + } + + internal class MarkdownParameterHelpInfo + { + public string Name { get; set; } + public string Description { get; set; } + public Type Type { get; set; } + public string Position { get; set; } + public string DefaultValue { get; set; } + + public bool HasAllParameterSets { get; set; } + public string[] ParameterSetNames { get; set; } + public string[] Aliases { get; set; } + + public bool IsRequired { get; set; } + public bool IsDynamic { get; set; } + public bool AcceptsPipelineByValue { get; set; } + public bool AcceptsPipelineByPropertyName { get; set; } + public bool AcceptsWildcardCharacters { get; set; } + + // For use by common parameters that have no backing data in the objects themselves. + public MarkdownParameterHelpInfo() { } + + public MarkdownParameterHelpInfo(PsParameterHelpInfo[] parameterHelpInfos, ParameterGroup parameterGroup) + { + Name = parameterGroup.ParameterName; + Description = parameterGroup.Description.NullIfEmpty() + ?? parameterHelpInfos.Select(phi => phi.Description).FirstOrDefault(d => !String.IsNullOrEmpty(d)).EmptyIfNull(); + Type = parameterGroup.ParameterType; + Position = parameterGroup.FirstPosition?.ToString() + ?? parameterHelpInfos.Select(phi => phi.PositionText).FirstOrDefault(d => !String.IsNullOrEmpty(d)).ToUpperFirstCharacter().NullIfEmpty() + ?? "Named"; + // This no longer uses firstHelpInfo.DefaultValueAsString since it seems to be broken. For example, it has a value of 0 for Int32, but no default value was declared. + DefaultValue = parameterGroup.DefaultInfo?.Script ?? "None"; + + HasAllParameterSets = parameterGroup.HasAllVariants; + ParameterSetNames = (parameterGroup.Parameters.Select(p => p.VariantName).ToArray().NullIfEmpty() + ?? parameterHelpInfos.SelectMany(phi => phi.ParameterSetNames).Distinct()) + .OrderBy(psn => psn).ToArray(); + Aliases = parameterGroup.Aliases.NullIfEmpty() ?? parameterHelpInfos.SelectMany(phi => phi.Aliases).ToArray(); + + IsRequired = parameterHelpInfos.Select(phi => phi.IsRequired).FirstOrDefault(r => r == true) ?? parameterGroup.Parameters.Any(p => p.IsMandatory); + IsDynamic = parameterHelpInfos.Select(phi => phi.IsDynamic).FirstOrDefault(d => d == true) ?? false; + AcceptsPipelineByValue = parameterHelpInfos.Select(phi => phi.SupportsPipelineInput?.Contains("ByValue")).FirstOrDefault(bv => bv == true) ?? parameterGroup.ValueFromPipeline; + AcceptsPipelineByPropertyName = parameterHelpInfos.Select(phi => phi.SupportsPipelineInput?.Contains("ByPropertyName")).FirstOrDefault(bv => bv == true) ?? parameterGroup.ValueFromPipelineByPropertyName; + AcceptsWildcardCharacters = parameterGroup.SupportsWildcards; + } + } + + internal static class MarkdownTypesExtensions + { + public static MarkdownExampleHelpInfo ToExampleHelpInfo(this PsHelpExampleInfo exampleInfo) => new MarkdownExampleHelpInfo(exampleInfo.Title, exampleInfo.Code, exampleInfo.Remarks); + + public static MarkdownExampleHelpInfo[] DefaultExampleHelpInfos = + { + new MarkdownExampleHelpInfo("Example 1: {{ Add title here }}", $@"PS C:\> {{{{ Add code here }}}}{Environment.NewLine}{Environment.NewLine}{{{{ Add output here }}}}", @"{{ Add description here }}"), + new MarkdownExampleHelpInfo("Example 2: {{ Add title here }}", $@"PS C:\> {{{{ Add code here }}}}{Environment.NewLine}{Environment.NewLine}{{{{ Add output here }}}}", @"{{ Add description here }}") + }; + + public static MarkdownParameterHelpInfo[] SupportsShouldProcessParameters = + { + new MarkdownParameterHelpInfo + { + Name = "Confirm", + Description ="Prompts you for confirmation before running the cmdlet.", + Type = typeof(SwitchParameter), + Position = "Named", + DefaultValue = "None", + HasAllParameterSets = true, + ParameterSetNames = new [] { "(All)" }, + Aliases = new [] { "cf" } + }, + new MarkdownParameterHelpInfo + { + Name = "WhatIf", + Description ="Shows what would happen if the cmdlet runs. The cmdlet is not run.", + Type = typeof(SwitchParameter), + Position = "Named", + DefaultValue = "None", + HasAllParameterSets = true, + ParameterSetNames = new [] { "(All)" }, + Aliases = new [] { "wi" } + } + }; + + public static MarkdownParameterHelpInfo[] SupportsPagingParameters = + { + new MarkdownParameterHelpInfo + { + Name = "First", + Description ="Gets only the first 'n' objects.", + Type = typeof(ulong), + Position = "Named", + DefaultValue = "None", + HasAllParameterSets = true, + ParameterSetNames = new [] { "(All)" }, + Aliases = new string[0] + }, + new MarkdownParameterHelpInfo + { + Name = "IncludeTotalCount", + Description ="Reports the number of objects in the data set (an integer) followed by the objects. If the cmdlet cannot determine the total count, it returns \"Unknown total count\".", + Type = typeof(SwitchParameter), + Position = "Named", + DefaultValue = "None", + HasAllParameterSets = true, + ParameterSetNames = new [] { "(All)" }, + Aliases = new string[0] + }, + new MarkdownParameterHelpInfo + { + Name = "Skip", + Description ="Ignores the first 'n' objects and then gets the remaining objects.", + Type = typeof(ulong), + Position = "Named", + DefaultValue = "None", + HasAllParameterSets = true, + ParameterSetNames = new [] { "(All)" }, + Aliases = new string[0] + } + }; + } +} diff --git a/src/CostManagement/generated/runtime/BuildTime/Models/PsProxyOutputs.cs b/src/CostManagement/generated/runtime/BuildTime/Models/PsProxyOutputs.cs new file mode 100644 index 000000000000..3ec52ed9f761 --- /dev/null +++ b/src/CostManagement/generated/runtime/BuildTime/Models/PsProxyOutputs.cs @@ -0,0 +1,513 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Management.Automation; +using System.Text; +using System.Text.RegularExpressions; +using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.PsProxyOutputExtensions; +using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.PsProxyTypeExtensions; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell +{ + internal class OutputTypeOutput + { + public PSTypeName[] OutputTypes { get; } + + public OutputTypeOutput(IEnumerable outputTypes) + { + OutputTypes = outputTypes.ToArray(); + } + + public override string ToString() => OutputTypes != null && OutputTypes.Any() ? $"[OutputType({OutputTypes.Select(ot => $"[{ot}]").JoinIgnoreEmpty(ItemSeparator)})]{Environment.NewLine}" : String.Empty; + } + + internal class CmdletBindingOutput + { + public VariantGroup VariantGroup { get; } + + public CmdletBindingOutput(VariantGroup variantGroup) + { + VariantGroup = variantGroup; + } + + public override string ToString() + { + var dpsText = VariantGroup.DefaultParameterSetName.IsValidDefaultParameterSetName() ? $"DefaultParameterSetName='{VariantGroup.DefaultParameterSetName}'" : String.Empty; + var sspText = VariantGroup.SupportsShouldProcess ? $"SupportsShouldProcess{ItemSeparator}ConfirmImpact='Medium'" : String.Empty; + var pbText = $"PositionalBinding={false.ToPsBool()}"; + var propertyText = new[] { dpsText, pbText, sspText }.JoinIgnoreEmpty(ItemSeparator); + return $"[CmdletBinding({propertyText})]{Environment.NewLine}"; + } + } + + internal class ParameterOutput + { + public Parameter Parameter { get; } + public bool HasMultipleVariantsInVariantGroup { get; } + public bool HasAllVariantsInParameterGroup { get; } + + public ParameterOutput(Parameter parameter, bool hasMultipleVariantsInVariantGroup, bool hasAllVariantsInParameterGroup) + { + Parameter = parameter; + HasMultipleVariantsInVariantGroup = hasMultipleVariantsInVariantGroup; + HasAllVariantsInParameterGroup = hasAllVariantsInParameterGroup; + } + + public override string ToString() + { + var psnText = HasMultipleVariantsInVariantGroup && !HasAllVariantsInParameterGroup ? $"ParameterSetName='{Parameter.VariantName}'" : String.Empty; + var positionText = Parameter.Position != null ? $"Position={Parameter.Position}" : String.Empty; + var mandatoryText = Parameter.IsMandatory ? "Mandatory" : String.Empty; + var dontShowText = Parameter.DontShow ? "DontShow" : String.Empty; + var vfpText = Parameter.ValueFromPipeline ? "ValueFromPipeline" : String.Empty; + var vfpbpnText = Parameter.ValueFromPipelineByPropertyName ? "ValueFromPipelineByPropertyName" : String.Empty; + var propertyText = new[] { psnText, positionText, mandatoryText, dontShowText, vfpText, vfpbpnText }.JoinIgnoreEmpty(ItemSeparator); + return $"{Indent}[Parameter({propertyText})]{Environment.NewLine}"; + } + } + + internal class AliasOutput + { + public string[] Aliases { get; } + public bool IncludeIndent { get; } + + public AliasOutput(string[] aliases, bool includeIndent = false) + { + Aliases = aliases; + IncludeIndent = includeIndent; + } + + public override string ToString() => Aliases?.Any() ?? false ? $"{(IncludeIndent ? Indent : String.Empty)}[Alias({Aliases.Select(an => $"'{an}'").JoinIgnoreEmpty(ItemSeparator)})]{Environment.NewLine}" : String.Empty; + } + + internal class ValidateNotNullOutput + { + public bool HasValidateNotNull { get; } + + public ValidateNotNullOutput(bool hasValidateNotNull) + { + HasValidateNotNull = hasValidateNotNull; + } + + public override string ToString() => HasValidateNotNull ? $"{Indent}[ValidateNotNull()]{Environment.NewLine}" : String.Empty; + } + + internal class ArgumentCompleterOutput + { + public CompleterInfo CompleterInfo { get; } + + public ArgumentCompleterOutput(CompleterInfo completerInfo) + { + CompleterInfo = completerInfo; + } + + public override string ToString() => CompleterInfo != null + ? $"{Indent}[ArgumentCompleter({(CompleterInfo.IsTypeCompleter ? $"[{CompleterInfo.Type.Unwrap().ToPsType()}]" : $"{{{CompleterInfo.Script.ToPsSingleLine("; ")}}}")})]{Environment.NewLine}" + : String.Empty; + } + + internal class DefaultInfoOutput + { + public bool HasDefaultInfo { get; } + public DefaultInfo DefaultInfo { get; } + + public DefaultInfoOutput(ParameterGroup parameterGroup) + { + HasDefaultInfo = parameterGroup.HasDefaultInfo; + DefaultInfo = parameterGroup.DefaultInfo; + } + + public override string ToString() + { + var nameText = !String.IsNullOrEmpty(DefaultInfo?.Name) ? $"Name='{DefaultInfo?.Name}'" : String.Empty; + var descriptionText = !String.IsNullOrEmpty(DefaultInfo?.Description) ? $"Description='{DefaultInfo?.Description.ToPsStringLiteral()}'" : String.Empty; + var scriptText = !String.IsNullOrEmpty(DefaultInfo?.Script) ? $"Script='{DefaultInfo?.Script.ToPsSingleLine("; ")}'" : String.Empty; + var propertyText = new[] { nameText, descriptionText, scriptText }.JoinIgnoreEmpty(ItemSeparator); + return HasDefaultInfo ? $"{Indent}[{typeof(DefaultInfoAttribute).ToPsAttributeType()}({propertyText})]{Environment.NewLine}" : String.Empty; + } + } + + internal class ParameterTypeOutput + { + public Type ParameterType { get; } + + public ParameterTypeOutput(Type parameterType) + { + ParameterType = parameterType; + } + + public override string ToString() => $"{Indent}[{ParameterType.ToPsType()}]{Environment.NewLine}"; + } + + internal class ParameterNameOutput + { + public string ParameterName { get; } + public bool IsLast { get; } + + public ParameterNameOutput(string parameterName, bool isLast) + { + ParameterName = parameterName; + IsLast = isLast; + } + + public override string ToString() => $"{Indent}${{{ParameterName}}}{(IsLast ? String.Empty : $",{Environment.NewLine}")}{Environment.NewLine}"; + } + + internal class BeginOutput + { + public VariantGroup VariantGroup { get; } + + public BeginOutput(VariantGroup variantGroup) + { + VariantGroup = variantGroup; + } + + public override string ToString() => $@"begin {{ +{Indent}try {{ +{Indent}{Indent}$outBuffer = $null +{Indent}{Indent}if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer)) {{ +{Indent}{Indent}{Indent}$PSBoundParameters['OutBuffer'] = 1 +{Indent}{Indent}}} +{Indent}{Indent}$parameterSet = $PSCmdlet.ParameterSetName +{GetParameterSetToCmdletMapping()}{GetDefaultValuesStatements()} +{Indent}{Indent}$wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet) +{Indent}{Indent}$scriptCmd = {{& $wrappedCmd @PSBoundParameters}} +{Indent}{Indent}$steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin) +{Indent}{Indent}$steppablePipeline.Begin($PSCmdlet) +{Indent}}} catch {{ +{Indent}{Indent}throw +{Indent}}} +}} + +"; + + private string GetParameterSetToCmdletMapping() + { + var sb = new StringBuilder(); + sb.AppendLine($"{Indent}{Indent}$mapping = @{{"); + foreach (var variant in VariantGroup.Variants) + { + sb.AppendLine($@"{Indent}{Indent}{Indent}{variant.VariantName} = '{variant.PrivateModuleName}\{variant.PrivateCmdletName}';"); + } + sb.Append($"{Indent}{Indent}}}"); + return sb.ToString(); + } + + private string GetDefaultValuesStatements() + { + var defaultInfos = VariantGroup.ParameterGroups.Where(pg => pg.HasDefaultInfo).Select(pg => pg.DefaultInfo).ToArray(); + var sb = new StringBuilder(); + + foreach (var defaultInfo in defaultInfos) + { + var variantListString = defaultInfo.ParameterGroup.VariantNames.ToPsList(); + var parameterName = defaultInfo.ParameterGroup.ParameterName; + sb.AppendLine(); + sb.AppendLine($"{Indent}{Indent}if (({variantListString}) -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('{parameterName}')) {{"); + sb.AppendLine($"{Indent}{Indent}{Indent}$PSBoundParameters['{parameterName}'] = {defaultInfo.Script}"); + sb.Append($"{Indent}{Indent}}}"); + } + return sb.ToString(); + } + } + + internal class ProcessOutput + { + public override string ToString() => $@"process {{ +{Indent}try {{ +{Indent}{Indent}$steppablePipeline.Process($_) +{Indent}}} catch {{ +{Indent}{Indent}throw +{Indent}}} +}} + +"; + } + + internal class EndOutput + { + public override string ToString() => $@"end {{ +{Indent}try {{ +{Indent}{Indent}$steppablePipeline.End() +{Indent}}} catch {{ +{Indent}{Indent}throw +{Indent}}} +}} +"; + } + + internal class HelpCommentOutput + { + public VariantGroup VariantGroup { get; } + public CommentInfo CommentInfo { get; } + + public HelpCommentOutput(VariantGroup variantGroup) + { + VariantGroup = variantGroup; + CommentInfo = variantGroup.CommentInfo; + } + + public override string ToString() + { + var inputs = String.Join(Environment.NewLine, CommentInfo.Inputs.Select(i => $".Inputs{Environment.NewLine}{i}")); + var inputsText = !String.IsNullOrEmpty(inputs) ? $"{Environment.NewLine}{inputs}" : String.Empty; + var outputs = String.Join(Environment.NewLine, CommentInfo.Outputs.Select(o => $".Outputs{Environment.NewLine}{o}")); + var outputsText = !String.IsNullOrEmpty(outputs) ? $"{Environment.NewLine}{outputs}" : String.Empty; + var notes = String.Join($"{Environment.NewLine}{Environment.NewLine}", VariantGroup.ComplexInterfaceInfos.Select(cii => cii.ToNoteOutput())); + var notesText = !String.IsNullOrEmpty(notes) ? $"{Environment.NewLine}.Notes{Environment.NewLine}{ComplexParameterHeader}{notes}" : String.Empty; + var relatedLinks = String.Join(Environment.NewLine, CommentInfo.RelatedLinks.Select(l => $".Link{Environment.NewLine}{l}")); + var relatedLinksText = !String.IsNullOrEmpty(relatedLinks) ? $"{Environment.NewLine}{relatedLinks}" : String.Empty; + var examples = ""; + foreach (var example in VariantGroup.HelpInfo.Examples) + { + examples = examples + ".Example" + "\r\n" + example.Code + "\r\n"; + } + return $@"<# +.Synopsis +{CommentInfo.Synopsis.ToDescriptionFormat(false)} +.Description +{CommentInfo.Description.ToDescriptionFormat(false)} +{examples}{inputsText}{outputsText}{notesText} +.Link +{CommentInfo.OnlineVersion}{relatedLinksText} +#> +"; + } + } + + internal class ParameterDescriptionOutput + { + public string Description { get; } + + public ParameterDescriptionOutput(string description) + { + Description = description; + } + + public override string ToString() => !String.IsNullOrEmpty(Description) + ? Description.ToDescriptionFormat(false).NormalizeNewLines() + .Split(new [] { Environment.NewLine }, StringSplitOptions.None) + .Aggregate(String.Empty, (c, n) => c + $"{Indent}# {n}{Environment.NewLine}") + : String.Empty; + } + + internal class ProfileOutput + { + public string ProfileName { get; } + + public ProfileOutput(string profileName) + { + ProfileName = profileName; + } + + public override string ToString() => ProfileName != NoProfiles ? $"[{typeof(ProfileAttribute).ToPsAttributeType()}('{ProfileName}')]{Environment.NewLine}" : String.Empty; + } + + internal class DescriptionOutput + { + public string Description { get; } + + public DescriptionOutput(string description) + { + Description = description; + } + + public override string ToString() => !String.IsNullOrEmpty(Description) ? $"[{typeof(DescriptionAttribute).ToPsAttributeType()}('{Description.ToPsStringLiteral()}')]{Environment.NewLine}" : String.Empty; + } + + internal class ParameterCategoryOutput + { + public ParameterCategory Category { get; } + + public ParameterCategoryOutput(ParameterCategory category) + { + Category = category; + } + + public override string ToString() => $"{Indent}[{typeof(CategoryAttribute).ToPsAttributeType()}('{Category}')]{Environment.NewLine}"; + } + + internal class InfoOutput + { + public InfoAttribute Info { get; } + public Type ParameterType { get; } + + public InfoOutput(InfoAttribute info, Type parameterType) + { + Info = info; + ParameterType = parameterType; + } + + public override string ToString() + { + // Rendering of InfoAttribute members that are not used currently + /*var serializedNameText = Info.SerializedName != null ? $"SerializedName='{Info.SerializedName}'" : String.Empty; + var readOnlyText = Info.ReadOnly ? "ReadOnly" : String.Empty; + var descriptionText = !String.IsNullOrEmpty(Info.Description) ? $"Description='{Info.Description.ToPsStringLiteral()}'" : String.Empty;*/ + + var requiredText = Info.Required ? "Required" : String.Empty; + var unwrappedType = ParameterType.Unwrap(); + var hasValidPossibleTypes = Info.PossibleTypes.Any(pt => pt != unwrappedType); + var possibleTypesText = hasValidPossibleTypes + ? $"PossibleTypes=({Info.PossibleTypes.Select(pt => $"[{pt.ToPsType()}]").JoinIgnoreEmpty(ItemSeparator)})" + : String.Empty; + var propertyText = new[] { /*serializedNameText, */requiredText,/* readOnlyText,*/ possibleTypesText/*, descriptionText*/ }.JoinIgnoreEmpty(ItemSeparator); + return hasValidPossibleTypes ? $"{Indent}[{typeof(InfoAttribute).ToPsAttributeType()}({propertyText})]{Environment.NewLine}" : String.Empty; + } + } + + internal class PropertySyntaxOutput + { + public string ParameterName { get; } + public Type ParameterType { get; } + public bool IsMandatory { get; } + public int? Position { get; } + + public bool IncludeSpace { get; } + public bool IncludeDash { get; } + + public PropertySyntaxOutput(Parameter parameter) + { + ParameterName = parameter.ParameterName; + ParameterType = parameter.ParameterType; + IsMandatory = parameter.IsMandatory; + Position = parameter.Position; + IncludeSpace = true; + IncludeDash = true; + } + + public PropertySyntaxOutput(ComplexInterfaceInfo complexInterfaceInfo) + { + ParameterName = complexInterfaceInfo.Name; + ParameterType = complexInterfaceInfo.Type; + IsMandatory = complexInterfaceInfo.Required; + Position = null; + IncludeSpace = false; + IncludeDash = false; + } + + public override string ToString() + { + var leftOptional = !IsMandatory ? "[" : String.Empty; + var leftPositional = Position != null ? "[" : String.Empty; + var rightPositional = Position != null ? "]" : String.Empty; + var type = ParameterType != typeof(SwitchParameter) ? $" <{ParameterType.ToSyntaxTypeName()}>" : String.Empty; + var rightOptional = !IsMandatory ? "]" : String.Empty; + var space = IncludeSpace ? " " : String.Empty; + var dash = IncludeDash ? "-" : String.Empty; + return $"{space}{leftOptional}{leftPositional}{dash}{ParameterName}{rightPositional}{type}{rightOptional}"; + } + } + + internal static class PsProxyOutputExtensions + { + public const string NoParameters = "__NoParameters"; + + public const string AllParameterSets = "__AllParameterSets"; + + public const string HalfIndent = " "; + + public const string Indent = HalfIndent + HalfIndent; + + public const string ItemSeparator = ", "; + + public static readonly string ComplexParameterHeader = $"COMPLEX PARAMETER PROPERTIES{Environment.NewLine}{Environment.NewLine}To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables.{Environment.NewLine}{Environment.NewLine}"; + + public static string ToPsBool(this bool value) => $"${value.ToString().ToLowerInvariant()}"; + + public static string ToPsType(this Type type) + { + var regex = new Regex(@"^(.*)`{1}\d+(.*)$"); + var typeText = type.ToString(); + var match = regex.Match(typeText); + return match.Success ? $"{match.Groups[1]}{match.Groups[2]}" : typeText; + } + + public static string ToPsAttributeType(this Type type) => type.ToPsType().RemoveEnd("Attribute"); + + // https://stackoverflow.com/a/5284606/294804 + private static string RemoveEnd(this string text, string suffix) => text.EndsWith(suffix) ? text.Substring(0, text.Length - suffix.Length) : text; + + public static string ToPsSingleLine(this string value, string replacer = " ") => value.ReplaceNewLines(replacer, new []{"
", "\r\n", "\n"}); + + public static string ToPsStringLiteral(this string value) => value?.Replace("'", "''").Replace("‘", "''").Replace("’", "''").ToPsSingleLine().Trim() ?? String.Empty; + + public static string JoinIgnoreEmpty(this IEnumerable values, string separator) => String.Join(separator, values?.Where(v => !String.IsNullOrEmpty(v))); + + // https://stackoverflow.com/a/41961738/294804 + public static string ToSyntaxTypeName(this Type type) + { + if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>)) + { + return $"{type.GetGenericArguments().First().ToSyntaxTypeName()}?"; + } + + if (type.IsGenericType) + { + var genericTypes = String.Join(ItemSeparator, type.GetGenericArguments().Select(ToSyntaxTypeName)); + return $"{type.Name.Split('`').First()}<{genericTypes}>"; + } + + return type.Name; + } + + public static OutputTypeOutput ToOutputTypeOutput(this IEnumerable outputTypes) => new OutputTypeOutput(outputTypes); + + public static CmdletBindingOutput ToCmdletBindingOutput(this VariantGroup variantGroup) => new CmdletBindingOutput(variantGroup); + + public static ParameterOutput ToParameterOutput(this Parameter parameter, bool hasMultipleVariantsInVariantGroup, bool hasAllVariantsInParameterGroup) => new ParameterOutput(parameter, hasMultipleVariantsInVariantGroup, hasAllVariantsInParameterGroup); + + public static AliasOutput ToAliasOutput(this string[] aliases, bool includeIndent = false) => new AliasOutput(aliases, includeIndent); + + public static ValidateNotNullOutput ToValidateNotNullOutput(this bool hasValidateNotNull) => new ValidateNotNullOutput(hasValidateNotNull); + + public static ArgumentCompleterOutput ToArgumentCompleterOutput(this CompleterInfo completerInfo) => new ArgumentCompleterOutput(completerInfo); + + public static DefaultInfoOutput ToDefaultInfoOutput(this ParameterGroup parameterGroup) => new DefaultInfoOutput(parameterGroup); + + public static ParameterTypeOutput ToParameterTypeOutput(this Type parameterType) => new ParameterTypeOutput(parameterType); + + public static ParameterNameOutput ToParameterNameOutput(this string parameterName, bool isLast) => new ParameterNameOutput(parameterName, isLast); + + public static BeginOutput ToBeginOutput(this VariantGroup variantGroup) => new BeginOutput(variantGroup); + + public static ProcessOutput ToProcessOutput(this VariantGroup variantGroup) => new ProcessOutput(); + + public static EndOutput ToEndOutput(this VariantGroup variantGroup) => new EndOutput(); + + public static HelpCommentOutput ToHelpCommentOutput(this VariantGroup variantGroup) => new HelpCommentOutput(variantGroup); + + public static ParameterDescriptionOutput ToParameterDescriptionOutput(this string description) => new ParameterDescriptionOutput(description); + + public static ProfileOutput ToProfileOutput(this string profileName) => new ProfileOutput(profileName); + + public static DescriptionOutput ToDescriptionOutput(this string description) => new DescriptionOutput(description); + + public static ParameterCategoryOutput ToParameterCategoryOutput(this ParameterCategory category) => new ParameterCategoryOutput(category); + + public static PropertySyntaxOutput ToPropertySyntaxOutput(this Parameter parameter) => new PropertySyntaxOutput(parameter); + + public static PropertySyntaxOutput ToPropertySyntaxOutput(this ComplexInterfaceInfo complexInterfaceInfo) => new PropertySyntaxOutput(complexInterfaceInfo); + + public static InfoOutput ToInfoOutput(this InfoAttribute info, Type parameterType) => new InfoOutput(info, parameterType); + + public static string ToNoteOutput(this ComplexInterfaceInfo complexInterfaceInfo, string currentIndent = "", bool includeDashes = false, bool includeBackticks = false, bool isFirst = true) + { + string RenderProperty(ComplexInterfaceInfo info, string indent, bool dash, bool backtick) => + $"{indent}{(dash ? "- " : String.Empty)}{(backtick ? "`" : String.Empty)}{info.ToPropertySyntaxOutput()}{(backtick ? "`" : String.Empty)}: {info.Description}"; + + var nested = complexInterfaceInfo.NestedInfos.Select(ni => + { + var nestedIndent = $"{currentIndent}{HalfIndent}"; + return ni.IsComplexInterface + ? ni.ToNoteOutput(nestedIndent, includeDashes, includeBackticks, false) + : RenderProperty(ni, nestedIndent, includeDashes, includeBackticks); + }).Prepend(RenderProperty(complexInterfaceInfo, currentIndent, !isFirst && includeDashes, !isFirst && includeBackticks)); + return String.Join(Environment.NewLine, nested); + } + } +} diff --git a/src/CostManagement/generated/runtime/BuildTime/Models/PsProxyTypes.cs b/src/CostManagement/generated/runtime/BuildTime/Models/PsProxyTypes.cs new file mode 100644 index 000000000000..e9b8c7890b34 --- /dev/null +++ b/src/CostManagement/generated/runtime/BuildTime/Models/PsProxyTypes.cs @@ -0,0 +1,499 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Management.Automation; +using System.Reflection; +using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.PsProxyOutputExtensions; +using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell.PsProxyTypeExtensions; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell +{ + internal class ProfileGroup + { + public string ProfileName { get; } + public Variant[] Variants { get; } + public string ProfileFolder { get; } + + public ProfileGroup(Variant[] variants, string profileName = NoProfiles) + { + ProfileName = profileName; + Variants = variants; + ProfileFolder = ProfileName != NoProfiles ? ProfileName : String.Empty; + } + } + + internal class VariantGroup + { + public string ModuleName { get; } + public string CmdletName { get; } + public string CmdletVerb { get; } + public string CmdletNoun { get; } + public string ProfileName { get; } + public Variant[] Variants { get; } + public ParameterGroup[] ParameterGroups { get; } + public ComplexInterfaceInfo[] ComplexInterfaceInfos { get; } + + public string[] Aliases { get; } + public PSTypeName[] OutputTypes { get; } + public bool SupportsShouldProcess { get; } + public bool SupportsPaging { get; } + public string DefaultParameterSetName { get; } + public bool HasMultipleVariants { get; } + public PsHelpInfo HelpInfo { get; } + public bool IsGenerated { get; } + public bool IsInternal { get; } + + public string OutputFolder { get; } + public string FileName { get; } + public string FilePath { get; } + + public CommentInfo CommentInfo { get; } + + public VariantGroup(string moduleName, string cmdletName, Variant[] variants, string outputFolder, string profileName = NoProfiles, bool isTest = false, bool isInternal = false) + { + ModuleName = moduleName; + CmdletName = cmdletName; + var cmdletNameParts = CmdletName.Split('-'); + CmdletVerb = cmdletNameParts.First(); + CmdletNoun = cmdletNameParts.Last(); + ProfileName = profileName; + Variants = variants; + ParameterGroups = Variants.ToParameterGroups().OrderBy(pg => pg.OrderCategory).ThenByDescending(pg => pg.IsMandatory).ToArray(); + var aliasDuplicates = ParameterGroups.SelectMany(pg => pg.Aliases) + //https://stackoverflow.com/a/18547390/294804 + .GroupBy(a => a).Where(g => g.Count() > 1).Select(g => g.Key).ToArray(); + if (aliasDuplicates.Any()) + { + throw new ParsingMetadataException($"The alias(es) [{String.Join(", ", aliasDuplicates)}] are defined on multiple parameters for cmdlet '{CmdletName}', which is not supported."); + } + ComplexInterfaceInfos = ParameterGroups.Where(pg => !pg.DontShow && pg.IsComplexInterface).OrderBy(pg => pg.ParameterName).Select(pg => pg.ComplexInterfaceInfo).ToArray(); + + Aliases = Variants.SelectMany(v => v.Attributes).ToAliasNames().ToArray(); + OutputTypes = Variants.SelectMany(v => v.Info.OutputType).Where(ot => ot.Type != null).GroupBy(ot => ot.Type).Select(otg => otg.First()).ToArray(); + SupportsShouldProcess = Variants.Any(v => v.SupportsShouldProcess); + SupportsPaging = Variants.Any(v => v.SupportsPaging); + DefaultParameterSetName = DetermineDefaultParameterSetName(); + HasMultipleVariants = Variants.Length > 1; + HelpInfo = Variants.Select(v => v.HelpInfo).FirstOrDefault() ?? new PsHelpInfo(); + IsGenerated = Variants.All(v => v.Attributes.OfType().Any()); + IsInternal = isInternal; + + OutputFolder = outputFolder; + FileName = $"{CmdletName}{(isTest ? ".Tests" : String.Empty)}.ps1"; + FilePath = Path.Combine(OutputFolder, FileName); + + CommentInfo = new CommentInfo(this); + } + + private string DetermineDefaultParameterSetName() + { + var defaultParameterSet = Variants + .Select(v => v.Metadata.DefaultParameterSetName) + .LastOrDefault(dpsn => dpsn.IsValidDefaultParameterSetName()); + + if (String.IsNullOrEmpty(defaultParameterSet)) + { + var variantParamCountGroups = Variants + .Select(v => ( + variant: v.VariantName, + paramCount: v.CmdletOnlyParameters.Count(p => p.IsMandatory), + isSimple: v.CmdletOnlyParameters.Where(p => p.IsMandatory).All(p => p.ParameterType.IsPsSimple()))) + .GroupBy(vpc => vpc.isSimple) + .ToArray(); + var variantParameterCounts = (variantParamCountGroups.Any(g => g.Key) ? variantParamCountGroups.Where(g => g.Key) : variantParamCountGroups).SelectMany(g => g).ToArray(); + var smallestParameterCount = variantParameterCounts.Min(vpc => vpc.paramCount); + defaultParameterSet = variantParameterCounts.First(vpc => vpc.paramCount == smallestParameterCount).variant; + } + + return defaultParameterSet; + } + } + + internal class Variant + { + public string CmdletName { get; } + public string VariantName { get; } + public CommandInfo Info { get; } + public CommandMetadata Metadata { get; } + public PsHelpInfo HelpInfo { get; } + public bool HasParameterSets { get; } + public bool IsFunction { get; } + public string PrivateModuleName { get; } + public string PrivateCmdletName { get; } + public bool SupportsShouldProcess { get; } + public bool SupportsPaging { get; } + + public Attribute[] Attributes { get; } + public Parameter[] Parameters { get; } + public Parameter[] CmdletOnlyParameters { get; } + public bool IsInternal { get; } + public bool IsDoNotExport { get; } + public string[] Profiles { get; } + + public Variant(string cmdletName, string variantName, CommandInfo info, CommandMetadata metadata, bool hasParameterSets = false, PsHelpInfo helpInfo = null) + { + CmdletName = cmdletName; + VariantName = variantName; + Info = info; + HelpInfo = helpInfo ?? new PsHelpInfo(); + Metadata = metadata; + HasParameterSets = hasParameterSets; + IsFunction = Info.CommandType == CommandTypes.Function; + PrivateModuleName = Info.Source; + PrivateCmdletName = Metadata.Name; + SupportsShouldProcess = Metadata.SupportsShouldProcess; + SupportsPaging = Metadata.SupportsPaging; + + Attributes = this.ToAttributes(); + Parameters = this.ToParameters().OrderBy(p => p.OrderCategory).ThenByDescending(p => p.IsMandatory).ToArray(); + IsInternal = Attributes.OfType().Any(); + IsDoNotExport = Attributes.OfType().Any(); + CmdletOnlyParameters = Parameters.Where(p => !p.Categories.Any(c => c == ParameterCategory.Azure || c == ParameterCategory.Runtime)).ToArray(); + Profiles = Attributes.OfType().SelectMany(pa => pa.Profiles).ToArray(); + } + } + + internal class ParameterGroup + { + public string ParameterName { get; } + public Parameter[] Parameters { get; } + + public string[] VariantNames { get; } + public string[] AllVariantNames { get; } + public bool HasAllVariants { get; } + public Type ParameterType { get; } + public string Description { get; } + + public string[] Aliases { get; } + public bool HasValidateNotNull { get; } + public CompleterInfo CompleterInfo { get; } + public DefaultInfo DefaultInfo { get; } + public bool HasDefaultInfo { get; } + public ParameterCategory OrderCategory { get; } + public bool DontShow { get; } + public bool IsMandatory { get; } + public bool SupportsWildcards { get; } + public bool IsComplexInterface { get; } + public ComplexInterfaceInfo ComplexInterfaceInfo { get; } + public InfoAttribute InfoAttribute { get; } + + public int? FirstPosition { get; } + public bool ValueFromPipeline { get; } + public bool ValueFromPipelineByPropertyName { get; } + public bool IsInputType { get; } + + public ParameterGroup(string parameterName, Parameter[] parameters, string[] allVariantNames) + { + ParameterName = parameterName; + Parameters = parameters; + + VariantNames = Parameters.Select(p => p.VariantName).ToArray(); + AllVariantNames = allVariantNames; + HasAllVariants = VariantNames.Any(vn => vn == AllParameterSets) || !AllVariantNames.Except(VariantNames).Any(); + var types = Parameters.Select(p => p.ParameterType).Distinct().ToArray(); + if (types.Length > 1) + { + throw new ParsingMetadataException($"The parameter '{ParameterName}' has multiple parameter types [{String.Join(", ", types.Select(t => t.Name))}] defined, which is not supported."); + } + ParameterType = types.First(); + Description = Parameters.Select(p => p.Description).FirstOrDefault(d => !String.IsNullOrEmpty(d)).EmptyIfNull(); + + Aliases = Parameters.SelectMany(p => p.Attributes).ToAliasNames().ToArray(); + HasValidateNotNull = Parameters.SelectMany(p => p.Attributes.OfType()).Any(); + CompleterInfo = Parameters.Select(p => p.CompleterInfoAttribute).FirstOrDefault()?.ToCompleterInfo() + ?? Parameters.Select(p => p.ArgumentCompleterAttribute).FirstOrDefault()?.ToCompleterInfo(); + DefaultInfo = Parameters.Select(p => p.DefaultInfoAttribute).FirstOrDefault()?.ToDefaultInfo(this) + ?? Parameters.Select(p => p.DefaultValueAttribute).FirstOrDefault(dv => dv != null)?.ToDefaultInfo(this); + HasDefaultInfo = DefaultInfo != null && !String.IsNullOrEmpty(DefaultInfo.Script); + // When DefaultInfo is present, force all parameters from this group to be optional. + if (HasDefaultInfo) + { + foreach (var parameter in Parameters) + { + parameter.IsMandatory = false; + } + } + OrderCategory = Parameters.Select(p => p.OrderCategory).Distinct().DefaultIfEmpty(ParameterCategory.Body).Min(); + DontShow = Parameters.All(p => p.DontShow); + IsMandatory = HasAllVariants && Parameters.Any(p => p.IsMandatory); + SupportsWildcards = Parameters.Any(p => p.SupportsWildcards); + IsComplexInterface = Parameters.Any(p => p.IsComplexInterface); + ComplexInterfaceInfo = Parameters.Where(p => p.IsComplexInterface).Select(p => p.ComplexInterfaceInfo).FirstOrDefault(); + InfoAttribute = Parameters.Select(p => p.InfoAttribute).First(); + + FirstPosition = Parameters.Select(p => p.Position).FirstOrDefault(p => p != null); + ValueFromPipeline = Parameters.Any(p => p.ValueFromPipeline); + ValueFromPipelineByPropertyName = Parameters.Any(p => p.ValueFromPipelineByPropertyName); + IsInputType = ValueFromPipeline || ValueFromPipelineByPropertyName; + } + } + + internal class Parameter + { + public string VariantName { get; } + public string ParameterName { get; } + public ParameterMetadata Metadata { get; } + public PsParameterHelpInfo HelpInfo { get; } + public Type ParameterType { get; } + + public Attribute[] Attributes { get; } + public ParameterCategory[] Categories { get; } + public ParameterCategory OrderCategory { get; } + public PSDefaultValueAttribute DefaultValueAttribute { get; } + public DefaultInfoAttribute DefaultInfoAttribute { get; } + public ParameterAttribute ParameterAttribute { get; } + public bool SupportsWildcards { get; } + public CompleterInfoAttribute CompleterInfoAttribute { get; } + public ArgumentCompleterAttribute ArgumentCompleterAttribute { get; } + + public bool ValueFromPipeline { get; } + public bool ValueFromPipelineByPropertyName { get; } + public int? Position { get; } + public bool DontShow { get; } + public bool IsMandatory { get; set; } + + public InfoAttribute InfoAttribute { get; } + public ComplexInterfaceInfo ComplexInterfaceInfo { get; } + public bool IsComplexInterface { get; } + public string Description { get; } + + public Parameter(string variantName, string parameterName, ParameterMetadata metadata, PsParameterHelpInfo helpInfo = null) + { + VariantName = variantName; + ParameterName = parameterName; + Metadata = metadata; + HelpInfo = helpInfo ?? new PsParameterHelpInfo(); + + Attributes = Metadata.Attributes.ToArray(); + ParameterType = Attributes.OfType().FirstOrDefault()?.Type ?? Metadata.ParameterType; + Categories = Attributes.OfType().SelectMany(ca => ca.Categories).Distinct().ToArray(); + OrderCategory = Categories.DefaultIfEmpty(ParameterCategory.Body).Min(); + DefaultValueAttribute = Attributes.OfType().FirstOrDefault(); + DefaultInfoAttribute = Attributes.OfType().FirstOrDefault(); + ParameterAttribute = Attributes.OfType().FirstOrDefault(pa => pa.ParameterSetName == VariantName || pa.ParameterSetName == AllParameterSets); + if (ParameterAttribute == null) + { + throw new ParsingMetadataException($"The variant '{VariantName}' has multiple parameter sets defined, which is not supported."); + } + SupportsWildcards = Attributes.OfType().Any(); + CompleterInfoAttribute = Attributes.OfType().FirstOrDefault(); + ArgumentCompleterAttribute = Attributes.OfType().FirstOrDefault(); + + ValueFromPipeline = ParameterAttribute.ValueFromPipeline; + ValueFromPipelineByPropertyName = ParameterAttribute.ValueFromPipelineByPropertyName; + Position = ParameterAttribute.Position == Int32.MinValue ? (int?)null : ParameterAttribute.Position; + DontShow = ParameterAttribute.DontShow; + IsMandatory = ParameterAttribute.Mandatory; + + var complexParameterName = ParameterName.ToUpperInvariant(); + var complexMessage = $"{Environment.NewLine}To construct, see NOTES section for {complexParameterName} properties and create a hash table."; + var description = ParameterAttribute.HelpMessage.NullIfEmpty() ?? HelpInfo.Description.NullIfEmpty() ?? InfoAttribute?.Description.NullIfEmpty() ?? String.Empty; + // Remove the complex type message as it will be reinserted if this is a complex type + description = description.NormalizeNewLines().Replace(complexMessage, String.Empty).Replace(complexMessage.ToPsSingleLine(), String.Empty); + // Make an InfoAttribute for processing only if one isn't provided + InfoAttribute = Attributes.OfType().FirstOrDefault() ?? new InfoAttribute { PossibleTypes = new[] { ParameterType.Unwrap() }, Required = IsMandatory }; + // Set the description if the InfoAttribute does not have one since they are exported without a description + InfoAttribute.Description = String.IsNullOrEmpty(InfoAttribute.Description) ? description : InfoAttribute.Description; + ComplexInterfaceInfo = InfoAttribute.ToComplexInterfaceInfo(complexParameterName, ParameterType, true); + IsComplexInterface = ComplexInterfaceInfo.IsComplexInterface; + Description = $"{description}{(IsComplexInterface ? complexMessage : String.Empty)}"; + } + } + + internal class ComplexInterfaceInfo + { + public InfoAttribute InfoAttribute { get; } + + public string Name { get; } + public Type Type { get; } + public bool Required { get; } + public bool ReadOnly { get; } + public string Description { get; } + + public ComplexInterfaceInfo[] NestedInfos { get; } + public bool IsComplexInterface { get; } + + public ComplexInterfaceInfo(string name, Type type, InfoAttribute infoAttribute, bool? required, List seenTypes) + { + Name = name; + Type = type; + InfoAttribute = infoAttribute; + + Required = required ?? InfoAttribute.Required; + ReadOnly = InfoAttribute.ReadOnly; + Description = InfoAttribute.Description.ToPsSingleLine(); + + var unwrappedType = Type.Unwrap(); + var hasBeenSeen = seenTypes?.Contains(unwrappedType) ?? false; + (seenTypes ?? (seenTypes = new List())).Add(unwrappedType); + NestedInfos = hasBeenSeen ? new ComplexInterfaceInfo[]{} : + unwrappedType.GetInterfaces() + .Concat(InfoAttribute.PossibleTypes) + .SelectMany(pt => pt.GetProperties() + .SelectMany(pi => pi.GetCustomAttributes(true).OfType() + .Select(ia => ia.ToComplexInterfaceInfo(pi.Name, pi.PropertyType, seenTypes: seenTypes)))) + .Where(cii => !cii.ReadOnly).OrderByDescending(cii => cii.Required).ToArray(); + // https://stackoverflow.com/a/503359/294804 + var associativeArrayInnerType = Type.GetInterfaces() + .FirstOrDefault(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IAssociativeArray<>)) + ?.GetTypeInfo().GetGenericArguments().First(); + if (!hasBeenSeen && associativeArrayInnerType != null) + { + var anyInfo = new InfoAttribute { Description = "This indicates any property can be added to this object." }; + NestedInfos = NestedInfos.Prepend(anyInfo.ToComplexInterfaceInfo("(Any)", associativeArrayInnerType)).ToArray(); + } + IsComplexInterface = NestedInfos.Any(); + } + } + + internal class CommentInfo + { + public string Description { get; } + public string Synopsis { get; } + + public string[] Examples { get; } + public string[] Inputs { get; } + public string[] Outputs { get; } + + public string OnlineVersion { get; } + public string[] RelatedLinks { get; } + + private const string HelpLinkPrefix = @"https://docs.microsoft.com/en-us/powershell/module/"; + + public CommentInfo(VariantGroup variantGroup) + { + var helpInfo = variantGroup.HelpInfo; + Description = variantGroup.Variants.SelectMany(v => v.Attributes).OfType().FirstOrDefault()?.Description.NullIfEmpty() + ?? helpInfo.Description.EmptyIfNull(); + // If there is no Synopsis, PowerShell may put in the Syntax string as the Synopsis. This seems unintended, so we remove the Synopsis in this situation. + var synopsis = helpInfo.Synopsis.EmptyIfNull().Trim().StartsWith(variantGroup.CmdletName) ? String.Empty : helpInfo.Synopsis; + Synopsis = synopsis.NullIfEmpty() ?? Description; + + Examples = helpInfo.Examples.Select(rl => rl.Code).ToArray(); + + Inputs = (variantGroup.ParameterGroups.Where(pg => pg.IsInputType).Select(pg => pg.ParameterType.FullName).ToArray().NullIfEmpty() ?? + helpInfo.InputTypes.Where(it => it.Name.NullIfWhiteSpace() != null).Select(it => it.Name).ToArray()) + .Where(i => i != "None").Distinct().OrderBy(i => i).ToArray(); + Outputs = (variantGroup.OutputTypes.Select(ot => ot.Type.FullName).ToArray().NullIfEmpty() ?? + helpInfo.OutputTypes.Where(it => it.Name.NullIfWhiteSpace() != null).Select(ot => ot.Name).ToArray()) + .Where(o => o != "None").Distinct().OrderBy(o => o).ToArray(); + + OnlineVersion = helpInfo.OnlineVersion?.Uri.NullIfEmpty() ?? $@"{HelpLinkPrefix}{variantGroup.ModuleName.ToLowerInvariant()}/{variantGroup.CmdletName.ToLowerInvariant()}"; + RelatedLinks = helpInfo.RelatedLinks.Select(rl => rl.Text).ToArray(); + } + } + + internal class CompleterInfo + { + public string Name { get; } + public string Description { get; } + public string Script { get; } + public Type Type { get; } + public bool IsTypeCompleter { get; } + + public CompleterInfo(CompleterInfoAttribute infoAttribute) + { + Name = infoAttribute.Name; + Description = infoAttribute.Description; + Script = infoAttribute.Script; + } + + public CompleterInfo(ArgumentCompleterAttribute completerAttribute) + { + Script = completerAttribute.ScriptBlock?.ToString(); + if (completerAttribute.Type != null) + { + Type = completerAttribute.Type; + IsTypeCompleter = true; + } + } + } + + internal class DefaultInfo + { + public string Name { get; } + public string Description { get; } + public string Script { get; } + public ParameterGroup ParameterGroup { get; } + + public DefaultInfo(DefaultInfoAttribute infoAttribute, ParameterGroup parameterGroup) + { + Name = infoAttribute.Name; + Description = infoAttribute.Description; + Script = infoAttribute.Script; + ParameterGroup = parameterGroup; + } + + public DefaultInfo(PSDefaultValueAttribute defaultValueAttribute, ParameterGroup parameterGroup) + { + Description = defaultValueAttribute.Help; + ParameterGroup = parameterGroup; + if (defaultValueAttribute.Value != null) + { + Script = defaultValueAttribute.Value.ToString(); + } + } + } + + internal static class PsProxyTypeExtensions + { + public const string NoProfiles = "__NoProfiles"; + + public static bool IsValidDefaultParameterSetName(this string parameterSetName) => + !String.IsNullOrEmpty(parameterSetName) && parameterSetName != AllParameterSets; + + public static Variant[] ToVariants(this CommandInfo info, PsHelpInfo helpInfo) + { + var metadata = new CommandMetadata(info); + var privateCmdletName = metadata.Name.Split('!').First(); + var parts = privateCmdletName.Split('_'); + return parts.Length > 1 + ? new[] { new Variant(parts[0], parts[1], info, metadata, helpInfo: helpInfo) } + // Process multiple parameter sets, so we declare a variant per parameter set. + : info.ParameterSets.Select(ps => new Variant(privateCmdletName, ps.Name, info, metadata, true, helpInfo)).ToArray(); + } + + public static Variant[] ToVariants(this CmdletAndHelpInfo info) => info.CommandInfo.ToVariants(info.HelpInfo); + + public static Variant[] ToVariants(this CommandInfo info, PSObject helpInfo = null) => info.ToVariants(helpInfo?.ToPsHelpInfo()); + + public static Parameter[] ToParameters(this Variant variant) + { + var parameters = variant.Metadata.Parameters.AsEnumerable(); + var parameterHelp = variant.HelpInfo.Parameters.AsEnumerable(); + if (variant.HasParameterSets) + { + parameters = parameters.Where(p => p.Value.ParameterSets.Keys.Any(k => k == variant.VariantName || k == AllParameterSets)); + parameterHelp = parameterHelp.Where(ph => !ph.ParameterSetNames.Any() || ph.ParameterSetNames.Any(psn => psn == variant.VariantName || psn == AllParameterSets)); + } + return parameters.Select(p => new Parameter(variant.VariantName, p.Key, p.Value, parameterHelp.FirstOrDefault(ph => ph.Name == p.Key))).ToArray(); + } + + public static Attribute[] ToAttributes(this Variant variant) => variant.IsFunction + ? ((FunctionInfo)variant.Info).ScriptBlock.Attributes.ToArray() + : variant.Metadata.CommandType.GetCustomAttributes(false).Cast().ToArray(); + + public static IEnumerable ToParameterGroups(this Variant[] variants) + { + var allVariantNames = variants.Select(vg => vg.VariantName).ToArray(); + return variants + .SelectMany(v => v.Parameters) + .GroupBy(p => p.ParameterName, StringComparer.InvariantCultureIgnoreCase) + .Select(pg => new ParameterGroup(pg.Key, pg.Select(p => p).ToArray(), allVariantNames)); + } + + public static ComplexInterfaceInfo ToComplexInterfaceInfo(this InfoAttribute infoAttribute, string name, Type type, bool? required = null, List seenTypes = null) + => new ComplexInterfaceInfo(name, type, infoAttribute, required, seenTypes); + + public static CompleterInfo ToCompleterInfo(this CompleterInfoAttribute infoAttribute) => new CompleterInfo(infoAttribute); + public static CompleterInfo ToCompleterInfo(this ArgumentCompleterAttribute completerAttribute) => new CompleterInfo(completerAttribute); + + public static DefaultInfo ToDefaultInfo(this DefaultInfoAttribute infoAttribute, ParameterGroup parameterGroup) => new DefaultInfo(infoAttribute, parameterGroup); + public static DefaultInfo ToDefaultInfo(this PSDefaultValueAttribute defaultValueAttribute, ParameterGroup parameterGroup) => new DefaultInfo(defaultValueAttribute, parameterGroup); + } +} diff --git a/src/CostManagement/generated/runtime/BuildTime/PsAttributes.cs b/src/CostManagement/generated/runtime/BuildTime/PsAttributes.cs new file mode 100644 index 000000000000..892c3cb828ba --- /dev/null +++ b/src/CostManagement/generated/runtime/BuildTime/PsAttributes.cs @@ -0,0 +1,114 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement +{ + [AttributeUsage(AttributeTargets.Class)] + public class DescriptionAttribute : Attribute + { + public string Description { get; } + + public DescriptionAttribute(string description) + { + Description = description; + } + } + + [AttributeUsage(AttributeTargets.Class)] + public class DoNotExportAttribute : Attribute + { + } + + [AttributeUsage(AttributeTargets.Class)] + public class InternalExportAttribute : Attribute + { + } + + [AttributeUsage(AttributeTargets.Class)] + public class GeneratedAttribute : Attribute + { + } + + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property)] + public class DoNotFormatAttribute : Attribute + { + } + + [AttributeUsage(AttributeTargets.Class)] + public class ProfileAttribute : Attribute + { + public string[] Profiles { get; } + + public ProfileAttribute(params string[] profiles) + { + Profiles = profiles; + } + } + + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] + public class CategoryAttribute : Attribute + { + public ParameterCategory[] Categories { get; } + + public CategoryAttribute(params ParameterCategory[] categories) + { + Categories = categories; + } + } + + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] + public class ExportAsAttribute : Attribute + { + public Type Type { get; set; } + + public ExportAsAttribute(Type type) + { + Type = type; + } + } + + public enum ParameterCategory + { + // Note: Order is significant + Uri = 0, + Path, + Query, + Header, + Cookie, + Body, + Azure, + Runtime + } + + [AttributeUsage(AttributeTargets.Property)] + public class OriginAttribute : Attribute + { + public PropertyOrigin Origin { get; } + + public OriginAttribute(PropertyOrigin origin) + { + Origin = origin; + } + } + + public enum PropertyOrigin + { + // Note: Order is significant + Inherited = 0, + Owned, + Inlined + } + + [AttributeUsage(AttributeTargets.Property)] + public class FormatTableAttribute : Attribute + { + public int Index { get; set; } = -1; + public bool HasIndex => Index != -1; + public string Label { get; set; } + public int Width { get; set; } = -1; + public bool HasWidth => Width != -1; + } +} diff --git a/src/CostManagement/generated/runtime/BuildTime/PsExtensions.cs b/src/CostManagement/generated/runtime/BuildTime/PsExtensions.cs new file mode 100644 index 000000000000..73998bdf988e --- /dev/null +++ b/src/CostManagement/generated/runtime/BuildTime/PsExtensions.cs @@ -0,0 +1,160 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Management.Automation; +using System.Reflection; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell +{ + internal static class PsExtensions + { + // https://stackoverflow.com/a/863944/294804 + // https://stackoverflow.com/a/4452598/294804 + // https://stackoverflow.com/a/28701974/294804 + // Note: This will unwrap nested collections, but we don't generate nested collections. + public static Type Unwrap(this Type type) + { + if (type.IsArray) + { + return type.GetElementType().Unwrap(); + } + + var typeInfo = type.GetTypeInfo(); + if (typeInfo.IsGenericType + && (typeInfo.GetGenericTypeDefinition() == typeof(Nullable<>) || typeof(IEnumerable<>).IsAssignableFrom(type))) + { + return typeInfo.GetGenericArguments().First().Unwrap(); + } + + return type; + } + + // https://stackoverflow.com/a/863944/294804 + private static bool IsSimple(this Type type) + { + var typeInfo = type.GetTypeInfo(); + return typeInfo.IsPrimitive + || typeInfo.IsEnum + || type == typeof(string) + || type == typeof(decimal); + } + + // https://stackoverflow.com/a/32025393/294804 + private static bool HasImplicitConversion(this Type baseType, Type targetType) => + baseType.GetMethods(BindingFlags.Public | BindingFlags.Static) + .Where(mi => mi.Name == "op_Implicit" && mi.ReturnType == targetType) + .Any(mi => mi.GetParameters().FirstOrDefault()?.ParameterType == baseType); + + public static bool IsPsSimple(this Type type) + { + var unwrappedType = type.Unwrap(); + return unwrappedType.IsSimple() + || unwrappedType == typeof(SwitchParameter) + || unwrappedType == typeof(Hashtable) + || unwrappedType == typeof(PSCredential) + || unwrappedType == typeof(ScriptBlock) + || unwrappedType == typeof(DateTime) + || unwrappedType == typeof(Uri) + || unwrappedType.HasImplicitConversion(typeof(string)); + } + + public static string ToPsList(this IEnumerable items) => String.Join(", ", items.Select(i => $"'{i}'")); + + public static IEnumerable ToAliasNames(this IEnumerable attributes) => attributes.OfType().SelectMany(aa => aa.AliasNames).Distinct(); + + public static bool IsArrayAndElementTypeIsT(this object item) + { + var itemType = item.GetType(); + var tType = typeof(T); + return itemType.IsArray && !tType.IsArray && tType.IsAssignableFrom(itemType.GetElementType()); + } + + public static bool IsTArrayAndElementTypeIsItem(this object item) + { + var itemType = item.GetType(); + var tType = typeof(T); + return !itemType.IsArray && tType.IsArray && (tType.GetElementType()?.IsAssignableFrom(itemType) ?? false); + } + + public static bool IsTypeOrArrayOfType(this object item) => item is T || item.IsArrayAndElementTypeIsT() || item.IsTArrayAndElementTypeIsItem(); + + public static T NormalizeArrayType(this object item) + { + if (item is T result) + { + return result; + } + + if (item.IsArrayAndElementTypeIsT()) + { + var array = (T[])Convert.ChangeType(item, typeof(T[])); + return array.FirstOrDefault(); + } + + if (item.IsTArrayAndElementTypeIsItem()) + { + var tType = typeof(T); + var array = Array.CreateInstance(tType.GetElementType(), 1); + array.SetValue(item, 0); + return (T)Convert.ChangeType(array, tType); + } + + return default(T); + } + + public static T GetNestedProperty(this PSObject psObject, params string[] names) => psObject.Properties.GetNestedProperty(names); + + public static T GetNestedProperty(this PSMemberInfoCollection properties, params string[] names) + { + var lastName = names.Last(); + var nestedProperties = names.Take(names.Length - 1).Aggregate(properties, (p, n) => p?.GetProperty(n)?.Properties); + return nestedProperties != null ? nestedProperties.GetProperty(lastName) : default(T); + } + + public static T GetProperty(this PSObject psObject, string name) => psObject.Properties.GetProperty(name); + + public static T GetProperty(this PSMemberInfoCollection properties, string name) + { + switch (properties[name]?.Value) + { + case PSObject psObject when psObject.BaseObject is PSCustomObject && psObject.ImmediateBaseObject.IsTypeOrArrayOfType(): + return psObject.ImmediateBaseObject.NormalizeArrayType(); + case PSObject psObject when psObject.BaseObject.IsTypeOrArrayOfType(): + return psObject.BaseObject.NormalizeArrayType(); + case object value when value.IsTypeOrArrayOfType(): + return value.NormalizeArrayType(); + default: + return default(T); + } + } + + public static IEnumerable RunScript(this PSCmdlet cmdlet, string script) + => PsHelpers.RunScript(cmdlet.InvokeCommand, script); + + public static void RunScript(this PSCmdlet cmdlet, string script) + => cmdlet.RunScript(script); + + public static IEnumerable RunScript(this EngineIntrinsics engineIntrinsics, string script) + => PsHelpers.RunScript(engineIntrinsics.InvokeCommand, script); + + public static void RunScript(this EngineIntrinsics engineIntrinsics, string script) + => engineIntrinsics.RunScript(script); + + public static IEnumerable RunScript(this PSCmdlet cmdlet, ScriptBlock block) + => PsHelpers.RunScript(cmdlet.InvokeCommand, block.ToString()); + + public static void RunScript(this PSCmdlet cmdlet, ScriptBlock block) + => cmdlet.RunScript(block.ToString()); + + public static IEnumerable RunScript(this EngineIntrinsics engineIntrinsics, ScriptBlock block) + => PsHelpers.RunScript(engineIntrinsics.InvokeCommand, block.ToString()); + + public static void RunScript(this EngineIntrinsics engineIntrinsics, ScriptBlock block) + => engineIntrinsics.RunScript(block.ToString()); + } +} diff --git a/src/CostManagement/generated/runtime/BuildTime/PsHelpers.cs b/src/CostManagement/generated/runtime/BuildTime/PsHelpers.cs new file mode 100644 index 000000000000..1346743e9777 --- /dev/null +++ b/src/CostManagement/generated/runtime/BuildTime/PsHelpers.cs @@ -0,0 +1,104 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; +using System.Collections; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Management.Automation; +using Pwsh = System.Management.Automation.PowerShell; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell +{ + internal static class PsHelpers + { + public static IEnumerable RunScript(string script) + => Pwsh.Create().AddScript(script).Invoke(); + + public static void RunScript(string script) + => RunScript(script); + + public static IEnumerable RunScript(CommandInvocationIntrinsics cii, string script) + => cii.InvokeScript(script).Select(o => o?.BaseObject).Where(o => o != null).OfType(); + + public static void RunScript(CommandInvocationIntrinsics cii, string script) + => RunScript(cii, script); + + public static IEnumerable GetModuleCmdlets(PSCmdlet cmdlet, params string[] modulePaths) + { + var getCmdletsCommand = String.Join(" + ", modulePaths.Select(mp => $"(Get-Command -Module (Import-Module '{mp}' -PassThru))")); + return (cmdlet?.RunScript(getCmdletsCommand) ?? RunScript(getCmdletsCommand)) + .Where(ci => ci.CommandType != CommandTypes.Alias); + } + + public static IEnumerable GetModuleCmdlets(params string[] modulePaths) + => GetModuleCmdlets(null, modulePaths); + + public static IEnumerable GetScriptCmdlets(PSCmdlet cmdlet, string scriptFolder) + { + // https://stackoverflow.com/a/40969712/294804 + var getCmdletsCommand = $@" +$currentFunctions = Get-ChildItem function: +Get-ChildItem -Path '{scriptFolder}' -Recurse -Include '*.ps1' -File | ForEach-Object {{ . $_.FullName }} +Get-ChildItem function: | Where-Object {{ ($currentFunctions -notcontains $_) -and $_.CmdletBinding }} +"; + return cmdlet?.RunScript(getCmdletsCommand) ?? RunScript(getCmdletsCommand); + } + + public static IEnumerable GetScriptCmdlets(string scriptFolder) + => GetScriptCmdlets(null, scriptFolder); + + public static IEnumerable GetScriptHelpInfo(PSCmdlet cmdlet, params string[] modulePaths) + { + var importModules = String.Join(Environment.NewLine, modulePaths.Select(mp => $"Import-Module '{mp}'")); + var getHelpCommand = $@" +$currentFunctions = Get-ChildItem function: +{importModules} +Get-ChildItem function: | Where-Object {{ ($currentFunctions -notcontains $_) -and $_.CmdletBinding }} | ForEach-Object {{ Get-Help -Name $_.Name -Full }} +"; + return cmdlet?.RunScript(getHelpCommand) ?? RunScript(getHelpCommand); + } + + public static IEnumerable GetScriptHelpInfo(params string[] modulePaths) + => GetScriptHelpInfo(null, modulePaths); + + public static IEnumerable GetModuleCmdletsAndHelpInfo(PSCmdlet cmdlet, params string[] modulePaths) + { + var getCmdletAndHelp = String.Join(" + ", modulePaths.Select(mp => + $@"(Get-Command -Module (Import-Module '{mp}' -PassThru) | Where-Object {{ $_.CommandType -ne 'Alias' }} | ForEach-Object {{ @{{ CommandInfo = $_; HelpInfo = ( invoke-command {{ try {{ Get-Help -Name $_.Name -Full }} catch{{ '' }} }} ) }} }})" + )); + return (cmdlet?.RunScript(getCmdletAndHelp) ?? RunScript(getCmdletAndHelp)) + .Select(h => new CmdletAndHelpInfo { CommandInfo = (h["CommandInfo"] as PSObject)?.BaseObject as CommandInfo, HelpInfo = h["HelpInfo"] as PSObject }); + } + + public static IEnumerable GetModuleCmdletsAndHelpInfo(params string[] modulePaths) + => GetModuleCmdletsAndHelpInfo(null, modulePaths); + + public static CmdletAndHelpInfo ToCmdletAndHelpInfo(this CommandInfo commandInfo, PSObject helpInfo) => new CmdletAndHelpInfo { CommandInfo = commandInfo, HelpInfo = helpInfo }; + + public const string Psd1Indent = " "; + public const string GuidStart = Psd1Indent + "GUID"; + + public static Guid ReadGuidFromPsd1(string psd1Path) + { + var guid = Guid.NewGuid(); + if (File.Exists(psd1Path)) + { + var currentGuid = File.ReadAllLines(psd1Path) + .FirstOrDefault(l => l.StartsWith(GuidStart))?.Split(new[] { " = " }, StringSplitOptions.RemoveEmptyEntries) + .LastOrDefault()?.Replace("'", String.Empty); + guid = currentGuid != null ? Guid.Parse(currentGuid) : guid; + } + + return guid; + } + } + + internal class CmdletAndHelpInfo + { + public CommandInfo CommandInfo { get; set; } + public PSObject HelpInfo { get; set; } + } +} diff --git a/src/CostManagement/generated/runtime/BuildTime/StringExtensions.cs b/src/CostManagement/generated/runtime/BuildTime/StringExtensions.cs new file mode 100644 index 000000000000..f34ebfa8fe73 --- /dev/null +++ b/src/CostManagement/generated/runtime/BuildTime/StringExtensions.cs @@ -0,0 +1,24 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; +using System.Linq; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell +{ + internal static class StringExtensions + { + public static string NullIfEmpty(this string text) => String.IsNullOrEmpty(text) ? null : text; + public static string NullIfWhiteSpace(this string text) => String.IsNullOrWhiteSpace(text) ? null : text; + public static string EmptyIfNull(this string text) => text ?? String.Empty; + + public static bool? ToNullableBool(this string text) => String.IsNullOrEmpty(text) ? (bool?)null : Convert.ToBoolean(text.ToLowerInvariant()); + + public static string ToUpperFirstCharacter(this string text) => String.IsNullOrEmpty(text) ? text : $"{text[0].ToString().ToUpperInvariant()}{text.Remove(0, 1)}"; + + public static string ReplaceNewLines(this string value, string replacer = " ", string[] newLineSymbols = null) + => (newLineSymbols ?? new []{ "\r\n", "\n" }).Aggregate(value.EmptyIfNull(), (current, symbol) => current.Replace(symbol, replacer)); + public static string NormalizeNewLines(this string value) => value.ReplaceNewLines("\u00A0").Replace("\u00A0", Environment.NewLine); + } +} diff --git a/src/CostManagement/generated/runtime/BuildTime/XmlExtensions.cs b/src/CostManagement/generated/runtime/BuildTime/XmlExtensions.cs new file mode 100644 index 000000000000..fa20a253c594 --- /dev/null +++ b/src/CostManagement/generated/runtime/BuildTime/XmlExtensions.cs @@ -0,0 +1,28 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System.IO; +using System.Xml; +using System.Xml.Serialization; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell +{ + internal static class XmlExtensions + { + public static string ToXmlString(this T inputObject, bool excludeDeclaration = false) + { + var serializer = new XmlSerializer(typeof(T)); + //https://stackoverflow.com/a/760290/294804 + //https://stackoverflow.com/a/3732234/294804 + var namespaces = new XmlSerializerNamespaces(new[] { XmlQualifiedName.Empty }); + var xmlSettings = new XmlWriterSettings { OmitXmlDeclaration = excludeDeclaration, Indent = true }; + using (var stringWriter = new StringWriter()) + using (var xmlWriter = XmlWriter.Create(stringWriter, xmlSettings)) + { + serializer.Serialize(xmlWriter, inputObject, namespaces); + return stringWriter.ToString(); + } + } + } +} diff --git a/src/CostManagement/generated/runtime/CmdInfoHandler.cs b/src/CostManagement/generated/runtime/CmdInfoHandler.cs new file mode 100644 index 000000000000..e325aec5baea --- /dev/null +++ b/src/CostManagement/generated/runtime/CmdInfoHandler.cs @@ -0,0 +1,40 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; +using System.Management.Automation; +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime +{ + using NextDelegate = Func, Task>, Task>; + using SignalDelegate = Func, Task>; + + public class CmdInfoHandler + { + private readonly string processRecordId; + private readonly string parameterSetName; + private readonly InvocationInfo invocationInfo; + + public CmdInfoHandler(string processRecordId, InvocationInfo invocationInfo, string parameterSetName) + { + this.processRecordId = processRecordId; + this.parameterSetName = parameterSetName; + this.invocationInfo = invocationInfo; + } + + public Task SendAsync(HttpRequestMessage request, CancellationToken token, Action cancel, SignalDelegate signal, NextDelegate next) + { + request.Headers.Add("x-ms-client-request-id", processRecordId); + request.Headers.Add("CommandName", invocationInfo?.InvocationName); + request.Headers.Add("FullCommandName", invocationInfo?.MyCommand?.Name); + request.Headers.Add("ParameterSetName", parameterSetName); + + // continue with pipeline. + return next(request, token, cancel, signal); + } + } +} diff --git a/src/CostManagement/generated/runtime/Conversions/ConversionException.cs b/src/CostManagement/generated/runtime/Conversions/ConversionException.cs new file mode 100644 index 000000000000..c6b1ea23b5c5 --- /dev/null +++ b/src/CostManagement/generated/runtime/Conversions/ConversionException.cs @@ -0,0 +1,17 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + internal class ConversionException : Exception + { + internal ConversionException(string message) + : base(message) { } + + internal ConversionException(JsonNode node, Type targetType) + : base($"Cannot convert '{node.Type}' to a {targetType.Name}") { } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Conversions/IJsonConverter.cs b/src/CostManagement/generated/runtime/Conversions/IJsonConverter.cs new file mode 100644 index 000000000000..84e970cd96b2 --- /dev/null +++ b/src/CostManagement/generated/runtime/Conversions/IJsonConverter.cs @@ -0,0 +1,13 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + internal interface IJsonConverter + { + JsonNode ToJson(object value); + + object FromJson(JsonNode node); + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Conversions/Instances/BinaryConverter.cs b/src/CostManagement/generated/runtime/Conversions/Instances/BinaryConverter.cs new file mode 100644 index 000000000000..5a945f1e95f2 --- /dev/null +++ b/src/CostManagement/generated/runtime/Conversions/Instances/BinaryConverter.cs @@ -0,0 +1,24 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + public sealed class BinaryConverter : JsonConverter + { + internal override JsonNode ToJson(byte[] value) => new XBinary(value); + + internal override byte[] FromJson(JsonNode node) + { + switch (node.Type) + { + case JsonType.String : return Convert.FromBase64String(node.ToString()); // Base64 Encoded + case JsonType.Binary : return ((XBinary)node).Value; + } + + throw new ConversionException(node, typeof(byte[])); + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Conversions/Instances/BooleanConverter.cs b/src/CostManagement/generated/runtime/Conversions/Instances/BooleanConverter.cs new file mode 100644 index 000000000000..9e8807ba4293 --- /dev/null +++ b/src/CostManagement/generated/runtime/Conversions/Instances/BooleanConverter.cs @@ -0,0 +1,13 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + public sealed class BooleanConverter : JsonConverter + { + internal override JsonNode ToJson(bool value) => new JsonBoolean(value); + + internal override bool FromJson(JsonNode node) => (bool)node; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Conversions/Instances/DateTimeConverter.cs b/src/CostManagement/generated/runtime/Conversions/Instances/DateTimeConverter.cs new file mode 100644 index 000000000000..2a5c22d3d284 --- /dev/null +++ b/src/CostManagement/generated/runtime/Conversions/Instances/DateTimeConverter.cs @@ -0,0 +1,18 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + public sealed class DateTimeConverter : JsonConverter + { + internal override JsonNode ToJson(DateTime value) + { + return new JsonDate(value); + } + + internal override DateTime FromJson(JsonNode node) => (DateTime)node; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Conversions/Instances/DateTimeOffsetConverter.cs b/src/CostManagement/generated/runtime/Conversions/Instances/DateTimeOffsetConverter.cs new file mode 100644 index 000000000000..d9b0b47965fd --- /dev/null +++ b/src/CostManagement/generated/runtime/Conversions/Instances/DateTimeOffsetConverter.cs @@ -0,0 +1,15 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + public sealed class DateTimeOffsetConverter : JsonConverter + { + internal override JsonNode ToJson(DateTimeOffset value) => new JsonDate(value); + + internal override DateTimeOffset FromJson(JsonNode node) => (DateTimeOffset)node; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Conversions/Instances/DecimalConverter.cs b/src/CostManagement/generated/runtime/Conversions/Instances/DecimalConverter.cs new file mode 100644 index 000000000000..1a5faf42fbf0 --- /dev/null +++ b/src/CostManagement/generated/runtime/Conversions/Instances/DecimalConverter.cs @@ -0,0 +1,16 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + public sealed class DecimalConverter : JsonConverter + { + internal override JsonNode ToJson(decimal value) => new JsonNumber(value.ToString()); + + internal override decimal FromJson(JsonNode node) + { + return (decimal)node; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Conversions/Instances/DoubleConverter.cs b/src/CostManagement/generated/runtime/Conversions/Instances/DoubleConverter.cs new file mode 100644 index 000000000000..8962108559ed --- /dev/null +++ b/src/CostManagement/generated/runtime/Conversions/Instances/DoubleConverter.cs @@ -0,0 +1,13 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + public sealed class DoubleConverter : JsonConverter + { + internal override JsonNode ToJson(double value) => new JsonNumber(value); + + internal override double FromJson(JsonNode node) => (double)node; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Conversions/Instances/EnumConverter.cs b/src/CostManagement/generated/runtime/Conversions/Instances/EnumConverter.cs new file mode 100644 index 000000000000..9f971e257aa6 --- /dev/null +++ b/src/CostManagement/generated/runtime/Conversions/Instances/EnumConverter.cs @@ -0,0 +1,30 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + public sealed class EnumConverter : IJsonConverter + { + private readonly Type type; + + internal EnumConverter(Type type) + { + this.type = type ?? throw new ArgumentNullException(nameof(type)); + } + + public JsonNode ToJson(object value) => new JsonString(value.ToString()); + + public object FromJson(JsonNode node) + { + if (node.Type == JsonType.Number) + { + return Enum.ToObject(type, (int)node); + } + + return Enum.Parse(type, node.ToString(), ignoreCase: true); + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Conversions/Instances/GuidConverter.cs b/src/CostManagement/generated/runtime/Conversions/Instances/GuidConverter.cs new file mode 100644 index 000000000000..35a6f80de6e3 --- /dev/null +++ b/src/CostManagement/generated/runtime/Conversions/Instances/GuidConverter.cs @@ -0,0 +1,15 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + public sealed class GuidConverter : JsonConverter + { + internal override JsonNode ToJson(Guid value) => new JsonString(value.ToString()); + + internal override Guid FromJson(JsonNode node) => (Guid)node; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Conversions/Instances/HashSet'1Converter.cs b/src/CostManagement/generated/runtime/Conversions/Instances/HashSet'1Converter.cs new file mode 100644 index 000000000000..875d1c926d88 --- /dev/null +++ b/src/CostManagement/generated/runtime/Conversions/Instances/HashSet'1Converter.cs @@ -0,0 +1,27 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System.Collections.Generic; +using System.Linq; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + public sealed class HashSetConverter : JsonConverter> + { + internal override JsonNode ToJson(HashSet value) + { + return new XSet(value); + } + + internal override HashSet FromJson(JsonNode node) + { + var collection = node as ICollection; + + if (collection.Count == 0) return null; + + // TODO: Remove Linq depedency + return new HashSet(collection.Cast()); + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Conversions/Instances/Int16Converter.cs b/src/CostManagement/generated/runtime/Conversions/Instances/Int16Converter.cs new file mode 100644 index 000000000000..d0121be37064 --- /dev/null +++ b/src/CostManagement/generated/runtime/Conversions/Instances/Int16Converter.cs @@ -0,0 +1,13 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + public sealed class Int16Converter : JsonConverter + { + internal override JsonNode ToJson(short value) => new JsonNumber(value); + + internal override short FromJson(JsonNode node) => (short)node; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Conversions/Instances/Int32Converter.cs b/src/CostManagement/generated/runtime/Conversions/Instances/Int32Converter.cs new file mode 100644 index 000000000000..f969317da686 --- /dev/null +++ b/src/CostManagement/generated/runtime/Conversions/Instances/Int32Converter.cs @@ -0,0 +1,13 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + public sealed class Int32Converter : JsonConverter + { + internal override JsonNode ToJson(int value) => new JsonNumber(value); + + internal override int FromJson(JsonNode node) => (int)node; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Conversions/Instances/Int64Converter.cs b/src/CostManagement/generated/runtime/Conversions/Instances/Int64Converter.cs new file mode 100644 index 000000000000..df7b24f93530 --- /dev/null +++ b/src/CostManagement/generated/runtime/Conversions/Instances/Int64Converter.cs @@ -0,0 +1,13 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + public sealed class Int64Converter : JsonConverter + { + internal override JsonNode ToJson(long value) => new JsonNumber(value); + + internal override long FromJson(JsonNode node) => (long)node; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Conversions/Instances/JsonArrayConverter.cs b/src/CostManagement/generated/runtime/Conversions/Instances/JsonArrayConverter.cs new file mode 100644 index 000000000000..53bb34f79016 --- /dev/null +++ b/src/CostManagement/generated/runtime/Conversions/Instances/JsonArrayConverter.cs @@ -0,0 +1,13 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + public sealed class JsonArrayConverter : JsonConverter + { + internal override JsonNode ToJson(JsonArray value) => value; + + internal override JsonArray FromJson(JsonNode node) => (JsonArray)node; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Conversions/Instances/JsonObjectConverter.cs b/src/CostManagement/generated/runtime/Conversions/Instances/JsonObjectConverter.cs new file mode 100644 index 000000000000..3b39a1b63d26 --- /dev/null +++ b/src/CostManagement/generated/runtime/Conversions/Instances/JsonObjectConverter.cs @@ -0,0 +1,13 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + public sealed class JsonObjectConverter : JsonConverter + { + internal override JsonNode ToJson(JsonObject value) => value; + + internal override JsonObject FromJson(JsonNode node) => (JsonObject)node; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Conversions/Instances/SingleConverter.cs b/src/CostManagement/generated/runtime/Conversions/Instances/SingleConverter.cs new file mode 100644 index 000000000000..a99a41a1e78d --- /dev/null +++ b/src/CostManagement/generated/runtime/Conversions/Instances/SingleConverter.cs @@ -0,0 +1,13 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + public sealed class SingleConverter : JsonConverter + { + internal override JsonNode ToJson(float value) => new JsonNumber(value.ToString()); + + internal override float FromJson(JsonNode node) => (float)node; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Conversions/Instances/StringConverter.cs b/src/CostManagement/generated/runtime/Conversions/Instances/StringConverter.cs new file mode 100644 index 000000000000..aebfc9880a6a --- /dev/null +++ b/src/CostManagement/generated/runtime/Conversions/Instances/StringConverter.cs @@ -0,0 +1,13 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + public sealed class StringConverter : JsonConverter + { + internal override JsonNode ToJson(string value) => new JsonString(value); + + internal override string FromJson(JsonNode node) => node.ToString(); + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Conversions/Instances/TimeSpanConverter.cs b/src/CostManagement/generated/runtime/Conversions/Instances/TimeSpanConverter.cs new file mode 100644 index 000000000000..069a72984ab7 --- /dev/null +++ b/src/CostManagement/generated/runtime/Conversions/Instances/TimeSpanConverter.cs @@ -0,0 +1,15 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + public sealed class TimeSpanConverter : JsonConverter + { + internal override JsonNode ToJson(TimeSpan value) => new JsonString(value.ToString()); + + internal override TimeSpan FromJson(JsonNode node) => (TimeSpan)node; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Conversions/Instances/UInt16Converter.cs b/src/CostManagement/generated/runtime/Conversions/Instances/UInt16Converter.cs new file mode 100644 index 000000000000..70e4bfd57e54 --- /dev/null +++ b/src/CostManagement/generated/runtime/Conversions/Instances/UInt16Converter.cs @@ -0,0 +1,13 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + public sealed class UInt16Converter : JsonConverter + { + internal override JsonNode ToJson(ushort value) => new JsonNumber(value); + + internal override ushort FromJson(JsonNode node) => (ushort)node; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Conversions/Instances/UInt32Converter.cs b/src/CostManagement/generated/runtime/Conversions/Instances/UInt32Converter.cs new file mode 100644 index 000000000000..84c7d570fa02 --- /dev/null +++ b/src/CostManagement/generated/runtime/Conversions/Instances/UInt32Converter.cs @@ -0,0 +1,13 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + public sealed class UInt32Converter : JsonConverter + { + internal override JsonNode ToJson(uint value) => new JsonNumber(value); + + internal override uint FromJson(JsonNode node) => (uint)node; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Conversions/Instances/UInt64Converter.cs b/src/CostManagement/generated/runtime/Conversions/Instances/UInt64Converter.cs new file mode 100644 index 000000000000..e9e092133fd1 --- /dev/null +++ b/src/CostManagement/generated/runtime/Conversions/Instances/UInt64Converter.cs @@ -0,0 +1,13 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + public sealed class UInt64Converter : JsonConverter + { + internal override JsonNode ToJson(ulong value) => new JsonNumber(value.ToString()); + + internal override ulong FromJson(JsonNode node) => (ulong)node; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Conversions/Instances/UriConverter.cs b/src/CostManagement/generated/runtime/Conversions/Instances/UriConverter.cs new file mode 100644 index 000000000000..3f8331a7ae70 --- /dev/null +++ b/src/CostManagement/generated/runtime/Conversions/Instances/UriConverter.cs @@ -0,0 +1,15 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + public sealed class UriConverter : JsonConverter + { + internal override JsonNode ToJson(Uri value) => new JsonString(value.AbsoluteUri); + + internal override Uri FromJson(JsonNode node) => (Uri)node; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Conversions/JsonConverter.cs b/src/CostManagement/generated/runtime/Conversions/JsonConverter.cs new file mode 100644 index 000000000000..e1811f42d891 --- /dev/null +++ b/src/CostManagement/generated/runtime/Conversions/JsonConverter.cs @@ -0,0 +1,21 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + public abstract class JsonConverter : IJsonConverter + { + internal abstract T FromJson(JsonNode node); + + internal abstract JsonNode ToJson(T value); + + #region IConverter + + object IJsonConverter.FromJson(JsonNode node) => FromJson(node); + + JsonNode IJsonConverter.ToJson(object value) => ToJson((T)value); + + #endregion + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Conversions/JsonConverterAttribute.cs b/src/CostManagement/generated/runtime/Conversions/JsonConverterAttribute.cs new file mode 100644 index 000000000000..b4258b7602a6 --- /dev/null +++ b/src/CostManagement/generated/runtime/Conversions/JsonConverterAttribute.cs @@ -0,0 +1,18 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + public sealed class JsonConverterAttribute : Attribute + { + internal JsonConverterAttribute(Type type) + { + Converter = (IJsonConverter)Activator.CreateInstance(type); + } + + internal IJsonConverter Converter { get; } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Conversions/JsonConverterFactory.cs b/src/CostManagement/generated/runtime/Conversions/JsonConverterFactory.cs new file mode 100644 index 000000000000..148856740af6 --- /dev/null +++ b/src/CostManagement/generated/runtime/Conversions/JsonConverterFactory.cs @@ -0,0 +1,91 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; +using System.Collections.Generic; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + public sealed class JsonConverterFactory + { + private static readonly Dictionary converters = new Dictionary(); + + static JsonConverterFactory() + { + AddInternal(new BooleanConverter()); + AddInternal(new DateTimeConverter()); + AddInternal(new DateTimeOffsetConverter()); + AddInternal(new BinaryConverter()); + AddInternal(new DecimalConverter()); + AddInternal(new DoubleConverter()); + AddInternal(new GuidConverter()); + AddInternal(new Int16Converter()); + AddInternal(new Int32Converter()); + AddInternal(new Int64Converter()); + AddInternal(new SingleConverter()); + AddInternal(new StringConverter()); + AddInternal(new TimeSpanConverter()); + AddInternal(new UInt16Converter()); + AddInternal(new UInt32Converter()); + AddInternal(new UInt64Converter()); + AddInternal(new UriConverter()); + + // Hash sets + AddInternal(new HashSetConverter()); + AddInternal(new HashSetConverter()); + AddInternal(new HashSetConverter()); + AddInternal(new HashSetConverter()); + AddInternal(new HashSetConverter()); + AddInternal(new HashSetConverter()); + + // JSON + + AddInternal(new JsonObjectConverter()); + AddInternal(new JsonArrayConverter()); + } + + internal static Dictionary Instances => converters; + + internal static IJsonConverter Get(Type type) + { + var details = TypeDetails.Get(type); + + if (details.JsonConverter == null) + { + throw new ConversionException($"No converter found for '{type.Name}'."); + } + + return details.JsonConverter; + } + + internal static bool TryGet(Type type, out IJsonConverter converter) + { + var typeDetails = TypeDetails.Get(type); + + converter = typeDetails.JsonConverter; + + return converter != null; + } + + private static void AddInternal(JsonConverter converter) + => converters.Add(typeof(T), converter); + + private static void AddInternal(IJsonConverter converter) + => converters.Add(typeof(T), converter); + + internal static void Add(JsonConverter converter) + { + if (converter == null) + { + throw new ArgumentNullException(nameof(converter)); + } + + AddInternal(converter); + + var type = TypeDetails.Get(); + + type.JsonConverter = converter; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Conversions/StringLikeConverter.cs b/src/CostManagement/generated/runtime/Conversions/StringLikeConverter.cs new file mode 100644 index 000000000000..9075cc72c2ec --- /dev/null +++ b/src/CostManagement/generated/runtime/Conversions/StringLikeConverter.cs @@ -0,0 +1,45 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; +using System.Reflection; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + public sealed class StringLikeConverter : IJsonConverter + { + private readonly Type type; + private readonly MethodInfo parseMethod; + + internal StringLikeConverter(Type type) + { + this.type = type ?? throw new ArgumentNullException(nameof(type)); + this.parseMethod = StringLikeHelper.GetParseMethod(type); + } + + public object FromJson(JsonNode node) => + parseMethod.Invoke(null, new[] { node.ToString() }); + + public JsonNode ToJson(object value) => new JsonString(value.ToString()); + } + + internal static class StringLikeHelper + { + private static readonly Type[] parseMethodParamaterTypes = new[] { typeof(string) }; + + internal static bool IsStringLike(Type type) + { + return GetParseMethod(type) != null; + } + + internal static MethodInfo GetParseMethod(Type type) + { + MethodInfo method = type.GetMethod("Parse", parseMethodParamaterTypes); + + if (method?.IsPublic != true) return null; + + return method; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Customizations/IJsonSerializable.cs b/src/CostManagement/generated/runtime/Customizations/IJsonSerializable.cs new file mode 100644 index 000000000000..6ac43b7a9a49 --- /dev/null +++ b/src/CostManagement/generated/runtime/Customizations/IJsonSerializable.cs @@ -0,0 +1,249 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json; +using System; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime +{ + public interface IJsonSerializable + { + JsonNode ToJson(JsonObject container = null, SerializationMode serializationMode = SerializationMode.None); + } + internal static class JsonSerializable + { + /// + /// Serializes an enumerable and returns a JsonNode. + /// + /// an IEnumerable collection of items + /// A JsonNode that contains the collection of items serialized. + private static JsonNode ToJsonValue(System.Collections.IEnumerable enumerable) + { + if (enumerable != null) + { + // is it a byte array of some kind? + if (enumerable is System.Collections.Generic.IEnumerable byteEnumerable) + { + return new XBinary(System.Linq.Enumerable.ToArray(byteEnumerable)); + } + + var hasValues = false; + // just create an array of value nodes. + var result = new XNodeArray(); + foreach (var each in enumerable) + { + // we had at least one value. + hasValues = true; + + // try to serialize it. + var node = ToJsonValue(each); + if (null != node) + { + result.Add(node); + } + } + + // if we were able to add values, (or it was just empty), return it. + if (result.Count > 0 || !hasValues) + { + return result; + } + } + + // we couldn't serialize the values. Sorry. + return null; + } + + /// + /// Serializes a valuetype to a JsonNode. + /// + /// a ValueType (ie, a primitive, enum or struct) to be serialized + /// a JsonNode with the serialized value + private static JsonNode ToJsonValue(ValueType vValue) + { + // numeric type + if (vValue is SByte || vValue is Int16 || vValue is Int32 || vValue is Int64 || vValue is Byte || vValue is UInt16 || vValue is UInt32 || vValue is UInt64 || vValue is decimal || vValue is float || vValue is double) + { + return new JsonNumber(vValue.ToString()); + } + + // boolean type + if (vValue is bool bValue) + { + return new JsonBoolean(bValue); + } + + // dates + if (vValue is DateTime dtValue) + { + return new JsonDate(dtValue); + } + + // sorry, no idea. + return null; + } + /// + /// Attempts to serialize an object by using ToJson() or ToJsonString() if they exist. + /// + /// the object to be serialized. + /// the serialized JsonNode (if successful), otherwise, null + private static JsonNode TryToJsonValue(dynamic oValue) + { + object jsonValue = null; + dynamic v = oValue; + try + { + jsonValue = v.ToJson().ToString(); + } + catch + { + // no harm... + try + { + jsonValue = v.ToJsonString().ToString(); + } + catch + { + // no worries here either. + } + } + + // if we got something out, let's use it. + if (null != jsonValue) + { + // JsonNumber is really a literal json value. Just don't try to cast that back to an actual number, ok? + return new JsonNumber(jsonValue.ToString()); + } + + return null; + } + + /// + /// Serialize an object by using a variety of methods. + /// + /// the object to be serialized. + /// the serialized JsonNode (if successful), otherwise, null + internal static JsonNode ToJsonValue(object value) + { + // things that implement our interface are preferred. + if (value is Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IJsonSerializable jsonSerializable) + { + return jsonSerializable.ToJson(); + } + + // strings are easy. + if (value is string || value is char) + { + return new JsonString(value.ToString()); + } + + // value types are fairly straightforward (fallback to ToJson()/ToJsonString() or literal JsonString ) + if (value is System.ValueType vValue) + { + return ToJsonValue(vValue) ?? TryToJsonValue(vValue) ?? new JsonString(vValue.ToString()); + } + + // dictionaries are objects that should be able to serialize + if (value is System.Collections.Generic.IDictionary dictionary) + { + return Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.JsonSerializable.ToJson(dictionary, null); + } + + // enumerable collections are handled like arrays (again, fallback to ToJson()/ToJsonString() or literal JsonString) + if (value is System.Collections.IEnumerable enumerableValue) + { + // some kind of enumerable value + return ToJsonValue(enumerableValue) ?? TryToJsonValue(value) ?? new JsonString(value.ToString()); + } + + // at this point, we're going to fallback to a string literal here, since we really have no idea what it is. + return new JsonString(value.ToString()); + } + + internal static JsonObject ToJson(System.Collections.Generic.Dictionary dictionary, JsonObject container) => ToJson((System.Collections.Generic.IDictionary)dictionary, container); + + /// + /// Serializes a dictionary into a JsonObject container. + /// + /// The dictionary to serailize + /// the container to serialize the dictionary into + /// the container + internal static JsonObject ToJson(System.Collections.Generic.IDictionary dictionary, JsonObject container) + { + container = container ?? new JsonObject(); + if (dictionary != null && dictionary.Count > 0) + { + foreach (var key in dictionary) + { + // currently, we don't serialize null values. + if (null != key.Value) + { + container.Add(key.Key, ToJsonValue(key.Value)); + continue; + } + } + } + return container; + } + + internal static Func> DeserializeDictionary(Func> dictionaryFactory) + { + return (node) => FromJson(node, dictionaryFactory(), (object)(DeserializeDictionary(dictionaryFactory)) as Func); + } + + internal static System.Collections.Generic.IDictionary FromJson(JsonObject json, System.Collections.Generic.Dictionary container, System.Func objectFactory, System.Collections.Generic.HashSet excludes = null) => FromJson(json, (System.Collections.Generic.IDictionary)container, objectFactory, excludes); + + + internal static System.Collections.Generic.IDictionary FromJson(JsonObject json, System.Collections.Generic.IDictionary container, System.Func objectFactory, System.Collections.Generic.HashSet excludes = null) + { + if (null == json) + { + return container; + } + + foreach (var key in json.Keys) + { + if (true == excludes?.Contains(key)) + { + continue; + } + + var value = json[key]; + try + { + switch (value.Type) + { + case JsonType.Null: + // skip null values. + continue; + + case JsonType.Array: + case JsonType.Boolean: + case JsonType.Date: + case JsonType.Binary: + case JsonType.Number: + case JsonType.String: + container.Add(key, (V)value.ToValue()); + break; + case JsonType.Object: + if (objectFactory != null) + { + var v = objectFactory(value as JsonObject); + if (null != v) + { + container.Add(key, v); + } + } + break; + } + } + catch + { + } + } + return container; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Customizations/JsonArray.cs b/src/CostManagement/generated/runtime/Customizations/JsonArray.cs new file mode 100644 index 000000000000..5509a376c543 --- /dev/null +++ b/src/CostManagement/generated/runtime/Customizations/JsonArray.cs @@ -0,0 +1,13 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + public partial class JsonArray + { + internal override object ToValue() => Count == 0 ? new object[0] : System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(this, each => each.ToValue())); + } + + +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Customizations/JsonBoolean.cs b/src/CostManagement/generated/runtime/Customizations/JsonBoolean.cs new file mode 100644 index 000000000000..7da9fb8545dc --- /dev/null +++ b/src/CostManagement/generated/runtime/Customizations/JsonBoolean.cs @@ -0,0 +1,16 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + internal partial class JsonBoolean + { + internal static JsonBoolean Create(bool? value) => value is bool b ? new JsonBoolean(b) : null; + internal bool ToBoolean() => Value; + + internal override object ToValue() => Value; + } + + +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Customizations/JsonNode.cs b/src/CostManagement/generated/runtime/Customizations/JsonNode.cs new file mode 100644 index 000000000000..7eadf585de5e --- /dev/null +++ b/src/CostManagement/generated/runtime/Customizations/JsonNode.cs @@ -0,0 +1,21 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + using System; + using System.Collections.Generic; + + public partial class JsonNode + { + /// + /// Returns the content of this node as the underlying value. + /// Will default to the string representation if not overridden in child classes. + /// + /// an object with the underlying value of the node. + internal virtual object ToValue() { + return this.ToString(); + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Customizations/JsonNumber.cs b/src/CostManagement/generated/runtime/Customizations/JsonNumber.cs new file mode 100644 index 000000000000..ad8295dfef94 --- /dev/null +++ b/src/CostManagement/generated/runtime/Customizations/JsonNumber.cs @@ -0,0 +1,78 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + using System; + + public partial class JsonNumber + { + internal static readonly DateTime EpochDate = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); + private static long ToUnixTime(DateTime dateTime) + { + return (long)dateTime.Subtract(EpochDate).TotalSeconds; + } + private static DateTime FromUnixTime(long totalSeconds) + { + return EpochDate.AddSeconds(totalSeconds); + } + internal byte ToByte() => this; + internal int ToInt() => this; + internal long ToLong() => this; + internal short ToShort() => this; + internal UInt16 ToUInt16() => this; + internal UInt32 ToUInt32() => this; + internal UInt64 ToUInt64() => this; + internal decimal ToDecimal() => this; + internal double ToDouble() => this; + internal float ToFloat() => this; + + internal static JsonNumber Create(int? value) => value is int n ? new JsonNumber(n) : null; + internal static JsonNumber Create(long? value) => value is long n ? new JsonNumber(n) : null; + internal static JsonNumber Create(float? value) => value is float n ? new JsonNumber(n) : null; + internal static JsonNumber Create(double? value) => value is double n ? new JsonNumber(n) : null; + internal static JsonNumber Create(decimal? value) => value is decimal n ? new JsonNumber(n) : null; + internal static JsonNumber Create(DateTime? value) => value is DateTime date ? new JsonNumber(ToUnixTime(date)) : null; + + public static implicit operator DateTime(JsonNumber number) => FromUnixTime(number); + internal DateTime ToDateTime() => this; + + internal JsonNumber(decimal value) + { + this.value = value.ToString(); + } + internal override object ToValue() + { + if (IsInteger) + { + if (int.TryParse(this.value, out int iValue)) + { + return iValue; + } + if (long.TryParse(this.value, out long lValue)) + { + return lValue; + } + } + else + { + if (float.TryParse(this.value, out float fValue)) + { + return fValue; + } + if (double.TryParse(this.value, out double dValue)) + { + return dValue; + } + if (decimal.TryParse(this.value, out decimal dcValue)) + { + return dcValue; + } + } + return null; + } + } + + +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Customizations/JsonObject.cs b/src/CostManagement/generated/runtime/Customizations/JsonObject.cs new file mode 100644 index 000000000000..1ac64bbb6e4b --- /dev/null +++ b/src/CostManagement/generated/runtime/Customizations/JsonObject.cs @@ -0,0 +1,183 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + using System; + using System.Collections.Generic; + + public partial class JsonObject + { + internal override object ToValue() => Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.JsonSerializable.FromJson(this, new System.Collections.Generic.Dictionary(), (obj) => obj.ToValue()); + + internal void SafeAdd(string name, Func valueFn) + { + if (valueFn != null) + { + var value = valueFn(); + if (null != value) + { + items.Add(name, value); + } + } + } + + internal void SafeAdd(string name, JsonNode value) + { + if (null != value) + { + items.Add(name, value); + } + } + + internal T NullableProperty(string propertyName) where T : JsonNode + { + if (this.TryGetValue(propertyName, out JsonNode value)) + { + if (value.IsNull) + { + return null; + } + if (value is T tval) + { + return tval; + } + /* it's present, but not the correct type... */ + //throw new Exception($"Property {propertyName} in object expected type {typeof(T).Name} but value of type {value.Type.ToString()} was found."); + } + return null; + } + + internal JsonObject Property(string propertyName) + { + return PropertyT(propertyName); + } + + internal T PropertyT(string propertyName) where T : JsonNode + { + if (this.TryGetValue(propertyName, out JsonNode value)) + { + if (value.IsNull) + { + return null; // we're going to assume that the consumer knows what to do if null is explicity returned? + } + + if (value is T tval) + { + return tval; + } + /* it's present, but not the correct type... */ + // throw new Exception($"Property {propertyName} in object expected type {typeof(T).Name} but value of type {value.Type.ToString()} was found."); + } + return null; + } + + internal int NumberProperty(string propertyName, ref int output) => output = this.PropertyT(propertyName)?.ToInt() ?? output; + internal float NumberProperty(string propertyName, ref float output) => output = this.PropertyT(propertyName)?.ToFloat() ?? output; + internal byte NumberProperty(string propertyName, ref byte output) => output = this.PropertyT(propertyName)?.ToByte() ?? output; + internal long NumberProperty(string propertyName, ref long output) => output = this.PropertyT(propertyName)?.ToLong() ?? output; + internal double NumberProperty(string propertyName, ref double output) => output = this.PropertyT(propertyName)?.ToDouble() ?? output; + internal decimal NumberProperty(string propertyName, ref decimal output) => output = this.PropertyT(propertyName)?.ToDecimal() ?? output; + internal short NumberProperty(string propertyName, ref short output) => output = this.PropertyT(propertyName)?.ToShort() ?? output; + internal DateTime NumberProperty(string propertyName, ref DateTime output) => output = this.PropertyT(propertyName)?.ToDateTime() ?? output; + + internal int? NumberProperty(string propertyName, ref int? output) => output = this.NullableProperty(propertyName)?.ToInt() ?? null; + internal float? NumberProperty(string propertyName, ref float? output) => output = this.NullableProperty(propertyName)?.ToFloat() ?? null; + internal byte? NumberProperty(string propertyName, ref byte? output) => output = this.NullableProperty(propertyName)?.ToByte() ?? null; + internal long? NumberProperty(string propertyName, ref long? output) => output = this.NullableProperty(propertyName)?.ToLong() ?? null; + internal double? NumberProperty(string propertyName, ref double? output) => output = this.NullableProperty(propertyName)?.ToDouble() ?? null; + internal decimal? NumberProperty(string propertyName, ref decimal? output) => output = this.NullableProperty(propertyName)?.ToDecimal() ?? null; + internal short? NumberProperty(string propertyName, ref short? output) => output = this.NullableProperty(propertyName)?.ToShort() ?? null; + + internal DateTime? NumberProperty(string propertyName, ref DateTime? output) => output = this.NullableProperty(propertyName)?.ToDateTime() ?? null; + + + internal string StringProperty(string propertyName) => this.PropertyT(propertyName)?.ToString(); + internal string StringProperty(string propertyName, ref string output) => output = this.PropertyT(propertyName)?.ToString() ?? output; + internal char StringProperty(string propertyName, ref char output) => output = this.PropertyT(propertyName)?.ToChar() ?? output; + internal char? StringProperty(string propertyName, ref char? output) => output = this.PropertyT(propertyName)?.ToChar() ?? null; + + internal DateTime StringProperty(string propertyName, ref DateTime output) => DateTime.TryParse(this.PropertyT(propertyName)?.ToString(), out output) ? output : output; + internal DateTime? StringProperty(string propertyName, ref DateTime? output) => output = DateTime.TryParse(this.PropertyT(propertyName)?.ToString(), out var o) ? o : output; + + + internal bool BooleanProperty(string propertyName, ref bool output) => output = this.PropertyT(propertyName)?.ToBoolean() ?? output; + internal bool? BooleanProperty(string propertyName, ref bool? output) => output = this.PropertyT(propertyName)?.ToBoolean() ?? null; + + internal T[] ArrayProperty(string propertyName, ref T[] output, Func deserializer) + { + var array = this.PropertyT(propertyName); + if (array != null) + { + output = new T[array.Count]; + for (var i = 0; i < output.Length; i++) + { + output[i] = deserializer(array[i]); + } + } + return output; + } + internal T[] ArrayProperty(string propertyName, Func deserializer) + { + var array = this.PropertyT(propertyName); + if (array != null) + { + var output = new T[array.Count]; + for (var i = 0; i < output.Length; i++) + { + output[i] = deserializer(array[i]); + } + return output; + } + return new T[0]; + } + internal void IterateArrayProperty(string propertyName, Action deserializer) + { + var array = this.PropertyT(propertyName); + if (array != null) + { + for (var i = 0; i < array.Count; i++) + { + deserializer(array[i]); + } + } + } + + internal Dictionary DictionaryProperty(string propertyName, ref Dictionary output, Func deserializer) + { + var dictionary = this.PropertyT(propertyName); + if (output == null) + { + output = new Dictionary(); + } + else + { + output.Clear(); + } + if (dictionary != null) + { + foreach (var key in dictionary.Keys) + { + output[key] = deserializer(dictionary[key]); + } + } + return output; + } + + internal static JsonObject Create(IDictionary source, Func selector) + { + if (source == null || selector == null) + { + return null; + } + var result = new JsonObject(); + + foreach (var key in source.Keys) + { + result.SafeAdd(key, selector(source[key])); + } + return result; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Customizations/JsonString.cs b/src/CostManagement/generated/runtime/Customizations/JsonString.cs new file mode 100644 index 000000000000..3032c67a5556 --- /dev/null +++ b/src/CostManagement/generated/runtime/Customizations/JsonString.cs @@ -0,0 +1,34 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + using System; + using System.Globalization; + using System.Linq; + + public partial class JsonString + { + internal static string DateFormat = "yyyy-MM-dd"; + internal static string DateTimeFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss.FFFFFFFK"; + internal static string DateTimeRfc1123Format = "R"; + + internal static JsonString Create(string value) => value == null ? null : new JsonString(value); + internal static JsonString Create(char? value) => value is char c ? new JsonString(c.ToString()) : null; + + internal static JsonString CreateDate(DateTime? value) => value is DateTime date ? new JsonString(date.ToString(DateFormat, CultureInfo.CurrentCulture)) : null; + internal static JsonString CreateDateTime(DateTime? value) => value is DateTime date ? new JsonString(date.ToString(DateTimeFormat, CultureInfo.CurrentCulture)) : null; + internal static JsonString CreateDateTimeRfc1123(DateTime? value) => value is DateTime date ? new JsonString(date.ToString(DateTimeRfc1123Format, CultureInfo.CurrentCulture)) : null; + + internal char ToChar() => this.Value?.ToString()?.FirstOrDefault() ?? default(char); + public static implicit operator char(JsonString value) => value?.ToString()?.FirstOrDefault() ?? default(char); + public static implicit operator char? (JsonString value) => value?.ToString()?.FirstOrDefault(); + + public static implicit operator DateTime(JsonString value) => DateTime.TryParse(value, out var output) ? output : default(DateTime); + public static implicit operator DateTime? (JsonString value) => DateTime.TryParse(value, out var output) ? output : default(DateTime?); + + } + + +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Customizations/XNodeArray.cs b/src/CostManagement/generated/runtime/Customizations/XNodeArray.cs new file mode 100644 index 000000000000..b7b44770348d --- /dev/null +++ b/src/CostManagement/generated/runtime/Customizations/XNodeArray.cs @@ -0,0 +1,44 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + using System; + using System.Linq; + + public partial class XNodeArray + { + internal static XNodeArray Create(T[] source, Func selector) + { + if (source == null || selector == null) + { + return null; + } + var result = new XNodeArray(); + foreach (var item in source.Select(selector)) + { + result.SafeAdd(item); + } + return result; + } + internal void SafeAdd(JsonNode item) + { + if (item != null) + { + items.Add(item); + } + } + internal void SafeAdd(Func itemFn) + { + if (itemFn != null) + { + var item = itemFn(); + if (item != null) + { + items.Add(item); + } + } + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Debugging.cs b/src/CostManagement/generated/runtime/Debugging.cs new file mode 100644 index 000000000000..65ce31ce5a4d --- /dev/null +++ b/src/CostManagement/generated/runtime/Debugging.cs @@ -0,0 +1,28 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime +{ + internal static class AttachDebugger + { + internal static void Break() + { + while (!System.Diagnostics.Debugger.IsAttached) + { + System.Console.Error.WriteLine($"Waiting for debugger to attach to process {System.Diagnostics.Process.GetCurrentProcess().Id}"); + for (int i = 0; i < 50; i++) + { + if (System.Diagnostics.Debugger.IsAttached) + { + break; + } + System.Threading.Thread.Sleep(100); + System.Console.Error.Write("."); + } + System.Console.Error.WriteLine(); + } + System.Diagnostics.Debugger.Break(); + } + } +} diff --git a/src/CostManagement/generated/runtime/DictionaryExtensions.cs b/src/CostManagement/generated/runtime/DictionaryExtensions.cs new file mode 100644 index 000000000000..57300be52bf7 --- /dev/null +++ b/src/CostManagement/generated/runtime/DictionaryExtensions.cs @@ -0,0 +1,36 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime +{ + internal static class DictionaryExtensions + { + internal static void HashTableToDictionary(System.Collections.Hashtable hashtable, System.Collections.Generic.IDictionary dictionary) + { + foreach (var each in hashtable.Keys) + { + var key = each.ToString(); + var value = hashtable[key]; + if (null != value) + { + if (value is System.Collections.Hashtable nested) + { + HashTableToDictionary(nested, new System.Collections.Generic.Dictionary()); + } + else + { + try + { + dictionary[key] = (V)value; + } + catch + { + // Values getting dropped; not compatible with target dictionary. Not sure what to do here. + } + } + } + } + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/EventData.cs b/src/CostManagement/generated/runtime/EventData.cs new file mode 100644 index 000000000000..55c5d8b6a792 --- /dev/null +++ b/src/CostManagement/generated/runtime/EventData.cs @@ -0,0 +1,78 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime +{ + + using System; + using System.Threading; + + ///Represents the data in signaled event. + public partial class EventData + { + /// + /// The type of the event being signaled + /// + public string Id; + + /// + /// The user-ready message from the event. + /// + public string Message; + + /// + /// When the event is about a parameter, this is the parameter name. + /// Used in Validation Events + /// + public string Parameter; + + /// + /// This represents a numeric value associated with the event. + /// Use for progress-style events + /// + public double Value; + + /// + /// Any extended data for an event should be serialized and stored here. + /// + public string ExtendedData; + + /// + /// If the event triggers after the request message has been created, this will contain the Request Message (which in HTTP calls would be HttpRequestMessage) + /// + /// Typically you'd cast this to the expected type to use it: + /// + /// if(eventData.RequestMessgae is HttpRequestMessage httpRequest) + /// { + /// httpRequest.Headers.Add("x-request-flavor", "vanilla"); + /// } + /// + /// + public object RequestMessage; + + /// + /// If the event triggers after the response is back, this will contain the Response Message (which in HTTP calls would be HttpResponseMessage) + /// + /// Typically you'd cast this to the expected type to use it: + /// + /// if(eventData.ResponseMessage is HttpResponseMessage httpResponse){ + /// var flavor = httpResponse.Headers.GetValue("x-request-flavor"); + /// } + /// + /// + public object ResponseMessage; + + /// + /// Cancellation method for this event. + /// + /// If the event consumer wishes to cancel the request that initiated this event, call Cancel() + /// + /// + /// The original initiator of the request must provide the implementation of this. + /// + public System.Action Cancel; + } + +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/EventDataExtensions.cs b/src/CostManagement/generated/runtime/EventDataExtensions.cs new file mode 100644 index 000000000000..e6dc3bd4f1e5 --- /dev/null +++ b/src/CostManagement/generated/runtime/EventDataExtensions.cs @@ -0,0 +1,94 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime +{ + using System; + + [System.ComponentModel.TypeConverter(typeof(EventDataConverter))] + /// + /// PowerShell-specific data on top of the llc# EventData + /// + /// + /// In PowerShell, we add on the EventDataConverter to support sending events between modules. + /// Obviously, this code would need to be duplcated on both modules. + /// This is preferable to sharing a common library, as versioning makes that problematic. + /// + public partial class EventData : EventArgs + { + } + + /// + /// A PowerShell PSTypeConverter to adapt an EventData object that has been passed. + /// Usually used between modules. + /// + public class EventDataConverter : System.Management.Automation.PSTypeConverter + { + public override bool CanConvertTo(object sourceValue, Type destinationType) => false; + public override object ConvertTo(object sourceValue, Type destinationType, IFormatProvider formatProvider, bool ignoreCase) => null; + public override bool CanConvertFrom(dynamic sourceValue, Type destinationType) => destinationType == typeof(EventData) && CanConvertFrom(sourceValue); + public override object ConvertFrom(dynamic sourceValue, Type destinationType, IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue); + + /// + /// Verifies that a given object has the required members to convert it to the target type (EventData) + /// + /// Uses a dynamic type so that it is able to use the simplest code without excessive checking. + /// + /// The instance to verify + /// True, if the object has all the required parameters. + public static bool CanConvertFrom(dynamic sourceValue) + { + try + { + // check if this has *required* parameters... + sourceValue?.Id?.GetType(); + sourceValue?.Message?.GetType(); + sourceValue?.Cancel?.GetType(); + + // remaining parameters are not *required*, + // and if they have values, it will copy them at conversion time. + } + catch + { + // if anything throws an exception (because it's null, or doesn't have that member) + return false; + } + return true; + } + + /// + /// Returns result of the delegate as the expected type, or default(T) + /// + /// This isolates any exceptions from the consumer. + /// + /// A delegate that returns a value + /// The desired output type + /// The value from the function if the type is correct + private static T To(Func srcValue) + { + try { return srcValue(); } + catch { return default(T); } + } + + /// + /// Converts an incoming object to the expected type by treating the incoming object as a dynamic, and coping the expected values. + /// + /// the incoming object + /// EventData + public static EventData ConvertFrom(dynamic sourceValue) + { + return new EventData + { + Id = To(() => sourceValue.Id), + Message = To(() => sourceValue.Message), + Parameter = To(() => sourceValue.Parameter), + Value = To(() => sourceValue.Value), + RequestMessage = To(() => sourceValue.RequestMessage), + ResponseMessage = To(() => sourceValue.ResponseMessage), + Cancel = To(() => sourceValue.Cancel) + }; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/EventListener.cs b/src/CostManagement/generated/runtime/EventListener.cs new file mode 100644 index 000000000000..1f591cb02186 --- /dev/null +++ b/src/CostManagement/generated/runtime/EventListener.cs @@ -0,0 +1,247 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime +{ + + using System; + using System.Linq; + using System.Collections; + using System.Collections.Generic; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + using GetEventData = System.Func; + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + public interface IValidates + { + Task Validate(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IEventListener listener); + } + + /// + /// The IEventListener Interface defines the communication mechanism for Signaling events during a remote call. + /// + /// + /// The interface is designed to be as minimal as possible, allow for quick peeking of the event type (id) + /// and the cancellation status and provides a delegate for retrieving the event details themselves. + /// + public interface IEventListener + { + Task Signal(string id, CancellationToken token, GetEventData createMessage); + CancellationToken Token { get; } + System.Action Cancel { get; } + } + + internal static partial class Extensions + { + public static Task Signal(this IEventListener instance, string id, CancellationToken token, Func createMessage) => instance.Signal(id, token, createMessage); + public static Task Signal(this IEventListener instance, string id, CancellationToken token) => instance.Signal(id, token, () => new EventData { Id = id, Cancel = instance.Cancel }); + public static Task Signal(this IEventListener instance, string id, CancellationToken token, string messageText) => instance.Signal(id, token, () => new EventData { Id = id, Message = messageText, Cancel = instance.Cancel }); + public static Task Signal(this IEventListener instance, string id, CancellationToken token, string messageText, HttpRequestMessage request) => instance.Signal(id, token, () => new EventData { Id = id, Message = messageText, RequestMessage = request, Cancel = instance.Cancel }); + public static Task Signal(this IEventListener instance, string id, CancellationToken token, string messageText, HttpResponseMessage response) => instance.Signal(id, token, () => new EventData { Id = id, Message = messageText, RequestMessage = response.RequestMessage, ResponseMessage = response, Cancel = instance.Cancel }); + public static Task Signal(this IEventListener instance, string id, CancellationToken token, string messageText, double magnitude) => instance.Signal(id, token, () => new EventData { Id = id, Message = messageText, Value = magnitude, Cancel = instance.Cancel }); + public static Task Signal(this IEventListener instance, string id, CancellationToken token, string messageText, double magnitude, HttpRequestMessage request) => instance.Signal(id, token, () => new EventData { Id = id, Message = messageText, RequestMessage = request, Value = magnitude, Cancel = instance.Cancel }); + public static Task Signal(this IEventListener instance, string id, CancellationToken token, string messageText, double magnitude, HttpResponseMessage response) => instance.Signal(id, token, () => new EventData { Id = id, Message = messageText, RequestMessage = response.RequestMessage, ResponseMessage = response, Value = magnitude, Cancel = instance.Cancel }); + public static Task Signal(this IEventListener instance, string id, CancellationToken token, HttpRequestMessage request) => instance.Signal(id, token, () => new EventData { Id = id, RequestMessage = request, Cancel = instance.Cancel }); + public static Task Signal(this IEventListener instance, string id, CancellationToken token, HttpRequestMessage request, HttpResponseMessage response) => instance.Signal(id, token, () => new EventData { Id = id, RequestMessage = request, ResponseMessage = response, Cancel = instance.Cancel }); + public static Task Signal(this IEventListener instance, string id, CancellationToken token, HttpResponseMessage response) => instance.Signal(id, token, () => new EventData { Id = id, RequestMessage = response.RequestMessage, ResponseMessage = response, Cancel = instance.Cancel }); + public static Task Signal(this IEventListener instance, string id, CancellationToken token, EventData message) => instance.Signal(id, token, () => { message.Id = id; message.Cancel = instance.Cancel; return message; }); + + public static Task Signal(this IEventListener instance, string id, Func createMessage) => instance.Signal(id, instance.Token, createMessage); + public static Task Signal(this IEventListener instance, string id) => instance.Signal(id, instance.Token, () => new EventData { Id = id, Cancel = instance.Cancel }); + public static Task Signal(this IEventListener instance, string id, string messageText) => instance.Signal(id, instance.Token, () => new EventData { Id = id, Message = messageText, Cancel = instance.Cancel }); + public static Task Signal(this IEventListener instance, string id, string messageText, HttpRequestMessage request) => instance.Signal(id, instance.Token, () => new EventData { Id = id, Message = messageText, RequestMessage = request, Cancel = instance.Cancel }); + public static Task Signal(this IEventListener instance, string id, string messageText, HttpResponseMessage response) => instance.Signal(id, instance.Token, () => new EventData { Id = id, Message = messageText, RequestMessage = response.RequestMessage, ResponseMessage = response, Cancel = instance.Cancel }); + public static Task Signal(this IEventListener instance, string id, string messageText, double magnitude) => instance.Signal(id, instance.Token, () => new EventData { Id = id, Message = messageText, Value = magnitude, Cancel = instance.Cancel }); + public static Task Signal(this IEventListener instance, string id, string messageText, double magnitude, HttpRequestMessage request) => instance.Signal(id, instance.Token, () => new EventData { Id = id, Message = messageText, RequestMessage = request, Value = magnitude, Cancel = instance.Cancel }); + public static Task Signal(this IEventListener instance, string id, string messageText, double magnitude, HttpResponseMessage response) => instance.Signal(id, instance.Token, () => new EventData { Id = id, Message = messageText, RequestMessage = response.RequestMessage, ResponseMessage = response, Value = magnitude, Cancel = instance.Cancel }); + public static Task Signal(this IEventListener instance, string id, HttpRequestMessage request) => instance.Signal(id, instance.Token, () => new EventData { Id = id, RequestMessage = request, Cancel = instance.Cancel }); + public static Task Signal(this IEventListener instance, string id, HttpRequestMessage request, HttpResponseMessage response) => instance.Signal(id, instance.Token, () => new EventData { Id = id, RequestMessage = request, ResponseMessage = response, Cancel = instance.Cancel }); + public static Task Signal(this IEventListener instance, string id, HttpResponseMessage response) => instance.Signal(id, instance.Token, () => new EventData { Id = id, RequestMessage = response.RequestMessage, ResponseMessage = response, Cancel = instance.Cancel }); + public static Task Signal(this IEventListener instance, string id, EventData message) => instance.Signal(id, instance.Token, () => { message.Id = id; message.Cancel = instance.Cancel; return message; }); + + public static Task Signal(this IEventListener instance, string id, System.Uri uri) => instance.Signal(id, instance.Token, () => new EventData { Id = id, Message = uri.ToString(), Cancel = instance.Cancel }); + + public static async Task AssertNotNull(this IEventListener instance, string parameterName, object value) + { + if (value == null) + { + await instance.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.ValidationWarning, instance.Token, () => new EventData { Id = Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.ValidationWarning, Message = $"'{parameterName}' should not be null", Parameter = parameterName, Cancel = instance.Cancel }); + } + } + public static async Task AssertMinimumLength(this IEventListener instance, string parameterName, string value, int length) + { + if (value != null && value.Length < length) + { + await instance.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.ValidationWarning, instance.Token, () => new EventData { Id = Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.ValidationWarning, Message = $"Length of '{parameterName}' is less than {length}", Parameter = parameterName, Cancel = instance.Cancel }); + } + } + public static async Task AssertMaximumLength(this IEventListener instance, string parameterName, string value, int length) + { + if (value != null && value.Length > length) + { + await instance.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.ValidationWarning, instance.Token, () => new EventData { Id = Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.ValidationWarning, Message = $"Length of '{parameterName}' is greater than {length}", Parameter = parameterName, Cancel = instance.Cancel }); + } + } + + public static async Task AssertRegEx(this IEventListener instance, string parameterName, string value, string regularExpression) + { + if (value != null && !System.Text.RegularExpressions.Regex.Match(value, regularExpression).Success) + { + await instance.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.ValidationWarning, instance.Token, () => new EventData { Id = Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.ValidationWarning, Message = $"'{parameterName}' does not validate against pattern /{regularExpression}/", Parameter = parameterName, Cancel = instance.Cancel }); + } + } + public static async Task AssertEnum(this IEventListener instance, string parameterName, string value, params string[] values) + { + if (!values.Any(each => each.Equals(value))) + { + await instance.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.ValidationWarning, instance.Token, () => new EventData { Id = Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.ValidationWarning, Message = $"'{parameterName}' is not one of ({values.Aggregate((c, e) => $"'{e}',{c}")}", Parameter = parameterName, Cancel = instance.Cancel }); + } + } + public static async Task AssertObjectIsValid(this IEventListener instance, string parameterName, object inst) + { + await (inst as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.IValidates)?.Validate(instance); + } + + public static async Task AssertIsLessThan(this IEventListener instance, string parameterName, T? value, T max) where T : struct, System.IComparable + { + if (null != value && ((T)value).CompareTo(max) >= 0) + { + await instance.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.ValidationWarning, instance.Token, () => new EventData { Id = Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.ValidationWarning, Message = $"Value of '{parameterName}' must be less than {max} (value is {value})", Parameter = parameterName, Cancel = instance.Cancel }); + } + } + public static async Task AssertIsGreaterThan(this IEventListener instance, string parameterName, T? value, T max) where T : struct, System.IComparable + { + if (null != value && ((T)value).CompareTo(max) <= 0) + { + await instance.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.ValidationWarning, instance.Token, () => new EventData { Id = Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.ValidationWarning, Message = $"Value of '{parameterName}' must be greater than {max} (value is {value})", Parameter = parameterName, Cancel = instance.Cancel }); + } + } + public static async Task AssertIsLessThanOrEqual(this IEventListener instance, string parameterName, T? value, T max) where T : struct, System.IComparable + { + if (null != value && ((T)value).CompareTo(max) > 0) + { + await instance.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.ValidationWarning, instance.Token, () => new EventData { Id = Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.ValidationWarning, Message = $"Value of '{parameterName}' must be less than or equal to {max} (value is {value})", Parameter = parameterName, Cancel = instance.Cancel }); + } + } + public static async Task AssertIsGreaterThanOrEqual(this IEventListener instance, string parameterName, T? value, T max) where T : struct, System.IComparable + { + if (null != value && ((T)value).CompareTo(max) < 0) + { + await instance.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.ValidationWarning, instance.Token, () => new EventData { Id = Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.ValidationWarning, Message = $"Value of '{parameterName}' must be greater than or equal to {max} (value is {value})", Parameter = parameterName, Cancel = instance.Cancel }); + } + } + public static async Task AssertIsMultipleOf(this IEventListener instance, string parameterName, Int64? value, Int64 multiple) + { + if (null != value && value % multiple != 0) + { + await instance.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.ValidationWarning, instance.Token, () => new EventData { Id = Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.ValidationWarning, Message = $"Value of '{parameterName}' must be multiple of {multiple} (value is {value})", Parameter = parameterName, Cancel = instance.Cancel }); + } + } + public static async Task AssertIsMultipleOf(this IEventListener instance, string parameterName, double? value, double multiple) + { + if (null != value) + { + var i = (Int64)(value / multiple); + if (i != value / multiple) + { + await instance.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.ValidationWarning, instance.Token, () => new EventData { Id = Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.ValidationWarning, Message = $"Value of '{parameterName}' must be multiple of {multiple} (value is {value})", Parameter = parameterName, Cancel = instance.Cancel }); + } + } + } + public static async Task AssertIsMultipleOf(this IEventListener instance, string parameterName, decimal? value, decimal multiple) + { + if (null != value) + { + var i = (Int64)(value / multiple); + if (i != value / multiple) + { + await instance.Signal(Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.ValidationWarning, instance.Token, () => new EventData { Id = Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Events.ValidationWarning, Message = $"Value of '{parameterName}' must be multiple of {multiple} (value is {value})", Parameter = parameterName, Cancel = instance.Cancel }); + } + } + } + } + + /// + /// An Implementation of the IEventListener that supports subscribing to events and dispatching them + /// (used for manually using the lowlevel interface) + /// + public class EventListener : CancellationTokenSource, IEnumerable>, IEventListener + { + private Dictionary calls = new Dictionary(); + public IEnumerator> GetEnumerator() => calls.GetEnumerator(); + IEnumerator IEnumerable.GetEnumerator() => calls.GetEnumerator(); + public EventListener() + { + } + + public new Action Cancel => base.Cancel; + private Event tracer; + + public EventListener(params (string name, Event callback)[] initializer) + { + foreach (var each in initializer) + { + Add(each.name, each.callback); + } + } + + public void Add(string name, SynchEvent callback) + { + Add(name, (message) => { callback(message); return Task.CompletedTask; }); + } + + public void Add(string name, Event callback) + { + if (callback != null) + { + if (string.IsNullOrEmpty(name)) + { + if (calls.ContainsKey(name)) + { + tracer += callback; + } + else + { + tracer = callback; + } + } + else + { + if (calls.ContainsKey(name)) + { + calls[name ?? System.String.Empty] += callback; + } + else + { + calls[name ?? System.String.Empty] = callback; + } + } + } + } + + + public async Task Signal(string id, CancellationToken token, GetEventData createMessage) + { + using (NoSynchronizationContext) + { + if (!string.IsNullOrEmpty(id) && (calls.TryGetValue(id, out Event listener) || tracer != null)) + { + var message = createMessage(); + message.Id = id; + + await listener?.Invoke(message); + await tracer?.Invoke(message); + + if (token.IsCancellationRequested) + { + throw new OperationCanceledException($"Canceled by event {id} ", this.Token); + } + } + } + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Events.cs b/src/CostManagement/generated/runtime/Events.cs new file mode 100644 index 000000000000..8de84b629dc3 --- /dev/null +++ b/src/CostManagement/generated/runtime/Events.cs @@ -0,0 +1,27 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime +{ + public static partial class Events + { + public const string Log = nameof(Log); + public const string Validation = nameof(Validation); + public const string ValidationWarning = nameof(ValidationWarning); + public const string AfterValidation = nameof(AfterValidation); + public const string RequestCreated = nameof(RequestCreated); + public const string ResponseCreated = nameof(ResponseCreated); + public const string URLCreated = nameof(URLCreated); + public const string Finally = nameof(Finally); + public const string HeaderParametersAdded = nameof(HeaderParametersAdded); + public const string BodyContentSet = nameof(BodyContentSet); + public const string BeforeCall = nameof(BeforeCall); + public const string BeforeResponseDispatch = nameof(BeforeResponseDispatch); + public const string FollowingNextLink = nameof(FollowingNextLink); + public const string DelayBeforePolling = nameof(DelayBeforePolling); + public const string Polling = nameof(Polling); + + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/EventsExtensions.cs b/src/CostManagement/generated/runtime/EventsExtensions.cs new file mode 100644 index 000000000000..21fd63a7beed --- /dev/null +++ b/src/CostManagement/generated/runtime/EventsExtensions.cs @@ -0,0 +1,27 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime +{ + public static partial class Events + { + public const string CmdletProcessRecordStart = nameof(CmdletProcessRecordStart); + public const string CmdletProcessRecordAsyncStart = nameof(CmdletProcessRecordAsyncStart); + public const string CmdletException = nameof(CmdletException); + public const string CmdletGetPipeline = nameof(CmdletGetPipeline); + public const string CmdletBeforeAPICall = nameof(CmdletBeforeAPICall); + public const string CmdletBeginProcessing = nameof(CmdletBeginProcessing); + public const string CmdletEndProcessing = nameof(CmdletEndProcessing); + public const string CmdletProcessRecordEnd = nameof(CmdletProcessRecordEnd); + public const string CmdletProcessRecordAsyncEnd = nameof(CmdletProcessRecordAsyncEnd); + public const string CmdletAfterAPICall = nameof(CmdletAfterAPICall); + + public const string Verbose = nameof(Verbose); + public const string Debug = nameof(Debug); + public const string Information = nameof(Information); + public const string Error = nameof(Error); + public const string Warning = nameof(Warning); + } + +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Extensions.cs b/src/CostManagement/generated/runtime/Extensions.cs new file mode 100644 index 000000000000..23f26f5a7b8a --- /dev/null +++ b/src/CostManagement/generated/runtime/Extensions.cs @@ -0,0 +1,111 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime +{ + using System.Linq; + + internal static partial class Extensions + { + + public static T ReadHeaders(this T instance, global::System.Net.Http.Headers.HttpResponseHeaders headers) where T : class + { + (instance as IHeaderSerializable)?.ReadHeaders(headers); + return instance; + } + + internal static bool If(T input, out T output) + { + if (null == input) + { + output = default(T); + return false; + } + output = input; + return true; + } + + internal static void AddIf(T value, System.Action addMethod) + { + // if value is present (and it's not just an empty JSON Object) + if (null != value && (value as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject)?.Keys.Count != 0) + { + addMethod(value); + } + } + + internal static void AddIf(T value, string serializedName, System.Action addMethod) + { + // if value is present (and it's not just an empty JSON Object) + if (null != value && (value as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject)?.Keys.Count != 0) + { + addMethod(serializedName, value); + } + } + + /// + /// Returns the first header value as a string from an HttpReponseMessage. + /// + /// the HttpResponseMessage to fetch a header from + /// the header name + /// the first header value as a string from an HttpReponseMessage. string.empty if there is no header value matching + internal static string GetFirstHeader(this System.Net.Http.HttpResponseMessage response, string headerName) => response.Headers.FirstOrDefault(each => headerName == each.Key).Value?.FirstOrDefault() ?? string.Empty; + + /// + /// Sets the Synchronization Context to null, and returns an IDisposable that when disposed, + /// will restore the synchonization context to the original value. + /// + /// This is used a less-invasive means to ensure that code in the library that doesn't + /// need to be continued in the original context doesn't have to have ConfigureAwait(false) + /// on every single await + /// + /// If the SynchronizationContext is null when this is used, the resulting IDisposable + /// will not do anything (this prevents excessive re-setting of the SynchronizationContext) + /// + /// Usage: + /// + /// using(NoSynchronizationContext) { + /// await SomeAsyncOperation(); + /// await SomeOtherOperation(); + /// } + /// + /// + /// + /// An IDisposable that will return the SynchronizationContext to original state + internal static System.IDisposable NoSynchronizationContext => System.Threading.SynchronizationContext.Current == null ? Dummy : new NoSyncContext(); + + /// + /// An instance of the Dummy IDispoable. + /// + /// + internal static System.IDisposable Dummy = new DummyDisposable(); + + /// + /// An IDisposable that does absolutely nothing. + /// + internal class DummyDisposable : System.IDisposable + { + public void Dispose() + { + } + } + /// + /// An IDisposable that saves the SynchronizationContext,sets it to null and + /// restores it to the original upon Dispose(). + /// + /// NOTE: This is designed to be less invasive than using .ConfigureAwait(false) + /// on every single await in library code (ie, places where we know we don't need + /// to continue in the same context as we went async) + /// + internal class NoSyncContext : System.IDisposable + { + private System.Threading.SynchronizationContext original = System.Threading.SynchronizationContext.Current; + internal NoSyncContext() + { + System.Threading.SynchronizationContext.SetSynchronizationContext(null); + } + public void Dispose() => System.Threading.SynchronizationContext.SetSynchronizationContext(original); + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Helpers/Extensions/StringBuilderExtensions.cs b/src/CostManagement/generated/runtime/Helpers/Extensions/StringBuilderExtensions.cs new file mode 100644 index 000000000000..22398d16eaba --- /dev/null +++ b/src/CostManagement/generated/runtime/Helpers/Extensions/StringBuilderExtensions.cs @@ -0,0 +1,23 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System.Text; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + internal static class StringBuilderExtensions + { + /// + /// Extracts the buffered value and resets the buffer + /// + internal static string Extract(this StringBuilder builder) + { + var text = builder.ToString(); + + builder.Clear(); + + return text; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Helpers/Extensions/TypeExtensions.cs b/src/CostManagement/generated/runtime/Helpers/Extensions/TypeExtensions.cs new file mode 100644 index 000000000000..3427f611b3cf --- /dev/null +++ b/src/CostManagement/generated/runtime/Helpers/Extensions/TypeExtensions.cs @@ -0,0 +1,61 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + internal static class TypeExtensions + { + internal static bool IsNullable(this Type type) => + type.IsGenericType && type.GetGenericTypeDefinition().Equals(typeof(Nullable<>)); + + internal static Type GetOpenGenericInterface(this Type candidateType, Type openGenericInterfaceType) + { + + if (candidateType.IsGenericType && candidateType.GetGenericTypeDefinition() == openGenericInterfaceType) + { + return candidateType; + } + + // Check if it references it's own converter.... + + foreach (Type interfaceType in candidateType.GetInterfaces()) + { + if (interfaceType.IsGenericType + && interfaceType.GetGenericTypeDefinition().Equals(openGenericInterfaceType)) + { + return interfaceType; + } + } + + return null; + } + + // Author: Sebastian Good + // http://stackoverflow.com/questions/503263/how-to-determine-if-a-type-implements-a-specific-generic-interface-type + internal static bool ImplementsOpenGenericInterface(this Type candidateType, Type openGenericInterfaceType) + { + if (candidateType.Equals(openGenericInterfaceType)) + { + return true; + } + + if (candidateType.IsGenericType && candidateType.GetGenericTypeDefinition().Equals(openGenericInterfaceType)) + { + return true; + } + + foreach (Type i in candidateType.GetInterfaces()) + { + if (i.IsGenericType && i.ImplementsOpenGenericInterface(openGenericInterfaceType)) + { + return true; + } + } + + return false; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Helpers/Seperator.cs b/src/CostManagement/generated/runtime/Helpers/Seperator.cs new file mode 100644 index 000000000000..dfa4e994bd86 --- /dev/null +++ b/src/CostManagement/generated/runtime/Helpers/Seperator.cs @@ -0,0 +1,11 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + internal static class Seperator + { + internal static readonly char[] Dash = { '-' }; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Helpers/TypeDetails.cs b/src/CostManagement/generated/runtime/Helpers/TypeDetails.cs new file mode 100644 index 000000000000..d0b5ccfe9334 --- /dev/null +++ b/src/CostManagement/generated/runtime/Helpers/TypeDetails.cs @@ -0,0 +1,116 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; +using System.Collections; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Reflection; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + + + + internal class TypeDetails + { + private readonly Type info; + + internal TypeDetails(Type info) + { + this.info = info ?? throw new ArgumentNullException(nameof(info)); + } + + internal Type NonNullType { get; set; } + + internal object DefaultValue { get; set; } + + internal bool IsNullable { get; set; } + + internal bool IsList { get; set; } + + internal bool IsStringLike { get; set; } + + internal bool IsEnum => info.IsEnum; + + internal bool IsArray => info.IsArray; + + internal bool IsValueType => info.IsValueType; + + internal Type ElementType { get; set; } + + internal IJsonConverter JsonConverter { get; set; } + + #region Creation + + private static readonly ConcurrentDictionary cache = new ConcurrentDictionary(); + + internal static TypeDetails Get() => Get(typeof(T)); + + internal static TypeDetails Get(Type type) => cache.GetOrAdd(type, Create); + + private static TypeDetails Create(Type type) + { + var isGenericList = !type.IsPrimitive && type.ImplementsOpenGenericInterface(typeof(IList<>)); + var isList = !type.IsPrimitive && (isGenericList || typeof(IList).IsAssignableFrom(type)); + + var isNullable = type.IsNullable(); + + Type elementType; + + if (type.IsArray) + { + elementType = type.GetElementType(); + } + else if (isGenericList) + { + var iList = type.GetOpenGenericInterface(typeof(IList<>)); + + elementType = iList.GetGenericArguments()[0]; + } + else + { + elementType = null; + } + + var nonNullType = isNullable ? type.GetGenericArguments()[0] : type; + + var isStringLike = false; + + IJsonConverter converter; + + var jsonConverterAttribute = type.GetCustomAttribute(); + + if (jsonConverterAttribute != null) + { + converter = jsonConverterAttribute.Converter; + } + else if (nonNullType.IsEnum) + { + converter = new EnumConverter(nonNullType); + } + else if (JsonConverterFactory.Instances.TryGetValue(nonNullType, out converter)) + { + } + else if (StringLikeHelper.IsStringLike(nonNullType)) + { + isStringLike = true; + + converter = new StringLikeConverter(nonNullType); + } + + return new TypeDetails(nonNullType) { + NonNullType = nonNullType, + DefaultValue = type.IsValueType ? Activator.CreateInstance(type) : null, + IsNullable = isNullable, + IsList = isList, + IsStringLike = isStringLike, + ElementType = elementType, + JsonConverter = converter + }; + } + + #endregion + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Helpers/XHelper.cs b/src/CostManagement/generated/runtime/Helpers/XHelper.cs new file mode 100644 index 000000000000..3f888db77189 --- /dev/null +++ b/src/CostManagement/generated/runtime/Helpers/XHelper.cs @@ -0,0 +1,75 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + internal static class XHelper + { + internal static JsonNode Create(JsonType type, TypeCode code, object value) + { + switch (type) + { + case JsonType.Binary : return new XBinary((byte[])value); + case JsonType.Boolean : return new JsonBoolean((bool)value); + case JsonType.Number : return new JsonNumber(value.ToString()); + case JsonType.String : return new JsonString((string)value); + } + + throw new Exception($"JsonType '{type}' does not have a fast conversion"); + } + + internal static bool TryGetElementType(TypeCode code, out JsonType type) + { + switch (code) + { + case TypeCode.Boolean : type = JsonType.Boolean; return true; + case TypeCode.Byte : type = JsonType.Number; return true; + case TypeCode.DateTime : type = JsonType.Date; return true; + case TypeCode.Decimal : type = JsonType.Number; return true; + case TypeCode.Double : type = JsonType.Number; return true; + case TypeCode.Empty : type = JsonType.Null; return true; + case TypeCode.Int16 : type = JsonType.Number; return true; + case TypeCode.Int32 : type = JsonType.Number; return true; + case TypeCode.Int64 : type = JsonType.Number; return true; + case TypeCode.SByte : type = JsonType.Number; return true; + case TypeCode.Single : type = JsonType.Number; return true; + case TypeCode.String : type = JsonType.String; return true; + case TypeCode.UInt16 : type = JsonType.Number; return true; + case TypeCode.UInt32 : type = JsonType.Number; return true; + case TypeCode.UInt64 : type = JsonType.Number; return true; + } + + type = default; + + return false; + } + + internal static JsonType GetElementType(TypeCode code) + { + switch (code) + { + case TypeCode.Boolean : return JsonType.Boolean; + case TypeCode.Byte : return JsonType.Number; + case TypeCode.DateTime : return JsonType.Date; + case TypeCode.Decimal : return JsonType.Number; + case TypeCode.Double : return JsonType.Number; + case TypeCode.Empty : return JsonType.Null; + case TypeCode.Int16 : return JsonType.Number; + case TypeCode.Int32 : return JsonType.Number; + case TypeCode.Int64 : return JsonType.Number; + case TypeCode.SByte : return JsonType.Number; + case TypeCode.Single : return JsonType.Number; + case TypeCode.String : return JsonType.String; + case TypeCode.UInt16 : return JsonType.Number; + case TypeCode.UInt32 : return JsonType.Number; + case TypeCode.UInt64 : return JsonType.Number; + default : return JsonType.Object; + } + + throw new Exception($"TypeCode '{code}' does not have a fast converter"); + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/HttpPipeline.cs b/src/CostManagement/generated/runtime/HttpPipeline.cs new file mode 100644 index 000000000000..4e91d94419e6 --- /dev/null +++ b/src/CostManagement/generated/runtime/HttpPipeline.cs @@ -0,0 +1,88 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime +{ + using System.Net.Http; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + using System.Collections; + using System.Linq; + + using GetEventData = System.Func; + using NextDelegate = System.Func, System.Threading.Tasks.Task>, System.Threading.Tasks.Task>; + + using SignalDelegate = System.Func, System.Threading.Tasks.Task>; + using GetParameterDelegate = System.Func, string, object>; + using SendAsyncStepDelegate = System.Func, System.Threading.Tasks.Task>, System.Func, System.Threading.Tasks.Task>, System.Threading.Tasks.Task>, System.Threading.Tasks.Task>; + using PipelineChangeDelegate = System.Action, System.Threading.Tasks.Task>, System.Func, System.Threading.Tasks.Task>, System.Threading.Tasks.Task>, System.Threading.Tasks.Task>>; + using ModuleLoadPipelineDelegate = System.Action, System.Threading.Tasks.Task>, System.Func, System.Threading.Tasks.Task>, System.Threading.Tasks.Task>, System.Threading.Tasks.Task>>, System.Action, System.Threading.Tasks.Task>, System.Func, System.Threading.Tasks.Task>, System.Threading.Tasks.Task>, System.Threading.Tasks.Task>>>; + using NewRequestPipelineDelegate = System.Action, System.Action, System.Threading.Tasks.Task>, System.Func, System.Threading.Tasks.Task>, System.Threading.Tasks.Task>, System.Threading.Tasks.Task>>, System.Action, System.Threading.Tasks.Task>, System.Func, System.Threading.Tasks.Task>, System.Threading.Tasks.Task>, System.Threading.Tasks.Task>>>; + +/* + public class DelegateBasedEventListener : IEventListener + { + private EventListenerDelegate _listener; + public DelegateBasedEventListener(EventListenerDelegate listener) + { + _listener = listener; + } + public CancellationToken Token => CancellationToken.None; + public System.Action Cancel => () => { }; + + + public Task Signal(string id, CancellationToken token, GetEventData createMessage) + { + return _listener(id, token, () => createMessage()); + } + } +*/ + /// + /// This is a necessary extension to the SendAsyncFactory to support the 'generic' delegate format. + /// + public partial class SendAsyncFactory + { + /// + /// This translates a generic-defined delegate for a listener into one that fits our ISendAsync pattern. + /// (Provided to support out-of-module delegation for Azure Cmdlets) + /// + /// The Pipeline Step as a delegate + public SendAsyncFactory(SendAsyncStepDelegate step) => this.implementation = (request, listener, next) => + step( + request, + listener.Token, + listener.Cancel, + (id, token, getEventData) => listener.Signal(id, token, () => { + var data = EventDataConverter.ConvertFrom( getEventData() ) as EventData; + data.Id = id; + data.Cancel = listener.Cancel; + data.RequestMessage = request; + return data; + }), + (req, token, cancel, listenerDelegate) => next.SendAsync(req, listener)); + } + + public partial class HttpPipeline : ISendAsync + { + public HttpPipeline Append(SendAsyncStepDelegate item) + { + if (item != null) + { + Append(new SendAsyncFactory(item)); + } + return this; + } + + public HttpPipeline Prepend(SendAsyncStepDelegate item) + { + if (item != null) + { + Prepend(new SendAsyncFactory(item)); + } + return this; + } + } +} diff --git a/src/CostManagement/generated/runtime/HttpPipelineMocking.ps1 b/src/CostManagement/generated/runtime/HttpPipelineMocking.ps1 new file mode 100644 index 000000000000..5a9de0253df3 --- /dev/null +++ b/src/CostManagement/generated/runtime/HttpPipelineMocking.ps1 @@ -0,0 +1,110 @@ +$ErrorActionPreference = "Stop" + +# get the recording path +if (-not $TestRecordingFile) { + $TestRecordingFile = Join-Path $PSScriptRoot 'recording.json' +} + +# create the Http Pipeline Recorder +$Mock = New-Object -Type Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PipelineMock $TestRecordingFile + +# set the recorder to the appropriate mode (default to 'live') +Write-Host -ForegroundColor Green "Running '$TestMode' mode..." +switch ($TestMode) { + 'record' { + Write-Host -ForegroundColor Green "Recording to $TestRecordingFile" + $Mock.SetRecord() + $null = erase -ea 0 $TestRecordingFile + } + 'playback' { + if (-not (Test-Path $TestRecordingFile)) { + Write-Host -fore:yellow "Recording file '$TestRecordingFile' is not present. Tests expecting recorded responses will fail" + } else { + Write-Host -ForegroundColor Green "Using recording $TestRecordingFile" + } + $Mock.SetPlayback() + $Mock.ForceResponseHeaders["Retry-After"] = "0"; + } + default: { + $Mock.SetLive() + } +} + +# overrides for Pester Describe/Context/It + +function Describe( + [Parameter(Mandatory = $true, Position = 0)] + [string] $Name, + + [Alias('Tags')] + [string[]] $Tag = @(), + + [Parameter(Position = 1)] + [ValidateNotNull()] + [ScriptBlock] $Fixture = $(Throw "No test script block is provided. (Have you put the open curly brace on the next line?)") +) { + $Mock.PushDescription($Name) + try { + return pester\Describe -Name $Name -Tag $Tag -Fixture $fixture + } + finally { + $Mock.PopDescription() + } +} + +function Context( + [Parameter(Mandatory = $true, Position = 0)] + [string] $Name, + + [Alias('Tags')] + [string[]] $Tag = @(), + + [Parameter(Position = 1)] + [ValidateNotNull()] + [ScriptBlock] $Fixture = $(Throw "No test script block is provided. (Have you put the open curly brace on the next line?)") +) { + $Mock.PushContext($Name) + try { + return pester\Context -Name $Name -Tag $Tag -Fixture $fixture + } + finally { + $Mock.PopContext() + } +} + +function It { + [CmdletBinding(DefaultParameterSetName = 'Normal')] + param( + [Parameter(Mandatory = $true, Position = 0)] + [string]$Name, + + [Parameter(Position = 1)] + [ScriptBlock] $Test = { }, + + [System.Collections.IDictionary[]] $TestCases, + + [Parameter(ParameterSetName = 'Pending')] + [Switch] $Pending, + + [Parameter(ParameterSetName = 'Skip')] + [Alias('Ignore')] + [Switch] $Skip + ) + $Mock.PushScenario($Name) + + try { + if ($skip) { + return pester\It -Name $Name -Test $Test -TestCases $TestCases -Skip + } + if ($pending) { + return pester\It -Name $Name -Test $Test -TestCases $TestCases -Pending + } + return pester\It -Name $Name -Test $Test -TestCases $TestCases + } + finally { + $null = $Mock.PopScenario() + } +} + +# set the HttpPipelineAppend for all the cmdlets +$PSDefaultParameterValues["*:HttpPipelinePrepend"] = $Mock diff --git a/src/CostManagement/generated/runtime/IAssociativeArray.cs b/src/CostManagement/generated/runtime/IAssociativeArray.cs new file mode 100644 index 000000000000..c7367086b998 --- /dev/null +++ b/src/CostManagement/generated/runtime/IAssociativeArray.cs @@ -0,0 +1,21 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime +{ + /// A subset of IDictionary that doesn't implement IEnumerable or IDictionary to work around PowerShell's aggressive formatter + public interface IAssociativeArray + { + System.Collections.Generic.IEnumerable Keys { get; } + System.Collections.Generic.IEnumerable Values { get; } + System.Collections.Generic.IDictionary AdditionalProperties { get; } + T this[string index] { get; set; } + int Count { get; } + void Add(string key, T value); + bool ContainsKey(string key); + bool Remove(string key); + bool TryGetValue(string key, out T value); + void Clear(); + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/IHeaderSerializable.cs b/src/CostManagement/generated/runtime/IHeaderSerializable.cs new file mode 100644 index 000000000000..e2f425cec9cf --- /dev/null +++ b/src/CostManagement/generated/runtime/IHeaderSerializable.cs @@ -0,0 +1,14 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +using System; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime +{ + public interface IHeaderSerializable + { + void ReadHeaders(global::System.Net.Http.Headers.HttpResponseHeaders headers); + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/ISendAsync.cs b/src/CostManagement/generated/runtime/ISendAsync.cs new file mode 100644 index 000000000000..3e0b67474abb --- /dev/null +++ b/src/CostManagement/generated/runtime/ISendAsync.cs @@ -0,0 +1,296 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime +{ + using System.Net.Http; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + using System.Collections; + using System.Linq; + + /// + /// The interface for sending an HTTP request across the wire. + /// + public interface ISendAsync + { + Task SendAsync(HttpRequestMessage request, IEventListener callback); + } + + public class SendAsyncTerminalFactory : ISendAsyncTerminalFactory, ISendAsync + { + SendAsync implementation; + + public SendAsyncTerminalFactory(SendAsync implementation) => this.implementation = implementation; + public SendAsyncTerminalFactory(ISendAsync implementation) => this.implementation = implementation.SendAsync; + public ISendAsync Create() => this; + public Task SendAsync(HttpRequestMessage request, IEventListener callback) => implementation(request, callback); + } + + public partial class SendAsyncFactory : ISendAsyncFactory + { + public class Sender : ISendAsync + { + internal ISendAsync next; + internal SendAsyncStep implementation; + + public Task SendAsync(HttpRequestMessage request, IEventListener callback) => implementation(request, callback, next); + } + SendAsyncStep implementation; + + public SendAsyncFactory(SendAsyncStep implementation) => this.implementation = implementation; + public ISendAsync Create(ISendAsync next) => new Sender { next = next, implementation = implementation }; + + } + + public class HttpClientFactory : ISendAsyncTerminalFactory, ISendAsync + { + HttpClient client; + public HttpClientFactory() : this(new HttpClient()) + { + } + public HttpClientFactory(HttpClient client) => this.client = client; + public ISendAsync Create() => this; + + public Task SendAsync(HttpRequestMessage request, IEventListener callback) => client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, callback.Token); + } + + public interface ISendAsyncFactory + { + ISendAsync Create(ISendAsync next); + } + + public interface ISendAsyncTerminalFactory + { + ISendAsync Create(); + } + + public partial class HttpPipeline : ISendAsync + { + private ISendAsync pipeline; + private ISendAsyncTerminalFactory terminal; + private List steps = new List(); + + public HttpPipeline() : this(new HttpClientFactory()) + { + } + + public HttpPipeline(ISendAsyncTerminalFactory terminalStep) + { + if (terminalStep == null) + { + throw new System.ArgumentNullException(nameof(terminalStep), "Terminal Step Factory in HttpPipeline may not be null"); + } + TerminalFactory = terminalStep; + } + + /// + /// Returns an HttpPipeline with the current state of this pipeline. + /// + public HttpPipeline Clone() => new HttpPipeline(terminal) { steps = this.steps.ToList(), pipeline = this.pipeline }; + + public ISendAsyncTerminalFactory TerminalFactory + { + get => terminal; + set + { + if (value == null) + { + throw new System.ArgumentNullException("TerminalFactory in HttpPipeline may not be null"); + } + terminal = value; + } + } + + public ISendAsync Pipeline + { + get + { + // if the pipeline has been created and not invalidated, return it. + if (this.pipeline != null) + { + return this.pipeline; + } + + // create the pipeline from scratch. + var next = terminal.Create(); + foreach (var factory in steps) + { + // skip factories that return null. + next = factory.Create(next) ?? next; + } + return this.pipeline = next; + } + } + + public int Count => steps.Count; + + public HttpPipeline Prepend(ISendAsyncFactory item) + { + if (item != null) + { + steps.Add(item); + pipeline = null; + } + return this; + } + + public HttpPipeline Append(SendAsyncStep item) + { + if (item != null) + { + Append(new SendAsyncFactory(item)); + } + return this; + } + + public HttpPipeline Prepend(SendAsyncStep item) + { + if (item != null) + { + Prepend(new SendAsyncFactory(item)); + } + return this; + } + public HttpPipeline Append(IEnumerable items) + { + if (items != null) + { + foreach (var item in items) + { + Append(new SendAsyncFactory(item)); + } + } + return this; + } + + public HttpPipeline Prepend(IEnumerable items) + { + if (items != null) + { + foreach (var item in items) + { + Prepend(new SendAsyncFactory(item)); + } + } + return this; + } + + public HttpPipeline Append(ISendAsyncFactory item) + { + if (item != null) + { + steps.Insert(0, item); + pipeline = null; + } + return this; + } + public HttpPipeline Prepend(IEnumerable items) + { + if (items != null) + { + foreach (var item in items) + { + Prepend(item); + } + } + return this; + } + + public HttpPipeline Append(IEnumerable items) + { + if (items != null) + { + foreach (var item in items) + { + Append(item); + } + } + return this; + } + + // you can use this as the ISendAsync Implementation + public Task SendAsync(HttpRequestMessage request, IEventListener callback) => Pipeline.SendAsync(request, callback); + } + + internal static partial class Extensions + { + internal static HttpRequestMessage CloneAndDispose(this HttpRequestMessage original, System.Uri requestUri = null, System.Net.Http.HttpMethod method = null) + { + using (original) + { + return original.Clone(requestUri, method); + } + } + + internal static Task CloneWithContentAndDispose(this HttpRequestMessage original, System.Uri requestUri = null, System.Net.Http.HttpMethod method = null) + { + using (original) + { + return original.CloneWithContent(requestUri, method); + } + } + + /// + /// Clones an HttpRequestMessage (without the content) + /// + /// Original HttpRequestMessage (Will be diposed before returning) + /// A clone of the HttpRequestMessage + internal static HttpRequestMessage Clone(this HttpRequestMessage original, System.Uri requestUri = null, System.Net.Http.HttpMethod method = null) + { + var clone = new HttpRequestMessage + { + Method = method ?? original.Method, + RequestUri = requestUri ?? original.RequestUri, + Version = original.Version, + }; + + foreach (KeyValuePair prop in original.Properties) + { + clone.Properties.Add(prop); + } + + foreach (KeyValuePair> header in original.Headers) + { + /* + **temporarily skip cloning telemetry related headers** + clone.Headers.TryAddWithoutValidation(header.Key, header.Value); + */ + if (!"x-ms-unique-id".Equals(header.Key) && !"x-ms-client-request-id".Equals(header.Key) && !"CommandName".Equals(header.Key) && !"FullCommandName".Equals(header.Key) && !"ParameterSetName".Equals(header.Key) && !"User-Agent".Equals(header.Key)) + { + clone.Headers.TryAddWithoutValidation(header.Key, header.Value); + } + } + + return clone; + } + + /// + /// Clones an HttpRequestMessage (including the content stream and content headers) + /// + /// Original HttpRequestMessage (Will be diposed before returning) + /// A clone of the HttpRequestMessage + internal static async Task CloneWithContent(this HttpRequestMessage original, System.Uri requestUri = null, System.Net.Http.HttpMethod method = null) + { + var clone = original.Clone(requestUri, method); + var stream = new System.IO.MemoryStream(); + if (original.Content != null) + { + await original.Content.CopyToAsync(stream).ConfigureAwait(false); + stream.Position = 0; + clone.Content = new StreamContent(stream); + if (original.Content.Headers != null) + { + foreach (var h in original.Content.Headers) + { + clone.Content.Headers.Add(h.Key, h.Value); + } + } + } + return clone; + } + } +} diff --git a/src/CostManagement/generated/runtime/InfoAttribute.cs b/src/CostManagement/generated/runtime/InfoAttribute.cs new file mode 100644 index 000000000000..b6c01cb49533 --- /dev/null +++ b/src/CostManagement/generated/runtime/InfoAttribute.cs @@ -0,0 +1,34 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime +{ + using System; + + [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Class)] + public class InfoAttribute : Attribute + { + public bool Required { get; set; } = false; + public bool ReadOnly { get; set; } = false; + public Type[] PossibleTypes { get; set; } = new Type[0]; + public string Description { get; set; } = ""; + public string SerializedName { get; set; } = ""; + } + + [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)] + public class CompleterInfoAttribute : Attribute + { + public string Script { get; set; } = ""; + public string Name { get; set; } = ""; + public string Description { get; set; } = ""; + } + + [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)] + public class DefaultInfoAttribute : Attribute + { + public string Script { get; set; } = ""; + public string Name { get; set; } = ""; + public string Description { get; set; } = ""; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Iso/IsoDate.cs b/src/CostManagement/generated/runtime/Iso/IsoDate.cs new file mode 100644 index 000000000000..32a0fe05a2d5 --- /dev/null +++ b/src/CostManagement/generated/runtime/Iso/IsoDate.cs @@ -0,0 +1,214 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; +using System.Text; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + internal struct IsoDate + { + internal int Year { get; set; } // 0-3000 + + internal int Month { get; set; } // 1-12 + + internal int Day { get; set; } // 1-31 + + internal int Hour { get; set; } // 0-24 + + internal int Minute { get; set; } // 0-60 (60 is a special case) + + internal int Second { get; set; } // 0-60 (60 is used for leap seconds) + + internal double Millisecond { get; set; } // 0-999.9... + + internal TimeSpan Offset { get; set; } + + internal DateTimeKind Kind { get; set; } + + internal TimeSpan TimeOfDay => new TimeSpan(Hour, Minute, Second); + + internal DateTime ToDateTime() + { + if (Kind == DateTimeKind.Utc || Offset == TimeSpan.Zero) + { + return new DateTime(Year, Month, Day, Hour, Minute, Second, (int)Millisecond, DateTimeKind.Utc); + } + + return ToDateTimeOffset().DateTime; + } + + internal DateTimeOffset ToDateTimeOffset() + { + return new DateTimeOffset( + Year, + Month, + Day, + Hour, + Minute, + Second, + (int)Millisecond, + Offset + ); + } + + internal DateTime ToUtcDateTime() + { + return ToDateTimeOffset().UtcDateTime; + } + + public override string ToString() + { + var sb = new StringBuilder(); + + // yyyy-MM-dd + sb.Append($"{Year}-{Month:00}-{Day:00}"); + + if (TimeOfDay > new TimeSpan(0)) + { + sb.Append($"T{Hour:00}:{Minute:00}"); + + if (TimeOfDay.Seconds > 0) + { + sb.Append($":{Second:00}"); + } + } + + if (Offset.Ticks == 0) + { + sb.Append('Z'); // UTC + } + else + { + if (Offset.Ticks >= 0) + { + sb.Append('+'); + } + + sb.Append($"{Offset.Hours:00}:{Offset.Minutes:00}"); + } + + return sb.ToString(); + } + + internal static IsoDate FromDateTimeOffset(DateTimeOffset date) + { + return new IsoDate { + Year = date.Year, + Month = date.Month, + Day = date.Day, + Hour = date.Hour, + Minute = date.Minute, + Second = date.Second, + Offset = date.Offset, + Kind = date.Offset == TimeSpan.Zero ? DateTimeKind.Utc : DateTimeKind.Unspecified + }; + } + + private static readonly char[] timeSeperators = { ':', '.' }; + + internal static IsoDate Parse(string text) + { + var tzIndex = -1; + var timeIndex = text.IndexOf('T'); + + var builder = new IsoDate { Day = 1, Month = 1 }; + + // TODO: strip the time zone offset off the end + string dateTime = text; + string timeZone = null; + + if (dateTime.IndexOf('Z') > -1) + { + tzIndex = dateTime.LastIndexOf('Z'); + + builder.Kind = DateTimeKind.Utc; + } + else if (dateTime.LastIndexOf('+') > 10) + { + tzIndex = dateTime.LastIndexOf('+'); + } + else if (dateTime.LastIndexOf('-') > 10) + { + tzIndex = dateTime.LastIndexOf('-'); + } + + if (tzIndex > -1) + { + timeZone = dateTime.Substring(tzIndex); + dateTime = dateTime.Substring(0, tzIndex); + } + + string date = (timeIndex == -1) ? dateTime : dateTime.Substring(0, timeIndex); + + var dateParts = date.Split(Seperator.Dash); // '-' + + for (int i = 0; i < dateParts.Length; i++) + { + var part = dateParts[i]; + + switch (i) + { + case 0: builder.Year = int.Parse(part); break; + case 1: builder.Month = int.Parse(part); break; + case 2: builder.Day = int.Parse(part); break; + } + } + + if (timeIndex > -1) + { + string[] timeParts = dateTime.Substring(timeIndex + 1).Split(timeSeperators); + + for (int i = 0; i < timeParts.Length; i++) + { + var part = timeParts[i]; + + switch (i) + { + case 0: builder.Hour = int.Parse(part); break; + case 1: builder.Minute = int.Parse(part); break; + case 2: builder.Second = int.Parse(part); break; + case 3: builder.Millisecond = double.Parse("0." + part) * 1000; break; + } + } + } + + if (timeZone != null && timeZone != "Z") + { + var hours = int.Parse(timeZone.Substring(1, 2)); + var minutes = int.Parse(timeZone.Substring(4, 2)); + + if (timeZone[0] == '-') + { + hours = -hours; + minutes = -minutes; + } + + builder.Offset = new TimeSpan(hours, minutes, 0); + } + + return builder; + } + } + + /* + YYYY # eg 1997 + YYYY-MM # eg 1997-07 + YYYY-MM-DD # eg 1997-07-16 + YYYY-MM-DDThh:mmTZD # eg 1997-07-16T19:20+01:00 + YYYY-MM-DDThh:mm:ssTZD # eg 1997-07-16T19:20:30+01:00 + YYYY-MM-DDThh:mm:ss.sTZD # eg 1997-07-16T19:20:30.45+01:00 + + where: + + YYYY = four-digit year + MM = two-digit month (01=January, etc.) + DD = two-digit day of month (01 through 31) + hh = two digits of hour (00 through 23) (am/pm NOT allowed) + mm = two digits of minute (00 through 59) + ss = two digits of second (00 through 59) + s = one or more digits representing a decimal fraction of a second + TZD = time zone designator (Z or +hh:mm or -hh:mm) + */ +} diff --git a/src/CostManagement/generated/runtime/JsonType.cs b/src/CostManagement/generated/runtime/JsonType.cs new file mode 100644 index 000000000000..d605c8b473d9 --- /dev/null +++ b/src/CostManagement/generated/runtime/JsonType.cs @@ -0,0 +1,18 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + internal enum JsonType + { + Null = 0, + Object = 1, + Array = 2, + Binary = 3, + Boolean = 4, + Date = 5, + Number = 6, + String = 7 + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Method.cs b/src/CostManagement/generated/runtime/Method.cs new file mode 100644 index 000000000000..fcfc98f97de1 --- /dev/null +++ b/src/CostManagement/generated/runtime/Method.cs @@ -0,0 +1,19 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime +{ + internal static class Method + { + internal static System.Net.Http.HttpMethod Get = System.Net.Http.HttpMethod.Get; + internal static System.Net.Http.HttpMethod Put = System.Net.Http.HttpMethod.Put; + internal static System.Net.Http.HttpMethod Head = System.Net.Http.HttpMethod.Head; + internal static System.Net.Http.HttpMethod Post = System.Net.Http.HttpMethod.Post; + internal static System.Net.Http.HttpMethod Delete = System.Net.Http.HttpMethod.Delete; + internal static System.Net.Http.HttpMethod Options = System.Net.Http.HttpMethod.Options; + internal static System.Net.Http.HttpMethod Trace = System.Net.Http.HttpMethod.Trace; + internal static System.Net.Http.HttpMethod Patch = new System.Net.Http.HttpMethod("PATCH"); + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Models/JsonMember.cs b/src/CostManagement/generated/runtime/Models/JsonMember.cs new file mode 100644 index 000000000000..1e73a542f958 --- /dev/null +++ b/src/CostManagement/generated/runtime/Models/JsonMember.cs @@ -0,0 +1,83 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; +using System.Reflection; +using System.Runtime.Serialization; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + + + internal sealed class JsonMember + { + private readonly TypeDetails type; + + private readonly Func getter; + private readonly Action setter; + + internal JsonMember(PropertyInfo property, int defaultOrder) + { + getter = property.GetValue; + setter = property.SetValue; + + var dataMember = property.GetCustomAttribute(); + + Name = dataMember?.Name ?? property.Name; + Order = dataMember?.Order ?? defaultOrder; + EmitDefaultValue = dataMember?.EmitDefaultValue ?? true; + + this.type = TypeDetails.Get(property.PropertyType); + + CanRead = property.CanRead; + } + + internal JsonMember(FieldInfo field, int defaultOrder) + { + getter = field.GetValue; + setter = field.SetValue; + + var dataMember = field.GetCustomAttribute(); + + Name = dataMember?.Name ?? field.Name; + Order = dataMember?.Order ?? defaultOrder; + EmitDefaultValue = dataMember?.EmitDefaultValue ?? true; + + this.type = TypeDetails.Get(field.FieldType); + + CanRead = true; + } + + internal string Name { get; } + + internal int Order { get; } + + internal TypeDetails TypeDetails => type; + + internal Type Type => type.NonNullType; + + internal bool IsList => type.IsList; + + // Arrays, Sets, ... + internal Type ElementType => type.ElementType; + + internal IJsonConverter Converter => type.JsonConverter; + + internal bool EmitDefaultValue { get; } + + internal bool IsStringLike => type.IsStringLike; + + internal object DefaultValue => type.DefaultValue; + + internal bool CanRead { get; } + + #region Helpers + + internal object GetValue(object instance) => getter(instance); + + internal void SetValue(object instance, object value) => setter(instance, value); + + #endregion + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Models/JsonModel.cs b/src/CostManagement/generated/runtime/Models/JsonModel.cs new file mode 100644 index 000000000000..ede77bcfcbec --- /dev/null +++ b/src/CostManagement/generated/runtime/Models/JsonModel.cs @@ -0,0 +1,89 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using System.Reflection; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + internal class JsonModel + { + private Dictionary map; + private readonly object _sync = new object(); + + private JsonModel(Type type, List members) + { + Type = type ?? throw new ArgumentNullException(nameof(type)); + Members = members ?? throw new ArgumentNullException(nameof(members)); + } + + internal string Name => Type.Name; + + internal Type Type { get; } + + internal List Members { get; } + + internal JsonMember this[string name] + { + get + { + if (map == null) + { + lock (_sync) + { + if (map == null) + { + map = new Dictionary(); + + foreach (JsonMember m in Members) + { + map[m.Name.ToLower()] = m; + } + } + } + } + + + map.TryGetValue(name.ToLower(), out JsonMember member); + + return member; + } + } + + internal static JsonModel FromType(Type type) + { + var members = new List(); + + int i = 0; + + // BindingFlags.Instance | BindingFlags.Public + + foreach (var member in type.GetFields()) + { + if (member.IsStatic) continue; + + if (member.IsDefined(typeof(IgnoreDataMemberAttribute))) continue; + + members.Add(new JsonMember(member, i)); + + i++; + } + + foreach (var member in type.GetProperties(BindingFlags.Public | BindingFlags.Instance)) + { + if (member.IsDefined(typeof(IgnoreDataMemberAttribute))) continue; + + members.Add(new JsonMember(member, i)); + + i++; + } + + members.Sort((a, b) => a.Order.CompareTo(b.Order)); // inline sort + + return new JsonModel(type, members); + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Models/JsonModelCache.cs b/src/CostManagement/generated/runtime/Models/JsonModelCache.cs new file mode 100644 index 000000000000..eb5ef6f5c541 --- /dev/null +++ b/src/CostManagement/generated/runtime/Models/JsonModelCache.cs @@ -0,0 +1,19 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; +using System.Runtime.CompilerServices; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + internal static class JsonModelCache + { + private static readonly ConditionalWeakTable cache + = new ConditionalWeakTable(); + + internal static JsonModel Get(Type type) => cache.GetValue(type, Create); + + private static JsonModel Create(Type type) => JsonModel.FromType(type); + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Nodes/Collections/JsonArray.cs b/src/CostManagement/generated/runtime/Nodes/Collections/JsonArray.cs new file mode 100644 index 000000000000..9a9729797c28 --- /dev/null +++ b/src/CostManagement/generated/runtime/Nodes/Collections/JsonArray.cs @@ -0,0 +1,65 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + public abstract partial class JsonArray : JsonNode, IEnumerable + { + internal override JsonType Type => JsonType.Array; + + internal abstract JsonType? ElementType { get; } + + public abstract int Count { get; } + + internal virtual bool IsSet => false; + + internal bool IsEmpty => Count == 0; + + #region IEnumerable + + IEnumerator IEnumerable.GetEnumerator() + { + throw new NotImplementedException(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + throw new NotImplementedException(); + } + + #endregion + + #region Static Helpers + + internal static JsonArray Create(short[] values) + => new XImmutableArray(values); + + internal static JsonArray Create(int[] values) + => new XImmutableArray(values); + + internal static JsonArray Create(long[] values) + => new XImmutableArray(values); + + internal static JsonArray Create(decimal[] values) + => new XImmutableArray(values); + + internal static JsonArray Create(float[] values) + => new XImmutableArray(values); + + internal static JsonArray Create(string[] values) + => new XImmutableArray(values); + + internal static JsonArray Create(XBinary[] values) + => new XImmutableArray(values); + + #endregion + + internal static new JsonArray Parse(string text) + => (JsonArray)JsonNode.Parse(text); + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Nodes/Collections/XImmutableArray.cs b/src/CostManagement/generated/runtime/Nodes/Collections/XImmutableArray.cs new file mode 100644 index 000000000000..511890d012a2 --- /dev/null +++ b/src/CostManagement/generated/runtime/Nodes/Collections/XImmutableArray.cs @@ -0,0 +1,62 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + internal sealed class XImmutableArray : JsonArray, IEnumerable + { + private readonly T[] values; + private readonly JsonType elementType; + private readonly TypeCode elementCode; + + internal XImmutableArray(T[] values) + { + this.values = values ?? throw new ArgumentNullException(nameof(values)); + this.elementCode = System.Type.GetTypeCode(typeof(T)); + this.elementType = XHelper.GetElementType(this.elementCode); + } + + public override JsonNode this[int index] => + XHelper.Create(elementType, elementCode, values[index]); + + internal override JsonType? ElementType => elementType; + + public override int Count => values.Length; + + public bool IsReadOnly => true; + + #region IEnumerable Members + + IEnumerator IEnumerable.GetEnumerator() + { + foreach (T value in values) + { + yield return XHelper.Create(elementType, elementCode, value); + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + foreach (T value in values) + { + yield return XHelper.Create(elementType, elementCode, value); + } + } + + #endregion + + #region Static Constructor + + internal XImmutableArray Create(T[] items) + { + return new XImmutableArray(items); + } + + #endregion + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Nodes/Collections/XList.cs b/src/CostManagement/generated/runtime/Nodes/Collections/XList.cs new file mode 100644 index 000000000000..13de4939d351 --- /dev/null +++ b/src/CostManagement/generated/runtime/Nodes/Collections/XList.cs @@ -0,0 +1,64 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + internal sealed class XList : JsonArray, IEnumerable + { + private readonly IList values; + private readonly JsonType elementType; + private readonly TypeCode elementCode; + + internal XList(IList values) + { + this.values = values ?? throw new ArgumentNullException(nameof(values)); + this.elementCode = System.Type.GetTypeCode(typeof(T)); + this.elementType = XHelper.GetElementType(this.elementCode); + } + + public override JsonNode this[int index] => + XHelper.Create(elementType, elementCode, values[index]); + + internal override JsonType? ElementType => elementType; + + public override int Count => values.Count; + + public bool IsReadOnly => values.IsReadOnly; + + #region IList + + public void Add(T value) + { + values.Add(value); + } + + public bool Contains(T value) => values.Contains(value); + + #endregion + + #region IEnumerable Members + + IEnumerator IEnumerable.GetEnumerator() + { + foreach (var value in values) + { + yield return XHelper.Create(elementType, elementCode, value); + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + foreach (var value in values) + { + yield return XHelper.Create(elementType, elementCode, value); + } + } + + #endregion + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Nodes/Collections/XNodeArray.cs b/src/CostManagement/generated/runtime/Nodes/Collections/XNodeArray.cs new file mode 100644 index 000000000000..bf091791b250 --- /dev/null +++ b/src/CostManagement/generated/runtime/Nodes/Collections/XNodeArray.cs @@ -0,0 +1,68 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System.Collections; +using System.Collections.Generic; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + public sealed partial class XNodeArray : JsonArray, ICollection + { + private readonly List items; + + internal XNodeArray() + { + items = new List(); + } + + internal XNodeArray(params JsonNode[] values) + { + items = new List(values); + } + + public override JsonNode this[int index] => items[index]; + + internal override JsonType? ElementType => null; + + public bool IsReadOnly => false; + + public override int Count => items.Count; + + #region ICollection Members + + public void Add(JsonNode item) + { + items.Add(item); + } + + void ICollection.Clear() + { + items.Clear(); + } + + public bool Contains(JsonNode item) => items.Contains(item); + + void ICollection.CopyTo(JsonNode[] array, int arrayIndex) + { + items.CopyTo(array, arrayIndex); + } + + public bool Remove(JsonNode item) + { + return items.Remove(item); + } + + #endregion + + #region IEnumerable Members + + IEnumerator IEnumerable.GetEnumerator() + => items.GetEnumerator(); + + IEnumerator IEnumerable.GetEnumerator() + => items.GetEnumerator(); + + #endregion + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Nodes/Collections/XSet.cs b/src/CostManagement/generated/runtime/Nodes/Collections/XSet.cs new file mode 100644 index 000000000000..fe8c0dcad333 --- /dev/null +++ b/src/CostManagement/generated/runtime/Nodes/Collections/XSet.cs @@ -0,0 +1,60 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + internal sealed class XSet : JsonArray, IEnumerable + { + private readonly HashSet values; + private readonly JsonType elementType; + private readonly TypeCode elementCode; + + internal XSet(IEnumerable values) + : this(new HashSet(values)) + { } + + internal XSet(HashSet values) + { + this.values = values ?? throw new ArgumentNullException(nameof(values)); + this.elementCode = System.Type.GetTypeCode(typeof(T)); + this.elementType = XHelper.GetElementType(this.elementCode); + } + + internal override JsonType Type => JsonType.Array; + + internal override JsonType? ElementType => elementType; + + public bool IsReadOnly => true; + + public override int Count => values.Count; + + internal override bool IsSet => true; + + #region IEnumerable Members + + IEnumerator IEnumerable.GetEnumerator() + { + foreach (var value in values) + { + yield return XHelper.Create(elementType, elementCode, value); + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + foreach (var value in values) + { + yield return XHelper.Create(elementType, elementCode, value); + } + } + + #endregion + + internal HashSet AsHashSet() => values; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Nodes/JsonBoolean.cs b/src/CostManagement/generated/runtime/Nodes/JsonBoolean.cs new file mode 100644 index 000000000000..ab0e316f2d8a --- /dev/null +++ b/src/CostManagement/generated/runtime/Nodes/JsonBoolean.cs @@ -0,0 +1,42 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + internal sealed partial class JsonBoolean : JsonNode + { + internal static readonly JsonBoolean True = new JsonBoolean(true); + internal static readonly JsonBoolean False = new JsonBoolean(false); + + internal JsonBoolean(bool value) + { + Value = value; + } + + internal bool Value { get; } + + internal override JsonType Type => JsonType.Boolean; + + internal static new JsonBoolean Parse(string text) + { + switch (text) + { + case "false": return False; + case "true": return True; + + default: throw new ArgumentException($"Expected true or false. Was {text}."); + } + } + + #region Implicit Casts + + public static implicit operator bool(JsonBoolean data) => data.Value; + + public static implicit operator JsonBoolean(bool data) => new JsonBoolean(data); + + #endregion + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Nodes/JsonDate.cs b/src/CostManagement/generated/runtime/Nodes/JsonDate.cs new file mode 100644 index 000000000000..d93a5264f8cd --- /dev/null +++ b/src/CostManagement/generated/runtime/Nodes/JsonDate.cs @@ -0,0 +1,173 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + + + internal sealed partial class JsonDate : JsonNode, IEquatable, IComparable + { + internal static bool AssumeUtcWhenKindIsUnspecified = true; + + private readonly DateTimeOffset value; + + internal JsonDate(DateTime value) + { + if (value.Kind == DateTimeKind.Unspecified && AssumeUtcWhenKindIsUnspecified) + { + value = DateTime.SpecifyKind(value, DateTimeKind.Utc); + } + + this.value = value; + } + + internal JsonDate(DateTimeOffset value) + { + this.value = value; + } + + internal override JsonType Type => JsonType.Date; + + #region Helpers + + internal DateTimeOffset ToDateTimeOffset() + { + return value; + } + + internal DateTime ToDateTime() + { + if (value.Offset == TimeSpan.Zero) + { + return value.UtcDateTime; + } + + return value.DateTime; + } + + internal DateTime ToUtcDateTime() => value.UtcDateTime; + + internal int ToUnixTimeSeconds() + { + return (int)value.ToUnixTimeSeconds(); + } + + internal long ToUnixTimeMilliseconds() + { + return (int)value.ToUnixTimeMilliseconds(); + } + + internal string ToIsoString() + { + return IsoDate.FromDateTimeOffset(value).ToString(); + } + + #endregion + + public override string ToString() + { + return ToIsoString(); + } + + internal static new JsonDate Parse(string text) + { + if (text == null) throw new ArgumentNullException(nameof(text)); + + // TODO support: unixtimeseconds.partialseconds + + if (text.Length > 4 && _IsNumber(text)) // UnixTime + { + var date = DateTimeOffset.FromUnixTimeSeconds(long.Parse(text)); + + return new JsonDate(date); + } + else if (text.Length <= 4 || text[4] == '-') // ISO: 2012- + { + return new JsonDate(IsoDate.Parse(text).ToDateTimeOffset()); + } + else + { + // NOT ISO ENCODED + // "Thu, 5 Apr 2012 16:59:01 +0200", + return new JsonDate(DateTimeOffset.Parse(text)); + } + } + + private static bool _IsNumber(string text) + { + foreach (var c in text) + { + if (!char.IsDigit(c)) return false; + } + + return true; + } + + internal static JsonDate FromUnixTime(int seconds) + { + return new JsonDate(DateTimeOffset.FromUnixTimeSeconds(seconds)); + } + + internal static JsonDate FromUnixTime(double seconds) + { + var milliseconds = (long)(seconds * 1000d); + + return new JsonDate(DateTimeOffset.FromUnixTimeMilliseconds(milliseconds)); + } + + #region Implicit Casts + + public static implicit operator DateTimeOffset(JsonDate value) + => value.ToDateTimeOffset(); + + public static implicit operator DateTime(JsonDate value) + => value.ToDateTime(); + + // From Date + public static implicit operator JsonDate(DateTimeOffset value) + { + return new JsonDate(value); + } + + public static implicit operator JsonDate(DateTime value) + { + return new JsonDate(value); + } + + // From String + public static implicit operator JsonDate(string value) + { + return Parse(value); + } + + #endregion + + #region Equality + + public override bool Equals(object obj) + { + return obj is JsonDate date && date.value == this.value; + } + + public bool Equals(JsonDate other) + { + return this.value == other.value; + } + + public override int GetHashCode() => value.GetHashCode(); + + #endregion + + #region IComparable Members + + int IComparable.CompareTo(JsonDate other) + { + return value.CompareTo(other.value); + } + + #endregion + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Nodes/JsonNode.cs b/src/CostManagement/generated/runtime/Nodes/JsonNode.cs new file mode 100644 index 000000000000..12238d24c10b --- /dev/null +++ b/src/CostManagement/generated/runtime/Nodes/JsonNode.cs @@ -0,0 +1,250 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; +using System.IO; +using System.Text; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + + + public abstract partial class JsonNode + { + internal abstract JsonType Type { get; } + + public virtual JsonNode this[int index] => throw new NotImplementedException(); + + public virtual JsonNode this[string name] + { + get => throw new NotImplementedException(); + set => throw new NotImplementedException(); + } + + #region Type Helpers + + internal bool IsArray => Type == JsonType.Array; + + internal bool IsDate => Type == JsonType.Date; + + internal bool IsObject => Type == JsonType.Object; + + internal bool IsNumber => Type == JsonType.Number; + + internal bool IsNull => Type == JsonType.Null; + + #endregion + + internal void WriteTo(TextWriter textWriter, bool pretty = true) + { + var writer = new JsonWriter(textWriter, pretty); + + writer.WriteNode(this); + } + + internal T As() + where T : new() + => new JsonSerializer().Deseralize((JsonObject)this); + + internal T[] ToArrayOf() + { + return (T[])new JsonSerializer().DeserializeArray(typeof(T[]), (JsonArray)this); + } + + #region ToString Overrides + + public override string ToString() => ToString(pretty: true); + + internal string ToString(bool pretty) + { + var sb = new StringBuilder(); + + using (var writer = new StringWriter(sb)) + { + WriteTo(writer, pretty); + + return sb.ToString(); + } + } + + #endregion + + #region Static Constructors + + internal static JsonNode Parse(string text) + { + return Parse(new SourceReader(new StringReader(text))); + } + + internal static JsonNode Parse(TextReader textReader) + => Parse(new SourceReader(textReader)); + + private static JsonNode Parse(SourceReader sourceReader) + { + using (var parser = new JsonParser(sourceReader)) + { + return parser.ReadNode(); + } + } + + internal static JsonNode FromObject(object instance) + => new JsonSerializer().Serialize(instance); + + #endregion + + #region Implict Casts + + public static implicit operator string(JsonNode node) => node.ToString(); + + #endregion + + #region Explict Casts + + public static explicit operator DateTime(JsonNode node) + { + switch (node.Type) + { + case JsonType.Date: + return ((JsonDate)node).ToDateTime(); + + case JsonType.String: + return JsonDate.Parse(node.ToString()).ToDateTime(); + + case JsonType.Number: + var num = (JsonNumber)node; + + if (num.IsInteger) + { + return DateTimeOffset.FromUnixTimeSeconds(num).UtcDateTime; + } + else + { + return DateTimeOffset.FromUnixTimeMilliseconds((long)((double)num * 1000)).UtcDateTime; + } + } + + throw new ConversionException(node, typeof(DateTime)); + } + + public static explicit operator DateTimeOffset(JsonNode node) + { + switch (node.Type) + { + case JsonType.Date : return ((JsonDate)node).ToDateTimeOffset(); + case JsonType.String : return JsonDate.Parse(node.ToString()).ToDateTimeOffset(); + + case JsonType.Number: + var num = (JsonNumber)node; + + if (num.IsInteger) + { + return DateTimeOffset.FromUnixTimeSeconds(num); + } + else + { + return DateTimeOffset.FromUnixTimeMilliseconds((long)((double)num * 1000)); + } + + } + + throw new ConversionException(node, typeof(DateTimeOffset)); + } + + public static explicit operator float(JsonNode node) + { + switch (node.Type) + { + case JsonType.Number : return (JsonNumber)node; + case JsonType.String : return float.Parse(node.ToString()); + } + + throw new ConversionException(node, typeof(float)); + } + + public static explicit operator double(JsonNode node) + { + switch (node.Type) + { + case JsonType.Number : return (JsonNumber)node; + case JsonType.String : return double.Parse(node.ToString()); + } + + throw new ConversionException(node, typeof(double)); + } + + public static explicit operator decimal(JsonNode node) + { + switch (node.Type) + { + case JsonType.Number: return (JsonNumber)node; + case JsonType.String: return decimal.Parse(node.ToString()); + } + + throw new ConversionException(node, typeof(decimal)); + } + + public static explicit operator Guid(JsonNode node) + => new Guid(node.ToString()); + + public static explicit operator short(JsonNode node) + { + switch (node.Type) + { + case JsonType.Number : return (JsonNumber)node; + case JsonType.String : return short.Parse(node.ToString()); + } + + throw new ConversionException(node, typeof(short)); + } + + public static explicit operator int(JsonNode node) + { + switch (node.Type) + { + case JsonType.Number : return (JsonNumber)node; + case JsonType.String : return int.Parse(node.ToString()); + } + + throw new ConversionException(node, typeof(int)); + } + + public static explicit operator long(JsonNode node) + { + switch (node.Type) + { + case JsonType.Number: return (JsonNumber)node; + case JsonType.String: return long.Parse(node.ToString()); + } + + throw new ConversionException(node, typeof(long)); + } + + public static explicit operator bool(JsonNode node) + => ((JsonBoolean)node).Value; + + public static explicit operator ushort(JsonNode node) + => (JsonNumber)node; + + public static explicit operator uint(JsonNode node) + => (JsonNumber)node; + + public static explicit operator ulong(JsonNode node) + => (JsonNumber)node; + + public static explicit operator TimeSpan(JsonNode node) + => TimeSpan.Parse(node.ToString()); + + public static explicit operator Uri(JsonNode node) + { + if (node.Type == JsonType.String) + { + return new Uri(node.ToString()); + } + + throw new ConversionException(node, typeof(Uri)); + } + + #endregion + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Nodes/JsonNumber.cs b/src/CostManagement/generated/runtime/Nodes/JsonNumber.cs new file mode 100644 index 000000000000..9d2c7546e73c --- /dev/null +++ b/src/CostManagement/generated/runtime/Nodes/JsonNumber.cs @@ -0,0 +1,109 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + public sealed partial class JsonNumber : JsonNode + { + private readonly string value; + private readonly bool overflows = false; + + internal JsonNumber(string value) + { + this.value = value ?? throw new ArgumentNullException(nameof(value)); + } + + internal JsonNumber(int value) + { + this.value = value.ToString(); + } + + internal JsonNumber(long value) + { + this.value = value.ToString(); + + if (value > 9007199254740991) + { + overflows = true; + } + } + + internal JsonNumber(float value) + { + this.value = value.ToString(); + } + + internal JsonNumber(double value) + { + this.value = value.ToString(); + } + + internal override JsonType Type => JsonType.Number; + + internal string Value => value; + + #region Helpers + + internal bool Overflows => overflows; + + internal bool IsInteger => !value.Contains("."); + + internal bool IsFloat => value.Contains("."); + + #endregion + + #region Casting + + public static implicit operator byte(JsonNumber number) + => byte.Parse(number.Value); + + public static implicit operator short(JsonNumber number) + => short.Parse(number.Value); + + public static implicit operator int(JsonNumber number) + => int.Parse(number.Value); + + public static implicit operator long(JsonNumber number) + => long.Parse(number.value); + + public static implicit operator UInt16(JsonNumber number) + => ushort.Parse(number.Value); + + public static implicit operator UInt32(JsonNumber number) + => uint.Parse(number.Value); + + public static implicit operator UInt64(JsonNumber number) + => ulong.Parse(number.Value); + + public static implicit operator decimal(JsonNumber number) + => decimal.Parse(number.Value); + + public static implicit operator Double(JsonNumber number) + => double.Parse(number.value); + + public static implicit operator float(JsonNumber number) + => float.Parse(number.value); + + public static implicit operator JsonNumber(short data) + => new JsonNumber(data.ToString()); + + public static implicit operator JsonNumber(int data) + => new JsonNumber(data); + + public static implicit operator JsonNumber(long data) + => new JsonNumber(data); + + public static implicit operator JsonNumber(Single data) + => new JsonNumber(data.ToString()); + + public static implicit operator JsonNumber(double data) + => new JsonNumber(data.ToString()); + + #endregion + + public override string ToString() => value; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Nodes/JsonObject.cs b/src/CostManagement/generated/runtime/Nodes/JsonObject.cs new file mode 100644 index 000000000000..31c3a5960d72 --- /dev/null +++ b/src/CostManagement/generated/runtime/Nodes/JsonObject.cs @@ -0,0 +1,172 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; +using System.Collections; +using System.Collections.Generic; +using System.IO; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + public partial class JsonObject : JsonNode, IDictionary + { + private readonly Dictionary items; + + internal JsonObject() + { + items = new Dictionary(); + } + + internal JsonObject(IEnumerable> properties) + { + if (properties == null) throw new ArgumentNullException(nameof(properties)); + + items = new Dictionary(); + + foreach (var field in properties) + { + items.Add(field.Key, field.Value); + } + } + + #region IDictionary Constructors + + internal JsonObject(IDictionary dic) + { + items = new Dictionary(dic.Count); + + foreach (var pair in dic) + { + Add(pair.Key, pair.Value); + } + } + + #endregion + + internal override JsonType Type => JsonType.Object; + + #region Add Overloads + + public void Add(string name, JsonNode value) => + items.Add(name, value); + + public void Add(string name, byte[] value) => + items.Add(name, new XBinary(value)); + + public void Add(string name, DateTime value) => + items.Add(name, new JsonDate(value)); + + public void Add(string name, int value) => + items.Add(name, new JsonNumber(value.ToString())); + + public void Add(string name, long value) => + items.Add(name, new JsonNumber(value.ToString())); + + public void Add(string name, float value) => + items.Add(name, new JsonNumber(value.ToString())); + + public void Add(string name, double value) => + items.Add(name, new JsonNumber(value.ToString())); + + public void Add(string name, string value) => + items.Add(name, new JsonString(value)); + + public void Add(string name, bool value) => + items.Add(name, new JsonBoolean(value)); + + public void Add(string name, Uri url) => + items.Add(name, new JsonString(url.AbsoluteUri)); + + public void Add(string name, string[] values) => + items.Add(name, new XImmutableArray(values)); + + public void Add(string name, int[] values) => + items.Add(name, new XImmutableArray(values)); + + #endregion + + #region ICollection> Members + + void ICollection>.Add(KeyValuePair item) + { + items.Add(item.Key, item.Value); + } + + void ICollection>.Clear() + { + items.Clear(); + } + + bool ICollection>.Contains(KeyValuePair item) => + throw new NotImplementedException(); + + void ICollection>.CopyTo(KeyValuePair[] array, int arrayIndex) => + throw new NotImplementedException(); + + + int ICollection>.Count => items.Count; + + bool ICollection>.IsReadOnly => false; + + bool ICollection>.Remove(KeyValuePair item) => + throw new NotImplementedException(); + + #endregion + + #region IDictionary Members + + public bool ContainsKey(string key) => items.ContainsKey(key); + + public ICollection Keys => items.Keys; + + public bool Remove(string key) => items.Remove(key); + + public bool TryGetValue(string key, out JsonNode value) => + items.TryGetValue(key, out value); + + public ICollection Values => items.Values; + + public override JsonNode this[string key] + { + get => items[key]; + set => items[key] = value; + } + + #endregion + + #region IEnumerable + + IEnumerator> IEnumerable>.GetEnumerator() + => items.GetEnumerator(); + + IEnumerator IEnumerable.GetEnumerator() + => items.GetEnumerator(); + + #endregion + + #region Helpers + + internal static new JsonObject FromObject(object instance) => + (JsonObject)new JsonSerializer().Serialize(instance); + + #endregion + + #region Static Constructors + + internal static JsonObject FromStream(Stream stream) + { + using (var tr = new StreamReader(stream)) + { + return (JsonObject)Parse(tr); + } + } + + internal static new JsonObject Parse(string text) + { + return (JsonObject)JsonNode.Parse(text); + } + + #endregion + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Nodes/JsonString.cs b/src/CostManagement/generated/runtime/Nodes/JsonString.cs new file mode 100644 index 000000000000..59c40138acc3 --- /dev/null +++ b/src/CostManagement/generated/runtime/Nodes/JsonString.cs @@ -0,0 +1,42 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + public sealed partial class JsonString : JsonNode, IEquatable + { + private readonly string value; + + internal JsonString(string value) + { + this.value = value ?? throw new ArgumentNullException(nameof(value)); + } + + internal override JsonType Type => JsonType.String; + + internal string Value => value; + + internal int Length => value.Length; + + #region #region Implicit Casts + + public static implicit operator string(JsonString data) => data.Value; + + public static implicit operator JsonString(string value) => new JsonString(value); + + #endregion + + public override int GetHashCode() => value.GetHashCode(); + + public override string ToString() => value; + + #region IEquatable + + bool IEquatable.Equals(JsonString other) => this.Value == other.Value; + + #endregion + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Nodes/XBinary.cs b/src/CostManagement/generated/runtime/Nodes/XBinary.cs new file mode 100644 index 000000000000..106fe5020ebd --- /dev/null +++ b/src/CostManagement/generated/runtime/Nodes/XBinary.cs @@ -0,0 +1,40 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + internal sealed class XBinary : JsonNode + { + private readonly byte[] _value; + private readonly string _base64; + + internal XBinary(byte[] value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + internal XBinary(string base64EncodedString) + { + _base64 = base64EncodedString ?? throw new ArgumentNullException(nameof(base64EncodedString)); + } + + internal override JsonType Type => JsonType.Binary; + + internal byte[] Value => _value ?? Convert.FromBase64String(_base64); + + #region #region Implicit Casts + + public static implicit operator byte[] (XBinary data) => data.Value; + + public static implicit operator XBinary(byte[] data) => new XBinary(data); + + #endregion + + public override int GetHashCode() => Value.GetHashCode(); + + public override string ToString() => _base64 ?? Convert.ToBase64String(_value); + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Nodes/XNull.cs b/src/CostManagement/generated/runtime/Nodes/XNull.cs new file mode 100644 index 000000000000..d1d686344d38 --- /dev/null +++ b/src/CostManagement/generated/runtime/Nodes/XNull.cs @@ -0,0 +1,15 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + internal sealed class XNull : JsonNode + { + internal static readonly XNull Instance = new XNull(); + + private XNull() { } + + internal override JsonType Type => JsonType.Null; + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Parser/Exceptions/ParseException.cs b/src/CostManagement/generated/runtime/Parser/Exceptions/ParseException.cs new file mode 100644 index 000000000000..722a9b8bcb17 --- /dev/null +++ b/src/CostManagement/generated/runtime/Parser/Exceptions/ParseException.cs @@ -0,0 +1,24 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + internal class ParserException : Exception + { + internal ParserException(string message) + : base(message) + { } + + internal ParserException(string message, SourceLocation location) + : base(message) + { + + Location = location; + } + + internal SourceLocation Location { get; } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Parser/JsonParser.cs b/src/CostManagement/generated/runtime/Parser/JsonParser.cs new file mode 100644 index 000000000000..e9c62b0a7441 --- /dev/null +++ b/src/CostManagement/generated/runtime/Parser/JsonParser.cs @@ -0,0 +1,180 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; +using System.Collections.Generic; +using System.IO; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + public class JsonParser : IDisposable + { + private readonly TokenReader reader; + + internal JsonParser(TextReader reader) + : this(new SourceReader(reader)) { } + + internal JsonParser(SourceReader sourceReader) + { + if (sourceReader == null) + throw new ArgumentNullException(nameof(sourceReader)); + + this.reader = new TokenReader(new JsonTokenizer(sourceReader)); + + this.reader.Next(); // Start with the first token + } + + internal IEnumerable ReadNodes() + { + JsonNode node; + + while ((node = ReadNode()) != null) yield return node; + } + + internal JsonNode ReadNode() + { + if (reader.Current.Kind == TokenKind.Eof || reader.Current.IsTerminator) + { + return null; + } + + switch (reader.Current.Kind) + { + case TokenKind.LeftBrace : return ReadObject(); // { + case TokenKind.LeftBracket : return ReadArray(); // [ + + default: throw new ParserException($"Expected '{{' or '['. Was {reader.Current}."); + } + } + + private JsonNode ReadFieldValue() + { + // Boolean, Date, Null, Number, String, Uri + if (reader.Current.IsLiteral) + { + return ReadLiteral(); + } + else + { + switch (reader.Current.Kind) + { + case TokenKind.LeftBracket: return ReadArray(); + case TokenKind.LeftBrace : return ReadObject(); + + default: throw new ParserException($"Unexpected token reading field value. Was {reader.Current}."); + } + } + } + + private JsonNode ReadLiteral() + { + var literal = reader.Current; + + reader.Next(); // Read the literal token + + switch (literal.Kind) + { + case TokenKind.Boolean : return JsonBoolean.Parse(literal.Value); + case TokenKind.Null : return XNull.Instance; + case TokenKind.Number : return new JsonNumber(literal.Value); + case TokenKind.String : return new JsonString(literal.Value); + + default: throw new ParserException($"Unexpected token reading literal. Was {literal}."); + } + } + + internal JsonObject ReadObject() + { + reader.Ensure(TokenKind.LeftBrace, "object"); + + reader.Next(); // Read '{' (Object start) + + var jsonObject = new JsonObject(); + + // Read the object's fields until we reach the end of the object ('}') + while (reader.Current.Kind != TokenKind.RightBrace) + { + if (reader.Current.Kind == TokenKind.Comma) + { + reader.Next(); // Read ',' (Seperator) + } + + // Ensure we have a field name + reader.Ensure(TokenKind.String, "Expected field name"); + + var field = ReadField(); + + jsonObject.Add(field.Key, field.Value); + } + + reader.Next(); // Read '}' (Object end) + + return jsonObject; + } + + + // TODO: Use ValueTuple in C#7 + private KeyValuePair ReadField() + { + var fieldName = reader.Current.Value; + + reader.Next(); // Read the field name + + reader.Ensure(TokenKind.Colon, "field"); + + reader.Next(); // Read ':' (Field value indicator) + + return new KeyValuePair(fieldName, ReadFieldValue()); + } + + + internal JsonArray ReadArray() + { + reader.Ensure(TokenKind.LeftBracket, "array"); + + var array = new XNodeArray(); + + reader.Next(); // Read the '[' (Array start) + + // Read the array's items + while (reader.Current.Kind != TokenKind.RightBracket) + { + if (reader.Current.Kind == TokenKind.Comma) + { + reader.Next(); // Read the ',' (Seperator) + } + + if (reader.Current.IsLiteral) + { + array.Add(ReadLiteral()); // Boolean, Date, Number, Null, String, Uri + } + else if (reader.Current.Kind == TokenKind.LeftBracket) + { + array.Add(ReadArray()); // Array + } + else if (reader.Current.Kind == TokenKind.LeftBrace) + { + array.Add(ReadObject()); // Object + } + else + { + throw new ParserException($"Expected comma, literal, or object. Was {reader.Current}."); + } + } + + reader.Next(); // Read the ']' (Array end) + + return array; + } + + #region IDisposable + + public void Dispose() + { + reader.Dispose(); + } + + #endregion + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Parser/JsonToken.cs b/src/CostManagement/generated/runtime/Parser/JsonToken.cs new file mode 100644 index 000000000000..3855c26301ac --- /dev/null +++ b/src/CostManagement/generated/runtime/Parser/JsonToken.cs @@ -0,0 +1,66 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + internal enum TokenKind + { + LeftBrace, // { Object start + RightBrace, // } Object end + + LeftBracket, // [ Array start + RightBracket, // ] Array end + + Comma, // , Comma + Colon, // : Value indicator + Dot, // . Access field indicator + Terminator, // \0 Stream terminator + + Boolean = 31, // true or false + Null = 33, // null + Number = 34, // i.e. -1.93, -1, 0, 1, 1.1 + String = 35, // i.e. "text" + + Eof = 50 + } + + internal /* readonly */ struct JsonToken + { + internal static readonly JsonToken BraceOpen = new JsonToken(TokenKind.LeftBrace, "{"); + internal static readonly JsonToken BraceClose = new JsonToken(TokenKind.RightBrace, "}"); + + internal static readonly JsonToken BracketOpen = new JsonToken(TokenKind.LeftBracket, "["); + internal static readonly JsonToken BracketClose = new JsonToken(TokenKind.RightBracket, "]"); + + internal static readonly JsonToken Colon = new JsonToken(TokenKind.Colon, ":"); + internal static readonly JsonToken Comma = new JsonToken(TokenKind.Comma, ","); + internal static readonly JsonToken Terminator = new JsonToken(TokenKind.Terminator, "\0"); + + internal static readonly JsonToken True = new JsonToken(TokenKind.Boolean, "true"); + internal static readonly JsonToken False = new JsonToken(TokenKind.Boolean, "false"); + internal static readonly JsonToken Null = new JsonToken(TokenKind.Null, "null"); + + internal static readonly JsonToken Eof = new JsonToken(TokenKind.Eof, null); + + internal JsonToken(TokenKind kind, string value) + { + Kind = kind; + Value = value; + } + + internal readonly TokenKind Kind; + + internal readonly string Value; + + public override string ToString() => Kind + ": " + Value; + + #region Helpers + + internal bool IsLiteral => (byte)Kind > 30 && (byte)Kind < 40; + + internal bool IsTerminator => Kind == TokenKind.Terminator; + + #endregion + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Parser/JsonTokenizer.cs b/src/CostManagement/generated/runtime/Parser/JsonTokenizer.cs new file mode 100644 index 000000000000..866684eb5f4f --- /dev/null +++ b/src/CostManagement/generated/runtime/Parser/JsonTokenizer.cs @@ -0,0 +1,177 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; +using System.Text; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + using System.IO; + + + public class JsonTokenizer : IDisposable + { + private readonly StringBuilder sb = new StringBuilder(); + + private readonly SourceReader reader; + + internal JsonTokenizer(TextReader reader) + : this(new SourceReader(reader)) { } + + internal JsonTokenizer(SourceReader reader) + { + this.reader = reader; + + reader.Next(); // Start with the first char + } + + internal JsonToken ReadNext() + { + reader.SkipWhitespace(); + + if (reader.IsEof) return JsonToken.Eof; + + switch (reader.Current) + { + case '"': return ReadQuotedString(); + + // Symbols + case '[' : reader.Next(); return JsonToken.BracketOpen; // Array start + case ']' : reader.Next(); return JsonToken.BracketClose; // Array end + case ',' : reader.Next(); return JsonToken.Comma; // Value seperator + case ':' : reader.Next(); return JsonToken.Colon; // Field value indicator + case '{' : reader.Next(); return JsonToken.BraceOpen; // Object start + case '}' : reader.Next(); return JsonToken.BraceClose; // Object end + case '\0' : reader.Next(); return JsonToken.Terminator; // Stream terminiator + + default: return ReadLiteral(); + } + } + + private JsonToken ReadQuotedString() + { + Expect('"', "quoted string indicator"); + + reader.Next(); // Read '"' (Starting quote) + + // Read until we reach an unescaped quote char + while (reader.Current != '"') + { + EnsureNotEof("quoted string"); + + if (reader.Current == '\\') + { + char escapedCharacter = reader.ReadEscapeCode(); + + sb.Append(escapedCharacter); + + continue; + } + + StoreCurrentCharacterAndReadNext(); + } + + reader.Next(); // Read '"' (Ending quote) + + return new JsonToken(TokenKind.String, value: sb.Extract()); + } + + private JsonToken ReadLiteral() + { + if (char.IsDigit(reader.Current) || + reader.Current == '-' || + reader.Current == '+') + { + return ReadNumber(); + } + + return ReadIdentifer(); + } + + private JsonToken ReadNumber() + { + // Read until we hit a non-numeric character + // -6.247737e-06 + // E + + while (char.IsDigit(reader.Current) + || reader.Current == '.' + || reader.Current == 'e' + || reader.Current == 'E' + || reader.Current == '-' + || reader.Current == '+') + { + StoreCurrentCharacterAndReadNext(); + } + + return new JsonToken(TokenKind.Number, value: sb.Extract()); + } + + int count = 0; + + private JsonToken ReadIdentifer() + { + count++; + + if (!char.IsLetter(reader.Current)) + { + throw new ParserException( + message : $"Expected literal (number, boolean, or null). Was '{reader.Current}'.", + location : reader.Location + ); + } + + // Read letters, numbers, and underscores '_' + while (char.IsLetterOrDigit(reader.Current) || reader.Current == '_') + { + StoreCurrentCharacterAndReadNext(); + } + + string text = sb.Extract(); + + switch (text) + { + case "true": return JsonToken.True; + case "false": return JsonToken.False; + case "null": return JsonToken.Null; + + default: return new JsonToken(TokenKind.String, text); + } + } + + private void Expect(char character, string description) + { + if (reader.Current != character) + { + throw new ParserException( + message: $"Expected {description} ('{character}'). Was '{reader.Current}'.", + location: reader.Location + ); + } + } + + private void EnsureNotEof(string tokenType) + { + if (reader.IsEof) + { + throw new ParserException( + message: $"Unexpected EOF while reading {tokenType}.", + location: reader.Location + ); + } + } + + private void StoreCurrentCharacterAndReadNext() + { + sb.Append(reader.Current); + + reader.Next(); + } + + public void Dispose() + { + reader.Dispose(); + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Parser/Location.cs b/src/CostManagement/generated/runtime/Parser/Location.cs new file mode 100644 index 000000000000..674150baf313 --- /dev/null +++ b/src/CostManagement/generated/runtime/Parser/Location.cs @@ -0,0 +1,43 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + internal struct SourceLocation + { + private int line; + private int column; + private int position; + + internal SourceLocation(int line = 0, int column = 0, int position = 0) + { + this.line = line; + this.column = column; + this.position = position; + } + + internal int Line => line; + + internal int Column => column; + + internal int Position => position; + + internal void Advance() + { + this.column++; + this.position++; + } + + internal void MarkNewLine() + { + this.line++; + this.column = 0; + } + + internal SourceLocation Clone() + { + return new SourceLocation(line, column, position); + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Parser/Readers/SourceReader.cs b/src/CostManagement/generated/runtime/Parser/Readers/SourceReader.cs new file mode 100644 index 000000000000..9f587757f077 --- /dev/null +++ b/src/CostManagement/generated/runtime/Parser/Readers/SourceReader.cs @@ -0,0 +1,130 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; +using System.Globalization; +using System.IO; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + public sealed class SourceReader : IDisposable + { + private readonly TextReader source; + + private char current; + + private readonly SourceLocation location = new SourceLocation(); + + private bool isEof = false; + + internal SourceReader(TextReader textReader) + { + this.source = textReader ?? throw new ArgumentNullException(nameof(textReader)); + } + + /// + /// Advances to the next character + /// + internal void Next() + { + // Advance to the new line when we see a new line '\n'. + // A new line may be prefixed by a carriage return '\r'. + + if (current == '\n') + { + location.MarkNewLine(); + } + + int charCode = source.Read(); // -1 for end + + if (charCode >= 0) + { + current = (char)charCode; + } + else + { + // If we've already marked this as the EOF, throw an exception + if (isEof) + { + throw new EndOfStreamException("Cannot advance past end of stream."); + } + + isEof = true; + + current = '\0'; + } + + location.Advance(); + } + + internal void SkipWhitespace() + { + while (char.IsWhiteSpace(current)) + { + Next(); + } + } + + internal char ReadEscapeCode() + { + Next(); + + char escapedChar = current; + + Next(); // Consume escaped character + + switch (escapedChar) + { + // Special escape codes + case '"': return '"'; // " (Quotation mark) U+0022 + case '/': return '/'; // / (Solidus) U+002F + case '\\': return '\\'; // \ (Reverse solidus) U+005C + + // Control Characters + case '0': return '\0'; // Nul (0) U+0000 + case 'a': return '\a'; // Alert (7) + case 'b': return '\b'; // Backspace (8) U+0008 + case 'f': return '\f'; // Form feed (12) U+000C + case 'n': return '\n'; // Line feed (10) U+000A + case 'r': return '\r'; // Carriage return (13) U+000D + case 't': return '\t'; // Horizontal tab (9) U+0009 + case 'v': return '\v'; // Vertical tab + + // Unicode escape sequence + case 'u': return ReadUnicodeEscapeSequence(); // U+XXXX + + default: throw new Exception($"Unrecognized escape sequence '\\{escapedChar}'"); + } + } + + private readonly char[] hexCode = new char[4]; + + private char ReadUnicodeEscapeSequence() + { + hexCode[0] = current; Next(); + hexCode[1] = current; Next(); + hexCode[2] = current; Next(); + hexCode[3] = current; Next(); + + return Convert.ToChar(int.Parse( + s : new string(hexCode), + style : NumberStyles.HexNumber, + provider: NumberFormatInfo.InvariantInfo + )); + } + + internal char Current => current; + + internal bool IsEof => isEof; + + internal char Peek() => (char)source.Peek(); + + internal SourceLocation Location => location; + + public void Dispose() + { + source.Dispose(); + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Parser/TokenReader.cs b/src/CostManagement/generated/runtime/Parser/TokenReader.cs new file mode 100644 index 000000000000..9e8ba7be9fb2 --- /dev/null +++ b/src/CostManagement/generated/runtime/Parser/TokenReader.cs @@ -0,0 +1,39 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + public class TokenReader : IDisposable + { + private readonly JsonTokenizer tokenizer; + private JsonToken current; + + internal TokenReader(JsonTokenizer tokenizer) + { + this.tokenizer = tokenizer ?? throw new ArgumentNullException(nameof(tokenizer)); + } + + internal void Next() + { + current = tokenizer.ReadNext(); + } + + internal JsonToken Current => current; + + internal void Ensure(TokenKind kind, string readerName) + { + if (current.Kind != kind) + { + throw new ParserException($"Expected {kind} while reading {readerName}). Was {current}."); + } + } + + public void Dispose() + { + tokenizer.Dispose(); + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/PipelineMocking.cs b/src/CostManagement/generated/runtime/PipelineMocking.cs new file mode 100644 index 000000000000..13f67f13938e --- /dev/null +++ b/src/CostManagement/generated/runtime/PipelineMocking.cs @@ -0,0 +1,254 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime +{ + using System.Threading.Tasks; + using System.Collections.Generic; + using System.Net.Http; + using System.Linq; + using System.Net; + using Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json; + + public enum MockMode + { + Live, + Record, + Playback, + + } + + public class PipelineMock + { + + private System.Collections.Generic.Stack scenario = new System.Collections.Generic.Stack(); + private System.Collections.Generic.Stack context = new System.Collections.Generic.Stack(); + private System.Collections.Generic.Stack description = new System.Collections.Generic.Stack(); + + private readonly string recordingPath; + private int counter = 0; + + public static implicit operator Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep(PipelineMock instance) => instance.SendAsync; + + public MockMode Mode { get; set; } = MockMode.Live; + public PipelineMock(string recordingPath) + { + this.recordingPath = recordingPath; + } + + public void PushContext(string text) => context.Push(text); + + public void PushDescription(string text) => description.Push(text); + + + public void PushScenario(string it) + { + // reset counter too + counter = 0; + + scenario.Push(it); + } + + public void PopContext() => context.Pop(); + + public void PopDescription() => description.Pop(); + + public void PopScenario() => scenario.Pop(); + + public void SetRecord() => Mode = MockMode.Record; + + public void SetPlayback() => Mode = MockMode.Playback; + + public void SetLive() => Mode = MockMode.Live; + + public string Scenario => (scenario.Count > 0 ? scenario.Peek() : "[NoScenario]"); + public string Description => (description.Count > 0 ? description.Peek() : "[NoDescription]"); + public string Context => (context.Count > 0 ? context.Peek() : "[NoContext]"); + + /// + /// Headers that we substitute out blank values for in the recordings + /// Add additional headers as necessary + /// + public static HashSet Blacklist = new HashSet(System.StringComparer.CurrentCultureIgnoreCase) { + "Authorization", + }; + + public Dictionary ForceResponseHeaders = new Dictionary(); + + internal static XImmutableArray Removed = new XImmutableArray(new string[] { "[Filtered]" }); + + internal static IEnumerable> FilterHeaders(IEnumerable>> headers) => headers.Select(header => new KeyValuePair(header.Key, Blacklist.Contains(header.Key) ? Removed : new XImmutableArray(header.Value.ToArray()))); + + internal static JsonNode SerializeContent(HttpContent content) => content == null ? XNull.Instance : SerializeContent(content.ReadAsByteArrayAsync().Result); + + internal static JsonNode SerializeContent(byte[] content) + { + if (null == content || content.Length == 0) + { + return XNull.Instance; + } + var first = content[0]; + var last = content[content.Length - 1]; + + // plaintext for JSON/SGML/XML/HTML/STRINGS/ARRAYS + if ((first == '{' && last == '}') || (first == '<' && last == '>') || (first == '[' && last == ']') || (first == '"' && last == '"')) + { + return new JsonString(System.Text.Encoding.UTF8.GetString(content)); + } + + // base64 for everyone else + return new JsonString(System.Convert.ToBase64String(content)); + } + + internal static byte[] DeserializeContent(string content) + { + if (string.IsNullOrWhiteSpace(content)) + { + return new byte[0]; + } + + if (content.EndsWith("==")) + { + try + { + return System.Convert.FromBase64String(content); + } + catch + { + // hmm. didn't work, return it as a string I guess. + } + } + return System.Text.Encoding.UTF8.GetBytes(content); + } + + public void SaveMessage(string rqKey, HttpRequestMessage request, HttpResponseMessage response) + { + var messages = System.IO.File.Exists(this.recordingPath) ? Load() : new JsonObject() ?? new JsonObject(); + messages[rqKey] = new JsonObject { + { "Request",new JsonObject { + { "Method", request.Method.Method }, + { "RequestUri", request.RequestUri }, + { "Content", SerializeContent( request.Content) }, + { "Headers", new JsonObject(FilterHeaders(request.Headers)) }, + { "ContentHeaders", request.Content == null ? new JsonObject() : new JsonObject(FilterHeaders(request.Content.Headers))} + } }, + {"Response", new JsonObject { + { "StatusCode", (int)response.StatusCode}, + { "Headers", new JsonObject(FilterHeaders(response.Headers))}, + { "ContentHeaders", new JsonObject(FilterHeaders(response.Content.Headers))}, + { "Content", SerializeContent(response.Content) }, + }} + }; + System.IO.File.WriteAllText(this.recordingPath, messages.ToString()); + } + + private JsonObject Load() + { + if (System.IO.File.Exists(this.recordingPath)) + { + try + { + return JsonObject.FromStream(System.IO.File.OpenRead(this.recordingPath)); + } + catch + { + throw new System.Exception($"Invalid recording file: '{recordingPath}'"); + } + } + + throw new System.ArgumentException($"Missing recording file: '{recordingPath}'", nameof(recordingPath)); + } + + public HttpResponseMessage LoadMessage(string rqKey) + { + var responses = Load(); + var message = responses.Property(rqKey); + + if (null == message) + { + throw new System.ArgumentException($"Missing Request '{rqKey}' in recording file", nameof(rqKey)); + } + + var sc = 0; + var reqMessage = message.Property("Request"); + var respMessage = message.Property("Response"); + + // --------------------------- deserialize response ---------------------------------------------------------------- + var response = new HttpResponseMessage + { + StatusCode = (HttpStatusCode)respMessage.NumberProperty("StatusCode", ref sc), + Content = new System.Net.Http.ByteArrayContent(DeserializeContent(respMessage.StringProperty("Content"))) + }; + + foreach (var each in respMessage.Property("Headers")) + { + response.Headers.TryAddWithoutValidation(each.Key, each.Value.ToArrayOf()); + } + + foreach (var frh in ForceResponseHeaders) + { + response.Headers.Remove(frh.Key); + response.Headers.TryAddWithoutValidation(frh.Key, frh.Value); + } + + foreach (var each in respMessage.Property("ContentHeaders")) + { + response.Content.Headers.TryAddWithoutValidation(each.Key, each.Value.ToArrayOf()); + } + + // --------------------------- deserialize request ---------------------------------------------------------------- + response.RequestMessage = new HttpRequestMessage + { + Method = new HttpMethod(reqMessage.StringProperty("Method")), + RequestUri = new System.Uri(reqMessage.StringProperty("RequestUri")), + Content = new System.Net.Http.ByteArrayContent(DeserializeContent(reqMessage.StringProperty("Content"))) + }; + + foreach (var each in reqMessage.Property("Headers")) + { + response.RequestMessage.Headers.TryAddWithoutValidation(each.Key, each.Value.ToArrayOf()); + } + foreach (var each in reqMessage.Property("ContentHeaders")) + { + response.RequestMessage.Content.Headers.TryAddWithoutValidation(each.Key, each.Value.ToArrayOf()); + } + + return response; + } + + public async Task SendAsync(HttpRequestMessage request, IEventListener callback, ISendAsync next) + { + counter++; + var rqkey = $"{Description}+{Context}+{Scenario}+${request.Method.Method}+{request.RequestUri}+{counter}"; + + switch (Mode) + { + case MockMode.Record: + //Add following code since the request.Content will be released after sendAsync + var requestClone = request; + if (requestClone.Content != null) + { + requestClone = await request.CloneWithContent(request.RequestUri, request.Method); + } + // make the call + var response = await next.SendAsync(request, callback); + + // save the message to the recording file + SaveMessage(rqkey, requestClone, response); + + // return the response. + return response; + + case MockMode.Playback: + // load and return the response. + return LoadMessage(rqkey); + + default: + // pass-thru, do nothing + return await next.SendAsync(request, callback); + } + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Response.cs b/src/CostManagement/generated/runtime/Response.cs new file mode 100644 index 000000000000..6116bb572da9 --- /dev/null +++ b/src/CostManagement/generated/runtime/Response.cs @@ -0,0 +1,27 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime +{ + using System; + using System.Threading.Tasks; + public class Response : EventData + { + public Response() : base() + { + } + } + + public class Response : Response + { + private Func> _resultDelegate; + private Task _resultValue; + + public Response(T value) : base() => _resultValue = Task.FromResult(value); + public Response(Func value) : base() => _resultDelegate = () => Task.FromResult(value()); + public Response(Func> value) : base() => _resultDelegate = value; + public Task Result => _resultValue ?? (_resultValue = this._resultDelegate()); + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Serialization/JsonSerializer.cs b/src/CostManagement/generated/runtime/Serialization/JsonSerializer.cs new file mode 100644 index 000000000000..5a0e0ab2a4e2 --- /dev/null +++ b/src/CostManagement/generated/runtime/Serialization/JsonSerializer.cs @@ -0,0 +1,350 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + internal class JsonSerializer + { + private int depth = 0; + + private SerializationOptions options = new SerializationOptions(); + + #region Deserialization + + internal T Deseralize(JsonObject json) + where T : new() + { + var contract = JsonModelCache.Get(typeof(T)); + + return (T)DeserializeObject(contract, json); + } + + internal object DeserializeObject(JsonModel contract, JsonObject json) + { + var instance = Activator.CreateInstance(contract.Type); + + depth++; + + // Ensure we don't recurse forever + if (depth > 5) throw new Exception("Depth greater than 5"); + + foreach (var field in json) + { + var member = contract[field.Key]; + + if (member != null) + { + var value = DeserializeValue(member, field.Value); + + member.SetValue(instance, value); + } + } + + depth--; + + return instance; + } + + private object DeserializeValue(JsonMember member, JsonNode value) + { + if (value.Type == JsonType.Null) return null; + + var type = member.Type; + + if (member.IsStringLike && value.Type != JsonType.String) + { + // Take the long path... + return DeserializeObject(JsonModelCache.Get(type), (JsonObject)value); + } + else if (member.Converter != null) + { + return member.Converter.FromJson(value); + } + else if (type.IsArray) + { + return DeserializeArray(type, (JsonArray)value); + } + else if (member.IsList) + { + return DeserializeList(type, (JsonArray)value); + } + else + { + var contract = JsonModelCache.Get(type); + + return DeserializeObject(contract, (JsonObject)value); + } + } + + private object DeserializeValue(Type type, JsonNode value) + { + if (type == null) throw new ArgumentNullException(nameof(type)); + + if (value.Type == JsonType.Null) return null; + + var typeDetails = TypeDetails.Get(type); + + if (typeDetails.JsonConverter != null) + { + return typeDetails.JsonConverter.FromJson(value); + } + else if (typeDetails.IsEnum) + { + return Enum.Parse(type, value.ToString(), ignoreCase: true); + } + else if (type.IsArray) + { + return DeserializeArray(type, (JsonArray)value); + } + else if (typeDetails.IsList) + { + return DeserializeList(type, (JsonArray)value); + } + else + { + var contract = JsonModelCache.Get(type); + + return DeserializeObject(contract, (JsonObject)value); + } + } + + internal Array DeserializeArray(Type type, JsonArray elements) + { + var elementType = type.GetElementType(); + + var elementTypeDetails = TypeDetails.Get(elementType); + + var array = Array.CreateInstance(elementType, elements.Count); + + int i = 0; + + if (elementTypeDetails.JsonConverter != null) + { + foreach (var value in elements) + { + array.SetValue(elementTypeDetails.JsonConverter.FromJson(value), i); + + i++; + } + } + else + { + foreach (var value in elements) + { + array.SetValue(DeserializeValue(elementType, value), i); + + i++; + } + } + + return array; + } + + internal IList DeserializeList(Type type, JsonArray jsonArray) + { + // TODO: Handle non-generic types + if (!type.IsGenericType) + throw new ArgumentException("Must be a generic type", nameof(type)); + + var elementType = type.GetGenericArguments()[0]; + + IList list; + + if (type.IsInterface) + { + // Create a concrete generic list + list = (IList)Activator.CreateInstance(typeof(List<>).MakeGenericType(elementType)); + } + else + { + list = (IList)Activator.CreateInstance(type); + } + + foreach (var value in jsonArray) + { + list.Add(DeserializeValue(elementType, value)); + } + + return list; + } + + #endregion + + #region Serialization + + internal JsonNode Serialize(object instance) => + Serialize(instance, SerializationOptions.Default); + + internal JsonNode Serialize(object instance, string[] include) => + Serialize(instance, new SerializationOptions { Include = include }); + + internal JsonNode Serialize(object instance, SerializationOptions options) + { + this.options = options; + + if (instance == null) + { + return XNull.Instance; + } + + return ReadValue(instance.GetType(), instance); + } + + #region Readers + + internal JsonArray ReadArray(IEnumerable collection) + { + var array = new XNodeArray(); + + foreach (var item in collection) + { + array.Add(ReadValue(item.GetType(), item)); + } + + return array; + } + + internal IEnumerable> ReadProperties(object instance) + { + var contract = JsonModelCache.Get(instance.GetType()); + + foreach (var member in contract.Members) + { + string name = member.Name; + + if (options.PropertyNameTransformer != null) + { + name = options.PropertyNameTransformer.Invoke(name); + } + + // Skip the field if it's not included + if ((depth == 1 && !options.IsIncluded(name))) + { + continue; + } + + var value = member.GetValue(instance); + + if (!member.EmitDefaultValue && (value == null || (member.IsList && ((IList)value).Count == 0) || value.Equals(member.DefaultValue))) + { + continue; + } + else if (options.IgnoreNullValues && value == null) // Ignore null values + { + continue; + } + + // Transform the value if there is one + if (options.Transformations != null) + { + var transform = options.GetTransformation(name); + + if (transform != null) + { + value = transform.Transformer(value); + } + } + + yield return new KeyValuePair(name, ReadValue(member.TypeDetails, value)); + } + } + + private JsonObject ReadObject(object instance) + { + depth++; + + // TODO: Guard against a self referencing graph + if (depth > options.MaxDepth) + { + depth--; + + return new JsonObject(); + } + + var node = new JsonObject(ReadProperties(instance)); + + depth--; + + return node; + } + + private JsonNode ReadValue(Type type, object value) + { + if (value == null) + { + return XNull.Instance; + } + + var member = TypeDetails.Get(type); + + return ReadValue(member, value); + } + + private JsonNode ReadValue(TypeDetails type, object value) + { + if (value == null) + { + return XNull.Instance; + } + + if (type.JsonConverter != null) + { + return type.JsonConverter.ToJson(value); + } + else if (type.IsArray) + { + switch (Type.GetTypeCode(type.ElementType)) + { + case TypeCode.String: return CreateArray((string[])value); + case TypeCode.UInt16: return CreateArray((ushort[])value); + case TypeCode.UInt32: return CreateArray((uint[])value); + case TypeCode.UInt64: return CreateArray((ulong[])value); + case TypeCode.Int16: return CreateArray((short[])value); + case TypeCode.Int32: return CreateArray((int[])value); + case TypeCode.Int64: return CreateArray((long[])value); + case TypeCode.Single: return CreateArray((float[])value); + case TypeCode.Double: return CreateArray((double[])value); + default: return ReadArray((IEnumerable)value); + } + } + else if (value is IEnumerable) + { + if (type.IsList && type.ElementType != null) + { + switch (Type.GetTypeCode(type.ElementType)) + { + case TypeCode.String: return CreateList(value); + case TypeCode.UInt16: return CreateList(value); + case TypeCode.UInt32: return CreateList(value); + case TypeCode.UInt64: return CreateList(value); + case TypeCode.Int16: return CreateList(value); + case TypeCode.Int32: return CreateList(value); + case TypeCode.Int64: return CreateList(value); + case TypeCode.Single: return CreateList(value); + case TypeCode.Double: return CreateList(value); + } + } + + return ReadArray((IEnumerable)value); + } + else + { + // Complex object + return ReadObject(value); + } + } + + private XList CreateList(object value) => new XList((IList)value); + + private XImmutableArray CreateArray(T[] array) => new XImmutableArray(array); + + #endregion + + #endregion + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Serialization/PropertyTransformation.cs b/src/CostManagement/generated/runtime/Serialization/PropertyTransformation.cs new file mode 100644 index 000000000000..760e85700cd9 --- /dev/null +++ b/src/CostManagement/generated/runtime/Serialization/PropertyTransformation.cs @@ -0,0 +1,21 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + internal class PropertyTransformation + { + internal PropertyTransformation(string name, Func transformer) + { + Name = name ?? throw new ArgumentNullException(nameof(name)); + Transformer = transformer ?? throw new ArgumentNullException(nameof(transformer)); + } + + internal string Name { get; } + + internal Func Transformer { get; } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Serialization/SerializationOptions.cs b/src/CostManagement/generated/runtime/Serialization/SerializationOptions.cs new file mode 100644 index 000000000000..6570df1b5497 --- /dev/null +++ b/src/CostManagement/generated/runtime/Serialization/SerializationOptions.cs @@ -0,0 +1,65 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; +using System.Linq; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + internal class SerializationOptions + { + internal static readonly SerializationOptions Default = new SerializationOptions(); + + internal SerializationOptions() { } + + internal SerializationOptions( + string[] include = null, + bool ingoreNullValues = false) + { + Include = include; + IgnoreNullValues = ingoreNullValues; + } + + internal string[] Include { get; set; } + + internal string[] Exclude { get; set; } + + internal bool IgnoreNullValues { get; set; } + + internal PropertyTransformation[] Transformations { get; set; } + + internal Func PropertyNameTransformer { get; set; } + + internal int MaxDepth { get; set; } = 5; + + internal bool IsIncluded(string name) + { + if (Exclude != null) + { + return !Exclude.Any(exclude => exclude.Equals(name, StringComparison.OrdinalIgnoreCase)); + } + else if (Include != null) + { + return Include.Any(exclude => exclude.Equals(name, StringComparison.OrdinalIgnoreCase)); + } + + return true; + } + + internal PropertyTransformation GetTransformation(string propertyName) + { + if (Transformations == null) return null; + + foreach (var t in Transformations) + { + if (t.Name.Equals(propertyName, StringComparison.OrdinalIgnoreCase)) + { + return t; + } + } + + return null; + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/SerializationMode.cs b/src/CostManagement/generated/runtime/SerializationMode.cs new file mode 100644 index 000000000000..7fcf21e67c94 --- /dev/null +++ b/src/CostManagement/generated/runtime/SerializationMode.cs @@ -0,0 +1,16 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime +{ + [System.Flags] + public enum SerializationMode + { + None = 0, + IncludeHeaders = 1 << 0, + IncludeReadOnly = 1 << 1, + + IncludeAll = IncludeHeaders | IncludeReadOnly + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/TypeConverterExtensions.cs b/src/CostManagement/generated/runtime/TypeConverterExtensions.cs new file mode 100644 index 000000000000..124474835e2b --- /dev/null +++ b/src/CostManagement/generated/runtime/TypeConverterExtensions.cs @@ -0,0 +1,190 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System.IO; +using System.Linq; +using System.Xml; +using System.Xml.Serialization; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.PowerShell +{ + internal static class TypeConverterExtensions + { + internal static T[] SelectToArray(object source, System.Func converter) + { + // null begets null + if (source == null) + { + return null; + } + + // single values and strings are just encapsulated in the array. + if (source is string || !(source is System.Collections.IEnumerable)) + { + try + { + return new T[] { (T)converter(source) }; + } +#if DEBUG + catch (System.Exception E) + { + System.Console.Error.WriteLine($"{E.GetType().Name}/{E.Message}/{E.StackTrace}"); + } +#else + catch + { + // silent conversion fail + } +#endif + return new T[0]; // empty result if couldn't convert. + } + + var result = new System.Collections.Generic.List(); + foreach (var each in (System.Collections.IEnumerable)source) + { + try + { + result.Add((T)converter(each)); + } +#if DEBUG + catch (System.Exception E) + { + System.Console.Error.WriteLine($"{E.GetType().Name}/{E.Message}/{E.StackTrace}"); + } +#else + catch + { + // silent conversion fail + } +#endif + } + return result.ToArray(); + } + + internal static System.Collections.Generic.IEnumerable GetPropertyKeys(this System.Collections.Generic.IDictionary dictionary) + { + if (null != dictionary) + { + foreach (var each in dictionary.Keys) + { + yield return each; + } + } + } + internal static System.Collections.Generic.IEnumerable GetPropertyKeys(this System.Collections.IDictionary dictionary) + { + if (null != dictionary) + { + foreach (var each in dictionary.Keys) + { + yield return each; + } + } + } + internal static System.Collections.Generic.IEnumerable GetPropertyKeys(this System.Management.Automation.PSObject instance) + { + if (null != instance) + { + foreach (var each in instance.Properties) + { + yield return each; + } + } + } + + internal static System.Collections.Generic.IEnumerable> GetFilteredProperties(this System.Collections.Generic.IDictionary instance, global::System.Collections.Generic.HashSet exclusions = null, global::System.Collections.Generic.HashSet inclusions = null) + { + return (null == instance || instance.Count == 0) ? + Enumerable.Empty>() : + instance.Keys + .Where(key => + !(true == exclusions?.Contains(key?.ToString())) + && (false != inclusions?.Contains(key?.ToString()))) + .Select(key => new System.Collections.Generic.KeyValuePair(key, instance[key])); + } + + internal static System.Collections.Generic.IEnumerable> GetFilteredProperties(this System.Collections.IDictionary instance, global::System.Collections.Generic.HashSet exclusions = null, global::System.Collections.Generic.HashSet inclusions = null) + { + return (null == instance || instance.Count == 0) ? + Enumerable.Empty>() : + instance.Keys.OfType() + .Where(key => + !(true == exclusions?.Contains(key?.ToString())) + && (false != inclusions?.Contains(key?.ToString()))) + .Select(key => new System.Collections.Generic.KeyValuePair(key, instance[key])); + } + + internal static System.Collections.Generic.IEnumerable> GetFilteredProperties(this System.Management.Automation.PSObject instance, global::System.Collections.Generic.HashSet exclusions = null, global::System.Collections.Generic.HashSet inclusions = null) + { + // new global::System.Collections.Generic.HashSet(System.StringComparer.InvariantCultureIgnoreCase) + return (null == instance || !instance.Properties.Any()) ? + Enumerable.Empty>() : + instance.Properties + .Where(property => + !(true == exclusions?.Contains(property.Name)) + && (false != inclusions?.Contains(property.Name))) + .Select(property => new System.Collections.Generic.KeyValuePair(property.Name, property.Value)); + } + + + internal static T GetValueForProperty(this System.Collections.Generic.IDictionary dictionary, string propertyName, T defaultValue, System.Func converter) + { + try + { + var key = System.Linq.Enumerable.FirstOrDefault(dictionary.Keys, each => System.String.Equals(each.ToString(), propertyName, System.StringComparison.CurrentCultureIgnoreCase)); + return key == null ? defaultValue : (T)converter(dictionary[key]); + } +#if DEBUG + catch (System.Exception E) + { + System.Console.Error.WriteLine($"{E.GetType().Name}/{E.Message}/{E.StackTrace}"); + } +#else + catch + { + } +#endif + return defaultValue; + } + internal static T GetValueForProperty(this System.Collections.IDictionary dictionary, string propertyName, T defaultValue, System.Func converter) + { + try + { + var key = System.Linq.Enumerable.FirstOrDefault(dictionary.Keys.OfType(), each => System.String.Equals(each.ToString(), propertyName, System.StringComparison.CurrentCultureIgnoreCase)); + return key == null ? defaultValue : (T)converter(dictionary[key]); + } +#if DEBUG + catch (System.Exception E) + { + System.Console.Error.WriteLine($"{E.GetType().Name}/{E.Message}/{E.StackTrace}"); + } +#else + catch + { + } +#endif + return defaultValue; + } + + internal static T GetValueForProperty(this System.Management.Automation.PSObject psObject, string propertyName, T defaultValue, System.Func converter) + { + try + { + var property = System.Linq.Enumerable.FirstOrDefault(psObject.Properties, each => System.String.Equals(each.Name.ToString(), propertyName, System.StringComparison.CurrentCultureIgnoreCase)); + return property == null ? defaultValue : (T)converter(property.Value); + } +#if DEBUG + catch (System.Exception E) + { + System.Console.Error.WriteLine($"{E.GetType().Name}/{E.Message}/{E.StackTrace}"); + } +#else + catch + { + } +#endif + return defaultValue; + } + } +} diff --git a/src/CostManagement/generated/runtime/UndeclaredResponseException.cs b/src/CostManagement/generated/runtime/UndeclaredResponseException.cs new file mode 100644 index 000000000000..a0e434083dd7 --- /dev/null +++ b/src/CostManagement/generated/runtime/UndeclaredResponseException.cs @@ -0,0 +1,104 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime +{ + using System; + using System.Net.Http; + using System.Net.Http.Headers; + using static Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Extensions; + + public class RestException : Exception, IDisposable + { + public System.Net.HttpStatusCode StatusCode { get; set; } + public string Code { get; protected set; } + protected string message; + public HttpRequestMessage RequestMessage { get; protected set; } + public HttpResponseHeaders ResponseHeaders { get; protected set; } + + public string ResponseBody { get; protected set; } + public string ClientRequestId { get; protected set; } + public string RequestId { get; protected set; } + + public override string Message => message; + public string Action { get; protected set; } + + public RestException(System.Net.Http.HttpResponseMessage response) + { + StatusCode = response.StatusCode; + //CloneWithContent will not work here since the content is disposed after sendAsync + //Besides, it seems there is no need for the request content cloned here. + RequestMessage = response.RequestMessage.Clone(); + ResponseBody = response.Content.ReadAsStringAsync().Result; + ResponseHeaders = response.Headers; + + RequestId = response.GetFirstHeader("x-ms-request-id"); + ClientRequestId = response.GetFirstHeader("x-ms-client-request-id"); + + try + { + // try to parse the body as JSON, and see if a code and message are in there. + var json = Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonNode.Parse(ResponseBody) as Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json.JsonObject; + + // see if there is an error block in the body + json = json.Property("error") ?? json; + + { Code = If(json?.PropertyT("code"), out var c) ? (string)c : (string)StatusCode.ToString(); } + { message = If(json?.PropertyT("message"), out var m) ? (string)m : (string)Message; } + { Action = If(json?.PropertyT("action"), out var a) ? (string)a : (string)Action; } + } +#if DEBUG + catch (System.Exception E) + { + System.Console.Error.WriteLine($"{E.GetType().Name}/{E.Message}/{E.StackTrace}"); + } +#else + catch + { + // couldn't get the code/message from the body response. + // we'll create one below. + } +#endif + if (string.IsNullOrEmpty(message)) + { + if (StatusCode >= System.Net.HttpStatusCode.BadRequest && StatusCode < System.Net.HttpStatusCode.InternalServerError) + { + message = $"The server responded with a Request Error, Status: {StatusCode}"; + } + else if (StatusCode >= System.Net.HttpStatusCode.InternalServerError) + { + message = $"The server responded with a Server Error, Status: {StatusCode}"; + } + else + { + message = $"The server responded with an unrecognized response, Status: {StatusCode}"; + } + } + } + + public void Dispose() + { + ((IDisposable)RequestMessage).Dispose(); + } + } + + public class RestException : RestException + { + public T Error { get; protected set; } + public RestException(System.Net.Http.HttpResponseMessage response, T error) : base(response) + { + Error = error; + } + } + + + public class UndeclaredResponseException : RestException + { + public UndeclaredResponseException(System.Net.Http.HttpResponseMessage response) : base(response) + { + + } + } +} \ No newline at end of file diff --git a/src/CostManagement/generated/runtime/Writers/JsonWriter.cs b/src/CostManagement/generated/runtime/Writers/JsonWriter.cs new file mode 100644 index 000000000000..5f928b30827b --- /dev/null +++ b/src/CostManagement/generated/runtime/Writers/JsonWriter.cs @@ -0,0 +1,223 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +using System; +using System.Collections.Generic; +using System.IO; +using System.Web; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.Json +{ + internal class JsonWriter + { + const string indentation = " "; // 2 spaces + + private readonly bool pretty; + private readonly TextWriter writer; + + protected int currentLevel = 0; + + internal JsonWriter(TextWriter writer, bool pretty = true) + { + this.writer = writer ?? throw new ArgumentNullException(nameof(writer)); + this.pretty = pretty; + } + + internal void WriteNode(JsonNode node) + { + switch (node.Type) + { + case JsonType.Array: WriteArray((IEnumerable)node); break; + case JsonType.Object: WriteObject((JsonObject)node); break; + + // Primitives + case JsonType.Binary: WriteBinary((XBinary)node); break; + case JsonType.Boolean: WriteBoolean((bool)node); break; + case JsonType.Date: WriteDate((JsonDate)node); break; + case JsonType.Null: WriteNull(); break; + case JsonType.Number: WriteNumber((JsonNumber)node); break; + case JsonType.String: WriteString(node); break; + } + } + + internal void WriteArray(IEnumerable array) + { + currentLevel++; + + writer.Write('['); + + bool doIndentation = false; + + if (pretty) + { + foreach (var node in array) + { + if (node.Type == JsonType.Object || node.Type == JsonType.Array) + { + doIndentation = true; + + break; + } + } + } + + bool isFirst = true; + + foreach (JsonNode node in array) + { + if (!isFirst) writer.Write(','); + + if (doIndentation) + { + WriteIndent(); + } + else if (pretty) + { + writer.Write(' '); + } + + WriteNode(node); + + isFirst = false; + } + + currentLevel--; + + if (doIndentation) + { + WriteIndent(); + } + else if (pretty) + { + writer.Write(' '); + } + + writer.Write(']'); + } + + internal void WriteIndent() + { + if (pretty) + { + writer.Write(Environment.NewLine); + + for (int level = 0; level < currentLevel; level++) + { + writer.Write(indentation); + } + } + } + + internal void WriteObject(JsonObject obj) + { + currentLevel++; + + writer.Write('{'); + + bool isFirst = true; + + foreach (var field in obj) + { + if (!isFirst) writer.Write(','); + + WriteIndent(); + + WriteFieldName(field.Key); + + writer.Write(':'); + + if (pretty) + { + writer.Write(' '); + } + + // Write the field value + WriteNode(field.Value); + + isFirst = false; + } + + currentLevel--; + + WriteIndent(); + + writer.Write('}'); + } + + internal void WriteFieldName(string fieldName) + { + writer.Write('"'); + writer.Write(HttpUtility.JavaScriptStringEncode(fieldName)); + writer.Write('"'); + } + + #region Primitives + + internal void WriteBinary(XBinary value) + { + writer.Write('"'); + writer.Write(value.ToString()); + writer.Write('"'); + } + + internal void WriteBoolean(bool value) + { + writer.Write(value ? "true" : "false"); + } + + internal void WriteDate(JsonDate date) + { + if (date.ToDateTime().Year == 1) + { + WriteNull(); + } + else + { + writer.Write('"'); + writer.Write(date.ToIsoString()); + writer.Write('"'); + } + } + + internal void WriteNull() + { + writer.Write("null"); + } + + internal void WriteNumber(JsonNumber number) + { + if (number.Overflows) + { + writer.Write('"'); + writer.Write(number.Value); + writer.Write('"'); + } + else + { + writer.Write(number.Value); + } + } + + internal void WriteString(string text) + { + if (text == null) + { + WriteNull(); + } + else + { + writer.Write('"'); + + writer.Write(HttpUtility.JavaScriptStringEncode(text)); + + writer.Write('"'); + } + } + + #endregion + } +} + + +// TODO: Replace with System.Text.Json when available diff --git a/src/CostManagement/generated/runtime/delegates.cs b/src/CostManagement/generated/runtime/delegates.cs new file mode 100644 index 000000000000..5b8571919c4d --- /dev/null +++ b/src/CostManagement/generated/runtime/delegates.cs @@ -0,0 +1,23 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +namespace Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime +{ + using System; + using System.Collections; + using System.Collections.Generic; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + using GetEventData=System.Func; + + public delegate Task SendAsync(HttpRequestMessage request, IEventListener callback); + public delegate Task SendAsyncStep(HttpRequestMessage request, IEventListener callback, ISendAsync next); + public delegate Task SignalEvent(string id, CancellationToken token, GetEventData getEventData); + public delegate Task Event(EventData message); + public delegate void SynchEvent(EventData message); + public delegate Task OnResponse(Response message); + public delegate Task OnResponse(Response message); +} \ No newline at end of file diff --git a/src/CostManagement/help/Az.CostManagement.md b/src/CostManagement/help/Az.CostManagement.md new file mode 100644 index 000000000000..517827181467 --- /dev/null +++ b/src/CostManagement/help/Az.CostManagement.md @@ -0,0 +1,46 @@ +--- +Module Name: Az.CostManagement +Module Guid: 4cd9af10-559e-4fb9-8dcd-d3e8eb9e03b7 +Download Help Link: https://docs.microsoft.com/en-us/powershell/module/az.costmanagement +Help Version: 1.0.0.0 +Locale: en-US +--- + +# Az.CostManagement Module +## Description +Microsoft Azure PowerShell: Cost cmdlets + +## Az.CostManagement Cmdlets +### [Get-AzCostManagementExport](Get-AzCostManagementExport.md) +The operation to get the export for the defined scope by export name. + +### [Get-AzCostManagementExportExecutionHistory](Get-AzCostManagementExportExecutionHistory.md) +The operation to get the execution history of an export for the defined scope and export name. + +### [Invoke-AzCostManagementExecuteExport](Invoke-AzCostManagementExecuteExport.md) +The operation to execute an export. + +### [Invoke-AzCostManagementQuery](Invoke-AzCostManagementQuery.md) +Query the usage data for scope defined. + +### [New-AzCostManagementExport](New-AzCostManagementExport.md) +The operation to create or update a export. +Update operation requires latest eTag to be set in the request. +You may obtain the latest eTag by performing a get operation. +Create operation does not require eTag. + +### [New-AzCostManagementQueryComparisonExpressionObject](New-AzCostManagementQueryComparisonExpressionObject.md) +Create a in-memory object for QueryComparisonExpression + +### [New-AzCostManagementQueryFilterObject](New-AzCostManagementQueryFilterObject.md) +Create a in-memory object for QueryFilter + +### [Remove-AzCostManagementExport](Remove-AzCostManagementExport.md) +The operation to delete a export. + +### [Update-AzCostManagementExport](Update-AzCostManagementExport.md) +The operation to create or update a export. +Update operation requires latest eTag to be set in the request. +You may obtain the latest eTag by performing a get operation. +Create operation does not require eTag. + diff --git a/src/CostManagement/help/Get-AzCostManagementExport.md b/src/CostManagement/help/Get-AzCostManagementExport.md new file mode 100644 index 000000000000..0e448b2a32fe --- /dev/null +++ b/src/CostManagement/help/Get-AzCostManagementExport.md @@ -0,0 +1,171 @@ +--- +external help file: +Module Name: Az.CostManagement +online version: https://docs.microsoft.com/en-us/powershell/module/az.costmanagement/get-azcostmanagementexport +schema: 2.0.0 +--- + +# Get-AzCostManagementExport + +## SYNOPSIS +The operation to get the export for the defined scope by export name. + +## SYNTAX + +### List (Default) +``` +Get-AzCostManagementExport -Scope [-Expand ] [-DefaultProfile ] + [] +``` + +### Get +``` +Get-AzCostManagementExport -Name -Scope [-Expand ] [-DefaultProfile ] + [] +``` + +### GetViaIdentity +``` +Get-AzCostManagementExport -InputObject [-Expand ] + [-DefaultProfile ] [] +``` + +## DESCRIPTION +The operation to get the export for the defined scope by export name. + +## EXAMPLES + +### Example 1: Get all AzCostManagementExports by scope +```powershell +PS C:\> Get-AzCostManagementExport -Scope 'subscriptions/**********' + +ETag Name Type +---- ---- ---- +"************" TestExport Microsoft.CostManagement/exports +"************" TestExport1 Microsoft.CostManagement/exports +"************" TestExport2 Microsoft.CostManagement/exports +``` + +Get all AzCostManagementExports by Scope + +### Example 2: Get AzCostManagementExport by Name and scope +```powershell +PS C:\> Get-AzCostManagementExport -Name 'TestExport' -Scope 'subscriptions/**********' + +ETag Name Type +---- ---- ---- +"************" TestExport Microsoft.CostManagement/exports +``` + +Get AzCostManagementExport by Name and scope + +## PARAMETERS + +### -DefaultProfile +The credentials, account, tenant, and subscription used for communication with Azure. + +```yaml +Type: System.Management.Automation.PSObject +Parameter Sets: (All) +Aliases: AzureRMContext, AzureCredential + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Expand +May be used to expand the properties within an export. +Currently only 'runHistory' is supported and will return information for the last 10 executions of the export. + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -InputObject +Identity Parameter +To construct, see NOTES section for INPUTOBJECT properties and create a hash table. + +```yaml +Type: Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity +Parameter Sets: GetViaIdentity +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByValue) +Accept wildcard characters: False +``` + +### -Name +Export Name. + +```yaml +Type: System.String +Parameter Sets: Get +Aliases: ExportName + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Scope +This parameter defines the scope of costmanagement from different perspectives 'Subscription','ResourceGroup' and 'Provide Service'. + +```yaml +Type: System.String +Parameter Sets: Get, List +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity + +## OUTPUTS + +### Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport + +## NOTES + +ALIASES + +COMPLEX PARAMETER PROPERTIES + +To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables. + + +INPUTOBJECT : Identity Parameter + - `[AlertId ]`: Alert ID + - `[ExportName ]`: Export Name. + - `[ExternalCloudProviderId ]`: This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' for consolidated account used with dimension/query operations. + - `[ExternalCloudProviderType ]`: The external cloud provider type associated with dimension/query operations. This includes 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated account. + - `[Id ]`: Resource identity path + - `[Scope ]`: The scope associated with view operations. This includes 'subscriptions/{subscriptionId}' for subscription scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for BillingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' for InvoiceSection scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope, 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for External Billing Account scope and 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for External Subscription scope. + - `[ViewName ]`: View name + +## RELATED LINKS + diff --git a/src/CostManagement/help/Get-AzCostManagementExportExecutionHistory.md b/src/CostManagement/help/Get-AzCostManagementExportExecutionHistory.md new file mode 100644 index 000000000000..ffafcc7d5381 --- /dev/null +++ b/src/CostManagement/help/Get-AzCostManagementExportExecutionHistory.md @@ -0,0 +1,150 @@ +--- +external help file: +Module Name: Az.CostManagement +online version: https://docs.microsoft.com/en-us/powershell/module/az.costmanagement/get-azcostmanagementexportexecutionhistory +schema: 2.0.0 +--- + +# Get-AzCostManagementExportExecutionHistory + +## SYNOPSIS +The operation to get the execution history of an export for the defined scope and export name. + +## SYNTAX + +### Get (Default) +``` +Get-AzCostManagementExportExecutionHistory -ExportName -Scope [-DefaultProfile ] + [] +``` + +### GetViaIdentity +``` +Get-AzCostManagementExportExecutionHistory -InputObject [-DefaultProfile ] + [] +``` + +## DESCRIPTION +The operation to get the execution history of an export for the defined scope and export name. + +## EXAMPLES + +### Example 1: Get AzCostManagementExportExecutionHistory +```powershell +PS C:\> Get-AzCostManagementExportExecutionHistory -ExportName 'TestExport' -Scope 'subscriptions/**********' + +ExecutionType ProcessingStartTime ProcessingEndTime Status FileName +------------- ------------------- ----------------- ------ -------- +Scheduled 2020/6/11 12:03:20 2020/6/11 12:03:43 Completed ad-hoc/TestExport/20200601-20200630/TestExport_00000000-0000-0000-0000-000000000000.csv +Scheduled 2020/6/12 12:03:37 2020/6/12 12:03:48 Completed ad-hoc/TestExport/20200601-20200630/TestExport_00000000-0000-0000-0000-000000000000.csv +``` + +Get AzCostManagementExportExecutionHistory By ExportName and Scope + +### Example 2: Get AzCostManagementExportExecutionHistory by InputObject +```powershell +PS C:\> $getExport = Get-AzCostManagementExport -Name 'TestExport' -Scope 'subscriptions/**********' +Get-AzCostManagementExportExecutionHistory -InputObject $getExport + +ExecutionType ProcessingStartTime ProcessingEndTime Status FileName +------------- ------------------- ----------------- ------ -------- +Scheduled 2020/6/11 12:03:20 2020/6/11 12:03:43 Completed ad-hoc/TestExport/20200601-20200630/TestExport_00000000-0000-0000-0000-000000000000.csv +Scheduled 2020/6/12 12:03:37 2020/6/12 12:03:48 Completed ad-hoc/TestExport/20200601-20200630/ +``` + +Get AzCostManagementExportExecutionHistory By InputObject + +## PARAMETERS + +### -DefaultProfile +The credentials, account, tenant, and subscription used for communication with Azure. + +```yaml +Type: System.Management.Automation.PSObject +Parameter Sets: (All) +Aliases: AzureRMContext, AzureCredential + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ExportName +Export Name. + +```yaml +Type: System.String +Parameter Sets: Get +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -InputObject +Identity Parameter +To construct, see NOTES section for INPUTOBJECT properties and create a hash table. + +```yaml +Type: Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity +Parameter Sets: GetViaIdentity +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByValue) +Accept wildcard characters: False +``` + +### -Scope +This parameter defines the scope of costmanagement from different perspectives 'Subscription','ResourceGroup' and 'Provide Service'. + +```yaml +Type: System.String +Parameter Sets: Get +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity + +## OUTPUTS + +### Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExportExecution + +## NOTES + +ALIASES + +COMPLEX PARAMETER PROPERTIES + +To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables. + + +INPUTOBJECT : Identity Parameter + - `[AlertId ]`: Alert ID + - `[ExportName ]`: Export Name. + - `[ExternalCloudProviderId ]`: This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' for consolidated account used with dimension/query operations. + - `[ExternalCloudProviderType ]`: The external cloud provider type associated with dimension/query operations. This includes 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated account. + - `[Id ]`: Resource identity path + - `[Scope ]`: The scope associated with view operations. This includes 'subscriptions/{subscriptionId}' for subscription scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for BillingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' for InvoiceSection scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope, 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for External Billing Account scope and 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for External Subscription scope. + - `[ViewName ]`: View name + +## RELATED LINKS + diff --git a/src/CostManagement/help/Invoke-AzCostManagementExecuteExport.md b/src/CostManagement/help/Invoke-AzCostManagementExecuteExport.md new file mode 100644 index 000000000000..f9c775b6ec69 --- /dev/null +++ b/src/CostManagement/help/Invoke-AzCostManagementExecuteExport.md @@ -0,0 +1,188 @@ +--- +external help file: +Module Name: Az.CostManagement +online version: https://docs.microsoft.com/en-us/powershell/module/az.costmanagement/invoke-azcostmanagementexecuteexport +schema: 2.0.0 +--- + +# Invoke-AzCostManagementExecuteExport + +## SYNOPSIS +The operation to execute an export. + +## SYNTAX + +### Execute (Default) +``` +Invoke-AzCostManagementExecuteExport -ExportName -Scope [-DefaultProfile ] + [-PassThru] [-Confirm] [-WhatIf] [] +``` + +### ExecuteViaIdentity +``` +Invoke-AzCostManagementExecuteExport -InputObject [-DefaultProfile ] + [-PassThru] [-Confirm] [-WhatIf] [] +``` + +## DESCRIPTION +The operation to execute an export. + +## EXAMPLES + +### Example 1: Invoke Export by ExportName and Scope +```powershell +PS C:\> Invoke-AzCostManagementExecuteExport -ExportName 'TestExport' -Scope 'subscriptions/**********' + +``` + +Invoke Export by ExportName and Scope + +### Example 2: Invoke Export by InputObject +```powershell +PS C:\> $getExport = Get-AzCostManagementExport -Name 'TestExport' -Scope 'subscriptions/**********' +Invoke-AzCostManagementExecuteExport -InputObject $getExport + +``` + +Invoke Export by InputObject + +## PARAMETERS + +### -DefaultProfile +The credentials, account, tenant, and subscription used for communication with Azure. + +```yaml +Type: System.Management.Automation.PSObject +Parameter Sets: (All) +Aliases: AzureRMContext, AzureCredential + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ExportName +Export Name. + +```yaml +Type: System.String +Parameter Sets: Execute +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -InputObject +Identity Parameter +To construct, see NOTES section for INPUTOBJECT properties and create a hash table. + +```yaml +Type: Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity +Parameter Sets: ExecuteViaIdentity +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByValue) +Accept wildcard characters: False +``` + +### -PassThru +Returns true when the command succeeds + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Scope +This parameter defines the scope of costmanagement from different perspectives 'Subscription','ResourceGroup' and 'Provide Service'. + +```yaml +Type: System.String +Parameter Sets: Execute +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity + +## OUTPUTS + +### System.Boolean + +## NOTES + +ALIASES + +COMPLEX PARAMETER PROPERTIES + +To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables. + + +INPUTOBJECT : Identity Parameter + - `[AlertId ]`: Alert ID + - `[ExportName ]`: Export Name. + - `[ExternalCloudProviderId ]`: This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' for consolidated account used with dimension/query operations. + - `[ExternalCloudProviderType ]`: The external cloud provider type associated with dimension/query operations. This includes 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated account. + - `[Id ]`: Resource identity path + - `[Scope ]`: The scope associated with view operations. This includes 'subscriptions/{subscriptionId}' for subscription scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for BillingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' for InvoiceSection scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope, 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for External Billing Account scope and 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for External Subscription scope. + - `[ViewName ]`: View name + +## RELATED LINKS + diff --git a/src/CostManagement/help/Invoke-AzCostManagementQuery.md b/src/CostManagement/help/Invoke-AzCostManagementQuery.md new file mode 100644 index 000000000000..689b8333c326 --- /dev/null +++ b/src/CostManagement/help/Invoke-AzCostManagementQuery.md @@ -0,0 +1,325 @@ +--- +external help file: +Module Name: Az.CostManagement +online version: https://docs.microsoft.com/en-us/powershell/module/az.costmanagement/invoke-azcostmanagementquery +schema: 2.0.0 +--- + +# Invoke-AzCostManagementQuery + +## SYNOPSIS +Query the usage data for scope defined. + +## SYNTAX + +### UsageExpanded (Default) +``` +Invoke-AzCostManagementQuery -Scope -Timeframe -Type + [-ConfigurationColumn ] [-DatasetAggregation ] [-DatasetFilter ] + [-DatasetGranularity ] [-DatasetGrouping ] [-TimePeriodFrom ] + [-TimePeriodTo ] [-DefaultProfile ] [-Confirm] [-WhatIf] [] +``` + +### UsageExpanded1 +``` +Invoke-AzCostManagementQuery -ExternalCloudProviderId + -ExternalCloudProviderType -Timeframe -Type + [-ConfigurationColumn ] [-DatasetAggregation ] [-DatasetFilter ] + [-DatasetGranularity ] [-DatasetGrouping ] [-TimePeriodFrom ] + [-TimePeriodTo ] [-DefaultProfile ] [-Confirm] [-WhatIf] [] +``` + +## DESCRIPTION +Query the usage data for scope defined. + +## EXAMPLES + +### Example 1: Invoke AzCostManagementQuery by Scope +```powershell +PS C:\> Invoke-AzCostManagementQuery -Scope "/subscriptions/***********" -Timeframe MonthToDate -Type Usage -DatasetGranularity 'Daily' + +Column Row +------ --- +{UsageDate, Currency} {20201101 USD, 20201102 USD, 20201103 USD, 20201104 USD…} +``` + +Invoke AzCostManagementQuery by Scope + +### Example 2: Invoke AzCostManagementQuery by Scope with Dimensions +```powershell +PS C:\> $dimensions = New-AzCostManagementQueryComparisonExpressionObject -Name 'ResourceGroup' -Operator 'In' -Value 'API' +$filter = New-AzCostManagementQueryFilterObject -Dimensions $dimensions +Invoke-AzCostManagementQuery -Type Usage -Scope "subscriptions/***********" -DatasetGranularity 'Monthly' -DatasetFilter $filter -Timeframe MonthToDate -Debug + + +Column Row +------ --- +{BillingMonth, Currency} {} +``` + +Invoke AzCostManagementQuery by Scope with Dimensions + +## PARAMETERS + +### -ConfigurationColumn +Array of column names to be included in the query. + +```yaml +Type: System.String[] +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DatasetAggregation +Dictionary of aggregation expression to use in the query. + +```yaml +Type: System.Collections.Hashtable +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DatasetFilter +Has filter expression to use in the query. +To construct, see NOTES section for DATASETFILTER properties and create a hash table. + +```yaml +Type: Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DatasetGranularity +The granularity of rows in the query. + +```yaml +Type: Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DatasetGrouping +Array of group by expression to use in the query. +To construct, see NOTES section for DATASETGROUPING properties and create a hash table. + +```yaml +Type: Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryGrouping[] +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DefaultProfile +The credentials, account, tenant, and subscription used for communication with Azure. + +```yaml +Type: System.Management.Automation.PSObject +Parameter Sets: (All) +Aliases: AzureRMContext, AzureCredential + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ExternalCloudProviderId +This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' for consolidated account used with dimension/query operations. + +```yaml +Type: System.String +Parameter Sets: UsageExpanded1 +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ExternalCloudProviderType +The external cloud provider type associated with dimension/query operations. + +```yaml +Type: Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExternalCloudProviderType +Parameter Sets: UsageExpanded1 +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Scope +This includes 'subscriptions/{subscriptionId}/' for subscription scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId} for Management Group scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' for invoiceSection scope, and 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' specific for partners. + +```yaml +Type: System.String +Parameter Sets: UsageExpanded +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Timeframe +The time frame for pulling data for the query. + +```yaml +Type: Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType +Parameter Sets: (All) +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -TimePeriodFrom +The start date to pull data from. + +```yaml +Type: System.DateTime +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -TimePeriodTo +The end date to pull data to. + +```yaml +Type: System.DateTime +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Type +The type of the query. + +```yaml +Type: Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType +Parameter Sets: (All) +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryResult + +## NOTES + +ALIASES + +COMPLEX PARAMETER PROPERTIES + +To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables. + + +DATASETFILTER : Has filter expression to use in the query. + - `[And ]`: The logical "AND" expression. Must have at least 2 items. + - `[Dimensions ]`: Has comparison expression for a dimension + - `Name `: The name of the column to use in comparison. + - `Operator `: The operator to use for comparison. + - `Value `: Array of values to use for comparison + - `[Not ]`: The logical "NOT" expression. + - `[Or ]`: The logical "OR" expression. Must have at least 2 items. + - `[Tag ]`: Has comparison expression for a tag + +DATASETGROUPING : Array of group by expression to use in the query. + - `Name `: The name of the column to group. + - `Type `: Has type of the column to group. + +## RELATED LINKS + diff --git a/src/CostManagement/help/New-AzCostManagementExport.md b/src/CostManagement/help/New-AzCostManagementExport.md new file mode 100644 index 000000000000..7e575be45fc5 --- /dev/null +++ b/src/CostManagement/help/New-AzCostManagementExport.md @@ -0,0 +1,361 @@ +--- +external help file: +Module Name: Az.CostManagement +online version: https://docs.microsoft.com/en-us/powershell/module/az.costmanagement/new-azcostmanagementexport +schema: 2.0.0 +--- + +# New-AzCostManagementExport + +## SYNOPSIS +The operation to create or update a export. +Update operation requires latest eTag to be set in the request. +You may obtain the latest eTag by performing a get operation. +Create operation does not require eTag. + +## SYNTAX + +``` +New-AzCostManagementExport -Name -Scope [-ConfigurationColumn ] + [-DataSetGranularity ] [-DefinitionTimeframe ] [-DefinitionType ] + [-DestinationContainer ] [-DestinationResourceId ] [-DestinationRootFolderPath ] + [-Format ] [-RecurrencePeriodFrom ] [-RecurrencePeriodTo ] + [-ScheduleRecurrence ] [-ScheduleStatus ] [-TimePeriodFrom ] + [-TimePeriodTo ] [-DefaultProfile ] [-Confirm] [-WhatIf] [] +``` + +## DESCRIPTION +The operation to create or update a export. +Update operation requires latest eTag to be set in the request. +You may obtain the latest eTag by performing a get operation. +Create operation does not require eTag. + +## EXAMPLES + +### Example 1: Create an AzCostManagementExport +```powershell +PS C:\> New-AzCostManagementExport -Scope "subscriptions/***********" -Name "CostManagementExportTest" -ScheduleStatus "Active" -ScheduleRecurrence "Daily" -RecurrencePeriodFrom "2020-10-31T20:00:00Z" -RecurrencePeriodTo "2020-11-30T00:00:00Z" -Format "Csv" -DestinationResourceId "/subscriptions/*************/resourceGroups/ResourceGroupTest/providers/Microsoft.Storage/storageAccounts/storageAccountTest" ` -DestinationContainer "exports" -DestinationRootFolderPath "ad-hoc" -DefinitionType "Usage" -DefinitionTimeframe "MonthToDate" -DatasetGranularity "Daily" + +ETag Name Type +---- ---- ---- +"********" TestExportDatasetAggregationInfosagdhaghj Microsoft.CostManagement/exports +``` + +Create an AzCostManagementExport + +## PARAMETERS + +### -ConfigurationColumn +Array of column names to be included in the export. +If not provided then the export will include all available columns. +The available columns can vary by customer channel (see examples). + +```yaml +Type: System.String[] +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DataSetGranularity +The granularity of rows in the export. +Currently only 'Daily' is supported. + +```yaml +Type: Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DefaultProfile +The credentials, account, tenant, and subscription used for communication with Azure. + +```yaml +Type: System.Management.Automation.PSObject +Parameter Sets: (All) +Aliases: AzureRMContext, AzureCredential + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DefinitionTimeframe +The time frame for pulling data for the export. +If custom, then a specific time period must be provided. + +```yaml +Type: Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DefinitionType +The type of the export. +Note that 'Usage' is equivalent to 'ActualCost' and is applicable to exports that do not yet provide data for charges or amortization for service reservations. + +```yaml +Type: Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DestinationContainer +The name of the container where exports will be uploaded. + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DestinationResourceId +The resource id of the storage account where exports will be delivered. + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DestinationRootFolderPath +The name of the directory where exports will be uploaded. + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Format +[Parameter()] +[Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] +[System.String] +# eTag of the resource. +# To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not. +${ETag}, +The format of the export being delivered. +Currently only 'Csv' is supported. + +```yaml +Type: Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Name +Export Name. + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: ExportName + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -RecurrencePeriodFrom +The start date of recurrence. + +```yaml +Type: System.DateTime +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -RecurrencePeriodTo +The end date of recurrence. + +```yaml +Type: System.DateTime +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ScheduleRecurrence +The schedule recurrence. + +```yaml +Type: Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ScheduleStatus +The status of the export's schedule. +If 'Inactive', the export's schedule is paused. + +```yaml +Type: Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Scope +This parameter defines the scope of costmanagement from different perspectives 'Subscription','ResourceGroup' and 'Provide Service'. + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -TimePeriodFrom +The start date for export data. + +```yaml +Type: System.DateTime +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -TimePeriodTo +The end date for export data. + +```yaml +Type: System.DateTime +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport + +## NOTES + +ALIASES + +## RELATED LINKS + diff --git a/src/CostManagement/help/New-AzCostManagementQueryComparisonExpressionObject.md b/src/CostManagement/help/New-AzCostManagementQueryComparisonExpressionObject.md new file mode 100644 index 000000000000..9d238d9a8aeb --- /dev/null +++ b/src/CostManagement/help/New-AzCostManagementQueryComparisonExpressionObject.md @@ -0,0 +1,97 @@ +--- +external help file: +Module Name: Az.CostManagement +online version: https://docs.microsoft.com/en-us/powershell/module/az.CostManagement/new-AzCostManagementQueryComparisonExpressionObject +schema: 2.0.0 +--- + +# New-AzCostManagementQueryComparisonExpressionObject + +## SYNOPSIS +Create a in-memory object for QueryComparisonExpression + +## SYNTAX + +``` +New-AzCostManagementQueryComparisonExpressionObject -Name -Operator -Value + [] +``` + +## DESCRIPTION +Create a in-memory object for QueryComparisonExpression + +## EXAMPLES + +### Example 1: Create a comparison expression object of query for cost management export +```powershell +PS C:\> New-AzCostManagementQueryComparisonExpressionObject -Name 'ResourceLocation' -Operator In -Value @('East US', 'West Europe') + +Name Operator Value +---- -------- ----- +ResourceLocation In {East US, West Europe} +``` + +This command creates a comparison expression object of query for cost management export. + +## PARAMETERS + +### -Name +The name of the column to use in comparison. + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Operator +The operator to use for comparison. + +```yaml +Type: Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.OperatorType +Parameter Sets: (All) +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Value +Array of values to use for comparison. + +```yaml +Type: System.String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryComparisonExpression + +## NOTES + +ALIASES + +## RELATED LINKS + diff --git a/src/CostManagement/help/New-AzCostManagementQueryFilterObject.md b/src/CostManagement/help/New-AzCostManagementQueryFilterObject.md new file mode 100644 index 000000000000..12170474f4ce --- /dev/null +++ b/src/CostManagement/help/New-AzCostManagementQueryFilterObject.md @@ -0,0 +1,183 @@ +--- +external help file: +Module Name: Az.CostManagement +online version: https://docs.microsoft.com/en-us/powershell/module/az.CostManagement/new-AzCostManagementQueryFilterObject +schema: 2.0.0 +--- + +# New-AzCostManagementQueryFilterObject + +## SYNOPSIS +Create a in-memory object for QueryFilter + +## SYNTAX + +``` +New-AzCostManagementQueryFilterObject [-And ] [-Dimensions ] + [-Not ] [-Or ] [-Tag ] [] +``` + +## DESCRIPTION +Create a in-memory object for QueryFilter + +## EXAMPLES + +### Example 1: Create a filter object of query for cost management export +```powershell +PS C:\> $orDimension = New-AzCostManagementQueryComparisonExpressionObject -Name 'ResourceLocation' -Operator In -Value @('East US', 'West Europe') +PS C:\> $orTag = New-AzCostManagementQueryComparisonExpressionObject -Name 'Environment' -Operator In -Value @('UAT', 'Prod') +PS C:\> New-AzCostManagementQueryFilterObject -or @((New-AzCostManagementQueryFilterObject -Dimension $orDimension), (New-AzCostManagementQueryFilterObject -Tag $orTag)) + +And : +Dimension : Microsoft.Azure.PowerShell.Cmdlets.Cost.Models.Api20200601.QueryComparisonExpression +Not : Microsoft.Azure.PowerShell.Cmdlets.Cost.Models.Api20200601.QueryFilter +Or : {Microsoft.Azure.PowerShell.Cmdlets.Cost.Models.Api20200601.QueryFilter, Microsoft.Azure.PowerShell.Cmdlets.Cost.Models.Api20200601.QueryFilter} +Tag : Microsoft.Azure.PowerShell.Cmdlets.Cost.Models.Api20200601.QueryComparisonExpression +``` + +this command creates a filter object of query for cost management export. + +## PARAMETERS + +### -And +The logical "AND" expression. +Must have at least 2 items. +To construct, see NOTES section for AND properties and create a hash table. + +```yaml +Type: Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter[] +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Dimensions +Has comparison expression for a dimensions. +To construct, see NOTES section for DIMENSIONS properties and create a hash table. + +```yaml +Type: Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryComparisonExpression +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Not +The logical "NOT" expression. +To construct, see NOTES section for NOT properties and create a hash table. + +```yaml +Type: Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Or +The logical "OR" expression. +Must have at least 2 items. +To construct, see NOTES section for OR properties and create a hash table. + +```yaml +Type: Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryFilter[] +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Tag +Has comparison expression for a tag. +To construct, see NOTES section for TAG properties and create a hash table. + +```yaml +Type: Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IQueryComparisonExpression +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.QueryFilter + +## NOTES + +ALIASES + +COMPLEX PARAMETER PROPERTIES + +To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables. + + +AND : The logical "AND" expression. Must have at least 2 items. + - `[And ]`: The logical "AND" expression. Must have at least 2 items. + - `[Dimensions ]`: Has comparison expression for a dimension + - `Name `: The name of the column to use in comparison. + - `Operator `: The operator to use for comparison. + - `Value `: Array of values to use for comparison + - `[Not ]`: The logical "NOT" expression. + - `[Or ]`: The logical "OR" expression. Must have at least 2 items. + - `[Tag ]`: Has comparison expression for a tag + +DIMENSIONS : Has comparison expression for a dimensions. + - `Name `: The name of the column to use in comparison. + - `Operator `: The operator to use for comparison. + - `Value `: Array of values to use for comparison + +NOT : The logical "NOT" expression. + - `[And ]`: The logical "AND" expression. Must have at least 2 items. + - `[Dimensions ]`: Has comparison expression for a dimension + - `Name `: The name of the column to use in comparison. + - `Operator `: The operator to use for comparison. + - `Value `: Array of values to use for comparison + - `[Not ]`: The logical "NOT" expression. + - `[Or ]`: The logical "OR" expression. Must have at least 2 items. + - `[Tag ]`: Has comparison expression for a tag + +OR : The logical "OR" expression. Must have at least 2 items. + - `[And ]`: The logical "AND" expression. Must have at least 2 items. + - `[Dimensions ]`: Has comparison expression for a dimension + - `Name `: The name of the column to use in comparison. + - `Operator `: The operator to use for comparison. + - `Value `: Array of values to use for comparison + - `[Not ]`: The logical "NOT" expression. + - `[Or ]`: The logical "OR" expression. Must have at least 2 items. + - `[Tag ]`: Has comparison expression for a tag + +TAG : Has comparison expression for a tag. + - `Name `: The name of the column to use in comparison. + - `Operator `: The operator to use for comparison. + - `Value `: Array of values to use for comparison + +## RELATED LINKS + diff --git a/src/CostManagement/help/Remove-AzCostManagementExport.md b/src/CostManagement/help/Remove-AzCostManagementExport.md new file mode 100644 index 000000000000..145b0c8a8a17 --- /dev/null +++ b/src/CostManagement/help/Remove-AzCostManagementExport.md @@ -0,0 +1,190 @@ +--- +external help file: +Module Name: Az.CostManagement +online version: https://docs.microsoft.com/en-us/powershell/module/az.costmanagement/remove-azcostmanagementexport +schema: 2.0.0 +--- + +# Remove-AzCostManagementExport + +## SYNOPSIS +The operation to delete a export. + +## SYNTAX + +### Delete (Default) +``` +Remove-AzCostManagementExport -Name -Scope [-DefaultProfile ] [-PassThru] + [-Confirm] [-WhatIf] [] +``` + +### DeleteViaIdentity +``` +Remove-AzCostManagementExport -InputObject [-DefaultProfile ] [-PassThru] + [-Confirm] [-WhatIf] [] +``` + +## DESCRIPTION +The operation to delete a export. + +## EXAMPLES + +### Example 1: Delete the AzCostManagementExport by Scope and Name +```powershell +PS C:\> Remove-AzCostManagementExport -Scope 'subscriptions/********' -name 'TestExportDatasetAggregationInfoYouri' + + +``` + +Delete the AzCostManagementExport By Scope and ExportName + +### Example 2: Delete the AzCostManagementExport by Export Object +```powershell +PS C:\> $getExport = Get-AzCostManagementExport -Scope 'subscriptions/*********' -name 'TestExportDatasetAggregationYouori' +Remove-AzCostManagementExport -InputObject $getExport + + +``` + +Delete the AzCostManagementExport By InputObject + +## PARAMETERS + +### -DefaultProfile +The credentials, account, tenant, and subscription used for communication with Azure. + +```yaml +Type: System.Management.Automation.PSObject +Parameter Sets: (All) +Aliases: AzureRMContext, AzureCredential + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -InputObject +Identity Parameter +To construct, see NOTES section for INPUTOBJECT properties and create a hash table. + +```yaml +Type: Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity +Parameter Sets: DeleteViaIdentity +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByValue) +Accept wildcard characters: False +``` + +### -Name +Export Name. + +```yaml +Type: System.String +Parameter Sets: Delete +Aliases: ExportName + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -PassThru +Returns true when the command succeeds + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Scope +This parameter defines the scope of costmanagement from different perspectives 'Subscription','ResourceGroup' and 'Provide Service'. + +```yaml +Type: System.String +Parameter Sets: Delete +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity + +## OUTPUTS + +### System.Boolean + +## NOTES + +ALIASES + +COMPLEX PARAMETER PROPERTIES + +To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables. + + +INPUTOBJECT : Identity Parameter + - `[AlertId ]`: Alert ID + - `[ExportName ]`: Export Name. + - `[ExternalCloudProviderId ]`: This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' for consolidated account used with dimension/query operations. + - `[ExternalCloudProviderType ]`: The external cloud provider type associated with dimension/query operations. This includes 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated account. + - `[Id ]`: Resource identity path + - `[Scope ]`: The scope associated with view operations. This includes 'subscriptions/{subscriptionId}' for subscription scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for BillingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' for InvoiceSection scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope, 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for External Billing Account scope and 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for External Subscription scope. + - `[ViewName ]`: View name + +## RELATED LINKS + diff --git a/src/CostManagement/help/Update-AzCostManagementExport.md b/src/CostManagement/help/Update-AzCostManagementExport.md new file mode 100644 index 000000000000..e1f66ce4e5c0 --- /dev/null +++ b/src/CostManagement/help/Update-AzCostManagementExport.md @@ -0,0 +1,426 @@ +--- +external help file: +Module Name: Az.CostManagement +online version: https://docs.microsoft.com/en-us/powershell/module/az.costmanagement/update-azcostmanagementexport +schema: 2.0.0 +--- + +# Update-AzCostManagementExport + +## SYNOPSIS +The operation to create or update a export. +Update operation requires latest eTag to be set in the request. +You may obtain the latest eTag by performing a get operation. +Create operation does not require eTag. + +## SYNTAX + +### UpdateExpanded (Default) +``` +Update-AzCostManagementExport -Name -Scope [-ConfigurationColumn ] + [-DataSetGranularity ] [-DefinitionTimeframe ] [-DefinitionType ] + [-DestinationContainer ] [-DestinationResourceId ] [-DestinationRootFolderPath ] + [-ETag ] [-Format ] [-RecurrencePeriodFrom ] [-RecurrencePeriodTo ] + [-ScheduleRecurrence ] [-ScheduleStatus ] [-TimePeriodFrom ] + [-TimePeriodTo ] [-DefaultProfile ] [-Confirm] [-WhatIf] [] +``` + +### UpdateViaIdentityExpanded +``` +Update-AzCostManagementExport -InputObject [-ConfigurationColumn ] + [-DataSetGranularity ] [-DefinitionTimeframe ] [-DefinitionType ] + [-DestinationContainer ] [-DestinationResourceId ] [-DestinationRootFolderPath ] + [-ETag ] [-Format ] [-RecurrencePeriodFrom ] [-RecurrencePeriodTo ] + [-ScheduleRecurrence ] [-ScheduleStatus ] [-TimePeriodFrom ] + [-TimePeriodTo ] [-DefaultProfile ] [-Confirm] [-WhatIf] [] +``` + +## DESCRIPTION +The operation to create or update a export. +Update operation requires latest eTag to be set in the request. +You may obtain the latest eTag by performing a get operation. +Create operation does not require eTag. + +## EXAMPLES + +### Example 1: Update AzCostManagementExport by scope and name +```powershell +PS C:\> Update-AzCostManagementExport -Scope "subscriptions//*********" -Name "TestExport" -ScheduleRecurrence 'Weekly' + +ETag Name Type +---- ---- ---- +"********" TestExportDatasetAggregationInfo Microsoft.CostManagement/exports +``` + +Update AzCostManagementExport by Scope and name + +### Example 2: Update AzCostManagementExport by InputObject +```powershell +PS C:\> $oldExport = Get-AzCostManagementExport -Scope "subscriptions/*********" -Name "TestExport" +Update-AzCostManagementExport -InputObject $oldExport -ScheduleRecurrence 'Weekly' + +ETag Name Type +---- ---- ---- +"********" TestExportDatasetAggregationInfo Microsoft.CostManagement/exports +``` + +Update AzCostManagementExport by InputObject + +## PARAMETERS + +### -ConfigurationColumn +Array of column names to be included in the export. +If not provided then the export will include all available columns. +The available columns can vary by customer channel (see examples). + +```yaml +Type: System.String[] +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DataSetGranularity +The granularity of rows in the export. +Currently only 'Daily' is supported. + +```yaml +Type: Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DefaultProfile +The credentials, account, tenant, and subscription used for communication with Azure. + +```yaml +Type: System.Management.Automation.PSObject +Parameter Sets: (All) +Aliases: AzureRMContext, AzureCredential + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DefinitionTimeframe +The time frame for pulling data for the export. +If custom, then a specific time period must be provided. + +```yaml +Type: Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DefinitionType +The type of the export. +Note that 'Usage' is equivalent to 'ActualCost' and is applicable to exports that do not yet provide data for charges or amortization for service reservations. + +```yaml +Type: Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DestinationContainer +The name of the container where exports will be uploaded. + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DestinationResourceId +The resource id of the storage account where exports will be delivered. + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DestinationRootFolderPath +The name of the directory where exports will be uploaded. + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ETag +eTag of the resource. +To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not. + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Format +The format of the export being delivered. +Currently only 'Csv' is supported. + +```yaml +Type: Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -InputObject +Identity Parameter +To construct, see NOTES section for INPUTOBJECT properties and create a hash table. + +```yaml +Type: Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity +Parameter Sets: UpdateViaIdentityExpanded +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByValue) +Accept wildcard characters: False +``` + +### -Name +Export Name. + +```yaml +Type: System.String +Parameter Sets: UpdateExpanded +Aliases: ExportName + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -RecurrencePeriodFrom +The start date of recurrence. + +```yaml +Type: System.DateTime +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -RecurrencePeriodTo +The end date of recurrence. + +```yaml +Type: System.DateTime +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ScheduleRecurrence +The schedule recurrence. + +```yaml +Type: Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ScheduleStatus +The status of the export's schedule. +If 'Inactive', the export's schedule is paused. + +```yaml +Type: Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Scope +This parameter defines the scope of costmanagement from different perspectives 'Subscription','ResourceGroup' and 'Provide Service'. + +```yaml +Type: System.String +Parameter Sets: UpdateExpanded +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -TimePeriodFrom +The start date for export data. + +```yaml +Type: System.DateTime +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -TimePeriodTo +The end date for export data. + +```yaml +Type: System.DateTime +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity + +## OUTPUTS + +### Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport + +## NOTES + +ALIASES + +COMPLEX PARAMETER PROPERTIES + +To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables. + + +INPUTOBJECT : Identity Parameter + - `[AlertId ]`: Alert ID + - `[ExportName ]`: Export Name. + - `[ExternalCloudProviderId ]`: This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' for consolidated account used with dimension/query operations. + - `[ExternalCloudProviderType ]`: The external cloud provider type associated with dimension/query operations. This includes 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated account. + - `[Id ]`: Resource identity path + - `[Scope ]`: The scope associated with view operations. This includes 'subscriptions/{subscriptionId}' for subscription scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for BillingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' for InvoiceSection scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope, 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for External Billing Account scope and 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for External Subscription scope. + - `[ViewName ]`: View name + +## RELATED LINKS + diff --git a/src/CostManagement/how-to.md b/src/CostManagement/how-to.md new file mode 100644 index 000000000000..8ac954c6b92a --- /dev/null +++ b/src/CostManagement/how-to.md @@ -0,0 +1,58 @@ +# How-To +This document describes how to develop for `Az.CostManagement`. + +## Building `Az.CostManagement` +To build, run the `build-module.ps1` at the root of the module directory. This will generate the proxy script cmdlets that are the cmdlets being exported by this module. After the build completes, the proxy script cmdlets will be output to the `exports` folder. To read more about the proxy script cmdlets, look at the [readme.md](exports/readme.md) in the `exports` folder. + +## Creating custom cmdlets +To add cmdlets that were not generated by the REST specification, use the `custom` folder. This folder allows you to add handwritten `.ps1` and `.cs` files. Currently, we support using `.ps1` scripts as new cmdlets or as additional low-level variants (via `ParameterSet`), and `.cs` files as low-level (variants) cmdlets that the exported script cmdlets call. We do not support exporting any `.cs` (dll) cmdlets directly. To read more about custom cmdlets, look at the [readme.md](custom/readme.md) in the `custom` folder. + +## Generating documentation +To generate documentation, the process is now integrated into the `build-module.ps1` script. If you don't want to run this process as part of `build-module.ps1`, you can provide the `-NoDocs` switch. If you want to run documentation generation after the build process, you may still run the `generate-help.ps1` script. Overall, the process will look at the documentation comments in the generated and custom cmdlets and types, and create `.md` files into the `docs` folder. Additionally, this pulls in any examples from the `examples` folder and adds them to the generated help markdown documents. To read more about examples, look at the [readme.md](examples/readme.md) in the `examples` folder. To read more about documentation, look at the [readme.md](docs/readme.md) in the `docs` folder. + +## Testing `Az.CostManagement` +To test the cmdlets, we use [Pester](https://github.com/pester/Pester). Tests scripts (`.ps1`) should be added to the `test` folder. To execute the Pester tests, run the `test-module.ps1` script. This will run all tests in `playback` mode within the `test` folder. To read more about testing cmdlets, look at the [readme.md](examples/readme.md) in the `examples` folder. + +## Packing `Az.CostManagement` +To pack `Az.CostManagement` for distribution, run the `pack-module.ps1` script. This will take the contents of multiple directories and certain root-folder files to create a `.nupkg`. The structure of the `.nupkg` is created so it can be loaded part of a [PSRepository](https://docs.microsoft.com/en-us/powershell/module/powershellget/register-psrepository). Additionally, this package is in a format for distribution to the [PSGallery](https://www.powershellgallery.com/). For signing an Azure module, please contact the [Azure PowerShell](https://github.com/Azure/azure-powershell) team. + +## Module Script Details +There are multiple scripts created for performing different actions for developing `Az.CostManagement`. +- `build-module.ps1` + - Builds the module DLL (`./bin/Az.CostManagement.private.dll`), creates the exported cmdlets and documentation, generates custom cmdlet test stubs and exported cmdlet example stubs, and updates `./Az.CostManagement.psd1` with Azure profile information. + - **Parameters**: [`Switch` parameters] + - `-Run`: After building, creates an isolated PowerShell session and loads `Az.CostManagement`. + - `-Test`: After building, runs the `Pester` tests defined in the `test` folder. + - `-Docs`: After building, generates the Markdown documents for the modules into the `docs` folder. + - `-Pack`: After building, packages the module into a `.nupkg`. + - `-Code`: After building, opens a VSCode window with the module's directory and runs (see `-Run`) the module. + - `-Release`: Builds the module in `Release` configuration (as opposed to `Debug` configuration). + - `-NoDocs`: Supresses writing the documentation markdown files as part of the cmdlet exporting process. + - `-Debugger`: Used when attaching the debugger in Visual Studio to the PowerShell session, and running the build process without recompiling the DLL. This suppresses running the script as an isolated process. +- `run-module.ps1` + - Creates an isolated PowerShell session and loads `Az.CostManagement` into the session. + - Same as `-Run` in `build-module.ps1`. + - **Parameters**: [`Switch` parameters] + - `-Code`: Opens a VSCode window with the module's directory. + - Same as `-Code` in `build-module.ps1`. +- `generate-help.ps1` + - Generates the Markdown documents for the modules into the `docs` folder. + - Same as `-Docs` in `build-module.ps1`. +- `test-module.ps1` + - Runs the `Pester` tests defined in the `test` folder. + - Same as `-Test` in `build-module.ps1`. +- `pack-module.ps1` + - Packages the module into a `.nupkg` for distribution. + - Same as `-Pack` in `build-module.ps1`. +- `generate-help.ps1` + - Generates the Markdown documents for the modules into the `docs` folder. + - Same as `-Docs` in `build-module.ps1`. + - This process is now integrated into `build-module.ps1` automatically. To disable, use `-NoDocs` when running `build-module.ps1`. +- `export-surface.ps1` + - Generates Markdown documents for both the cmdlet surface and the model (class) surface of the module. + - These files are placed into the `resources` folder. + - Used for investigating the surface of your module. These are *not* documentation for distribution. +- `check-dependencies.ps1` + - Used in `run-module.ps1` and `test-module.ps1` to verify dependent modules are available to run those tasks. + - It will download local (within the module's directory structure) versions of those modules as needed. + - This script *does not* need to be ran by-hand. \ No newline at end of file diff --git a/src/CostManagement/internal/Az.CostManagement.internal.psm1 b/src/CostManagement/internal/Az.CostManagement.internal.psm1 new file mode 100644 index 000000000000..3422b1a9e074 --- /dev/null +++ b/src/CostManagement/internal/Az.CostManagement.internal.psm1 @@ -0,0 +1,38 @@ +# region Generated + # Load the private module dll + $null = Import-Module -PassThru -Name (Join-Path $PSScriptRoot '..\bin\Az.CostManagement.private.dll') + + # Get the private module's instance + $instance = [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Module]::Instance + + # Export nothing to clear implicit exports + Export-ModuleMember + + # Export proxy cmdlet scripts + $exportsPath = $PSScriptRoot + $directories = Get-ChildItem -Directory -Path $exportsPath + $profileDirectory = $null + if($instance.ProfileName) { + if(($directories | ForEach-Object { $_.Name }) -contains $instance.ProfileName) { + $profileDirectory = $directories | Where-Object { $_.Name -eq $instance.ProfileName } + } else { + # Don't export anything if the profile doesn't exist for the module + $exportsPath = $null + Write-Warning "Selected Azure profile '$($instance.ProfileName)' does not exist for module '$($instance.Name)'. No cmdlets were loaded." + } + } elseif(($directories | Measure-Object).Count -gt 0) { + # Load the last folder if no profile is selected + $profileDirectory = $directories | Select-Object -Last 1 + } + + if($profileDirectory) { + Write-Information "Loaded Azure profile '$($profileDirectory.Name)' for module '$($instance.Name)'" + $exportsPath = $profileDirectory.FullName + } + + if($exportsPath) { + Get-ChildItem -Path $exportsPath -Recurse -Include '*.ps1' -File | ForEach-Object { . $_.FullName } + $cmdletNames = Get-ScriptCmdlet -ScriptFolder $exportsPath + Export-ModuleMember -Function $cmdletNames -Alias (Get-ScriptCmdlet -ScriptFolder $exportsPath -AsAlias) + } +# endregion diff --git a/src/CostManagement/internal/Get-AzCostManagementOperation.ps1 b/src/CostManagement/internal/Get-AzCostManagementOperation.ps1 new file mode 100644 index 000000000000..7586e7847bcf --- /dev/null +++ b/src/CostManagement/internal/Get-AzCostManagementOperation.ps1 @@ -0,0 +1,121 @@ + +# ---------------------------------------------------------------------------------- +# +# Copyright Microsoft Corporation +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ---------------------------------------------------------------------------------- + +<# +.Synopsis +Lists all of the available cost management REST API operations. +.Description +Lists all of the available cost management REST API operations. +.Example +PS C:\> {{ Add code here }} + +{{ Add output here }} +.Example +PS C:\> {{ Add code here }} + +{{ Add output here }} + +.Outputs +Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperation +.Link +https://docs.microsoft.com/en-us/powershell/module/az.costmanagement/get-azcostmanagementoperation +#> +function Get-AzCostManagementOperation { +[OutputType([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperation])] +[CmdletBinding(DefaultParameterSetName='List', PositionalBinding=$false)] +param( + [Parameter()] + [Alias('AzureRMContext', 'AzureCredential')] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Azure')] + [System.Management.Automation.PSObject] + # The credentials, account, tenant, and subscription used for communication with Azure. + ${DefaultProfile}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Wait for .NET debugger to attach + ${Break}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be appended to the front of the pipeline + ${HttpPipelineAppend}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be prepended to the front of the pipeline + ${HttpPipelinePrepend}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Uri] + # The URI for the proxy server to use + ${Proxy}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.PSCredential] + # Credentials for a proxy server to use for the remote call + ${ProxyCredential}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Use the default credentials for the proxy + ${ProxyUseDefaultCredentials} +) + +begin { + try { + $outBuffer = $null + if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer)) { + $PSBoundParameters['OutBuffer'] = 1 + } + $parameterSet = $PSCmdlet.ParameterSetName + $mapping = @{ + List = 'Az.CostManagement.private\Get-AzCostManagementOperation_List'; + } + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet) + $scriptCmd = {& $wrappedCmd @PSBoundParameters} + $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin) + $steppablePipeline.Begin($PSCmdlet) + } catch { + throw + } +} + +process { + try { + $steppablePipeline.Process($_) + } catch { + throw + } +} + +end { + try { + $steppablePipeline.End() + } catch { + throw + } +} +} diff --git a/src/CostManagement/internal/New-AzCostManagementExport.ps1 b/src/CostManagement/internal/New-AzCostManagementExport.ps1 new file mode 100644 index 000000000000..659790547dec --- /dev/null +++ b/src/CostManagement/internal/New-AzCostManagementExport.ps1 @@ -0,0 +1,242 @@ + +# ---------------------------------------------------------------------------------- +# +# Copyright Microsoft Corporation +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ---------------------------------------------------------------------------------- + +<# +.Synopsis +The operation to create or update a export. +Update operation requires latest eTag to be set in the request. +You may obtain the latest eTag by performing a get operation. +Create operation does not require eTag. +.Description +The operation to create or update a export. +Update operation requires latest eTag to be set in the request. +You may obtain the latest eTag by performing a get operation. +Create operation does not require eTag. +.Example +PS C:\> New-AzCostManagementExport -Scope "subscriptions/***********" -Name "CostManagementExportTest" -ScheduleStatus "Active" -ScheduleRecurrence "Daily" -RecurrencePeriodFrom "2020-10-31T20:00:00Z" -RecurrencePeriodTo "2020-11-30T00:00:00Z" -Format "Csv" -DestinationResourceId "/subscriptions/*************/resourceGroups/ResourceGroupTest/providers/Microsoft.Storage/storageAccounts/storageAccountTest" ` -DestinationContainer "exports" -DestinationRootFolderPath "ad-hoc" -DefinitionType "Usage" -DefinitionTimeframe "MonthToDate" -DatasetGranularity "Daily" + +ETag Name Type +---- ---- ---- +"********" TestExportDatasetAggregationInfosagdhaghj Microsoft.CostManagement/exports + +.Outputs +Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport +.Link +https://docs.microsoft.com/en-us/powershell/module/az.costmanagement/new-azcostmanagementexport +#> +function New-AzCostManagementExport { +[OutputType([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport])] +[CmdletBinding(DefaultParameterSetName='CreateExpanded', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')] +param( + [Parameter(Mandatory)] + [Alias('ExportName')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [System.String] + # Export Name. + ${Name}, + + [Parameter(Mandatory)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [System.String] + # This parameter defines the scope of costmanagement from different perspectives 'Subscription','ResourceGroup' and 'Provide Service'. + ${Scope}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String[]] + # Array of column names to be included in the export. + # If not provided then the export will include all available columns. + # The available columns can vary by customer channel (see examples). + ${ConfigurationColumn}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType] + # The granularity of rows in the export. + # Currently only 'Daily' is supported. + ${DataSetGranularity}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType] + # The time frame for pulling data for the export. + # If custom, then a specific time period must be provided. + ${DefinitionTimeframe}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType] + # The type of the export. + # Note that 'Usage' is equivalent to 'ActualCost' and is applicable to exports that do not yet provide data for charges or amortization for service reservations. + ${DefinitionType}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String] + # The name of the container where exports will be uploaded. + ${DestinationContainer}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String] + # The resource id of the storage account where exports will be delivered. + ${DestinationResourceId}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String] + # The name of the directory where exports will be uploaded. + ${DestinationRootFolderPath}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String] + # eTag of the resource. + # To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not. + ${ETag}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType] + # The format of the export being delivered. + # Currently only 'Csv' is supported. + ${Format}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.DateTime] + # The start date of recurrence. + ${RecurrencePeriodFrom}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.DateTime] + # The end date of recurrence. + ${RecurrencePeriodTo}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType] + # The schedule recurrence. + ${ScheduleRecurrence}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType] + # The status of the export's schedule. + # If 'Inactive', the export's schedule is paused. + ${ScheduleStatus}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.DateTime] + # The start date for export data. + ${TimePeriodFrom}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.DateTime] + # The end date for export data. + ${TimePeriodTo}, + + [Parameter()] + [Alias('AzureRMContext', 'AzureCredential')] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Azure')] + [System.Management.Automation.PSObject] + # The credentials, account, tenant, and subscription used for communication with Azure. + ${DefaultProfile}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Wait for .NET debugger to attach + ${Break}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be appended to the front of the pipeline + ${HttpPipelineAppend}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be prepended to the front of the pipeline + ${HttpPipelinePrepend}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Uri] + # The URI for the proxy server to use + ${Proxy}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.PSCredential] + # Credentials for a proxy server to use for the remote call + ${ProxyCredential}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Use the default credentials for the proxy + ${ProxyUseDefaultCredentials} +) + +begin { + try { + $outBuffer = $null + if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer)) { + $PSBoundParameters['OutBuffer'] = 1 + } + $parameterSet = $PSCmdlet.ParameterSetName + $mapping = @{ + CreateExpanded = 'Az.CostManagement.private\New-AzCostManagementExport_CreateExpanded'; + } + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet) + $scriptCmd = {& $wrappedCmd @PSBoundParameters} + $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin) + $steppablePipeline.Begin($PSCmdlet) + } catch { + throw + } +} + +process { + try { + $steppablePipeline.Process($_) + } catch { + throw + } +} + +end { + try { + $steppablePipeline.End() + } catch { + throw + } +} +} diff --git a/src/CostManagement/internal/ProxyCmdletDefinitions.ps1 b/src/CostManagement/internal/ProxyCmdletDefinitions.ps1 new file mode 100644 index 000000000000..0945b1038fca --- /dev/null +++ b/src/CostManagement/internal/ProxyCmdletDefinitions.ps1 @@ -0,0 +1,635 @@ + +# ---------------------------------------------------------------------------------- +# +# Copyright Microsoft Corporation +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ---------------------------------------------------------------------------------- + +<# +.Synopsis +Lists all of the available cost management REST API operations. +.Description +Lists all of the available cost management REST API operations. +.Example +PS C:\> {{ Add code here }} + +{{ Add output here }} +.Example +PS C:\> {{ Add code here }} + +{{ Add output here }} + +.Outputs +Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperation +.Link +https://docs.microsoft.com/en-us/powershell/module/az.costmanagement/get-azcostmanagementoperation +#> +function Get-AzCostManagementOperation { +[OutputType([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IOperation])] +[CmdletBinding(DefaultParameterSetName='List', PositionalBinding=$false)] +param( + [Parameter()] + [Alias('AzureRMContext', 'AzureCredential')] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Azure')] + [System.Management.Automation.PSObject] + # The credentials, account, tenant, and subscription used for communication with Azure. + ${DefaultProfile}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Wait for .NET debugger to attach + ${Break}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be appended to the front of the pipeline + ${HttpPipelineAppend}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be prepended to the front of the pipeline + ${HttpPipelinePrepend}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Uri] + # The URI for the proxy server to use + ${Proxy}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.PSCredential] + # Credentials for a proxy server to use for the remote call + ${ProxyCredential}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Use the default credentials for the proxy + ${ProxyUseDefaultCredentials} +) + +begin { + try { + $outBuffer = $null + if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer)) { + $PSBoundParameters['OutBuffer'] = 1 + } + $parameterSet = $PSCmdlet.ParameterSetName + $mapping = @{ + List = 'Az.CostManagement.private\Get-AzCostManagementOperation_List'; + } + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet) + $scriptCmd = {& $wrappedCmd @PSBoundParameters} + $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin) + $steppablePipeline.Begin($PSCmdlet) + } catch { + throw + } +} + +process { + try { + $steppablePipeline.Process($_) + } catch { + throw + } +} + +end { + try { + $steppablePipeline.End() + } catch { + throw + } +} +} + +# ---------------------------------------------------------------------------------- +# +# Copyright Microsoft Corporation +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ---------------------------------------------------------------------------------- + +<# +.Synopsis +The operation to create or update a export. +Update operation requires latest eTag to be set in the request. +You may obtain the latest eTag by performing a get operation. +Create operation does not require eTag. +.Description +The operation to create or update a export. +Update operation requires latest eTag to be set in the request. +You may obtain the latest eTag by performing a get operation. +Create operation does not require eTag. +.Example +PS C:\> New-AzCostManagementExport -Scope "subscriptions/***********" -Name "CostManagementExportTest" -ScheduleStatus "Active" -ScheduleRecurrence "Daily" -RecurrencePeriodFrom "2020-10-31T20:00:00Z" -RecurrencePeriodTo "2020-11-30T00:00:00Z" -Format "Csv" -DestinationResourceId "/subscriptions/*************/resourceGroups/ResourceGroupTest/providers/Microsoft.Storage/storageAccounts/storageAccountTest" ` -DestinationContainer "exports" -DestinationRootFolderPath "ad-hoc" -DefinitionType "Usage" -DefinitionTimeframe "MonthToDate" -DatasetGranularity "Daily" + +ETag Name Type +---- ---- ---- +"********" TestExportDatasetAggregationInfosagdhaghj Microsoft.CostManagement/exports + +.Outputs +Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport +.Link +https://docs.microsoft.com/en-us/powershell/module/az.costmanagement/new-azcostmanagementexport +#> +function New-AzCostManagementExport { +[OutputType([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport])] +[CmdletBinding(DefaultParameterSetName='CreateExpanded', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')] +param( + [Parameter(Mandatory)] + [Alias('ExportName')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [System.String] + # Export Name. + ${Name}, + + [Parameter(Mandatory)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [System.String] + # This parameter defines the scope of costmanagement from different perspectives 'Subscription','ResourceGroup' and 'Provide Service'. + ${Scope}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String[]] + # Array of column names to be included in the export. + # If not provided then the export will include all available columns. + # The available columns can vary by customer channel (see examples). + ${ConfigurationColumn}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType] + # The granularity of rows in the export. + # Currently only 'Daily' is supported. + ${DataSetGranularity}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType] + # The time frame for pulling data for the export. + # If custom, then a specific time period must be provided. + ${DefinitionTimeframe}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType] + # The type of the export. + # Note that 'Usage' is equivalent to 'ActualCost' and is applicable to exports that do not yet provide data for charges or amortization for service reservations. + ${DefinitionType}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String] + # The name of the container where exports will be uploaded. + ${DestinationContainer}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String] + # The resource id of the storage account where exports will be delivered. + ${DestinationResourceId}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String] + # The name of the directory where exports will be uploaded. + ${DestinationRootFolderPath}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String] + # eTag of the resource. + # To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not. + ${ETag}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType] + # The format of the export being delivered. + # Currently only 'Csv' is supported. + ${Format}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.DateTime] + # The start date of recurrence. + ${RecurrencePeriodFrom}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.DateTime] + # The end date of recurrence. + ${RecurrencePeriodTo}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType] + # The schedule recurrence. + ${ScheduleRecurrence}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType] + # The status of the export's schedule. + # If 'Inactive', the export's schedule is paused. + ${ScheduleStatus}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.DateTime] + # The start date for export data. + ${TimePeriodFrom}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.DateTime] + # The end date for export data. + ${TimePeriodTo}, + + [Parameter()] + [Alias('AzureRMContext', 'AzureCredential')] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Azure')] + [System.Management.Automation.PSObject] + # The credentials, account, tenant, and subscription used for communication with Azure. + ${DefaultProfile}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Wait for .NET debugger to attach + ${Break}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be appended to the front of the pipeline + ${HttpPipelineAppend}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be prepended to the front of the pipeline + ${HttpPipelinePrepend}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Uri] + # The URI for the proxy server to use + ${Proxy}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.PSCredential] + # Credentials for a proxy server to use for the remote call + ${ProxyCredential}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Use the default credentials for the proxy + ${ProxyUseDefaultCredentials} +) + +begin { + try { + $outBuffer = $null + if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer)) { + $PSBoundParameters['OutBuffer'] = 1 + } + $parameterSet = $PSCmdlet.ParameterSetName + $mapping = @{ + CreateExpanded = 'Az.CostManagement.private\New-AzCostManagementExport_CreateExpanded'; + } + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet) + $scriptCmd = {& $wrappedCmd @PSBoundParameters} + $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin) + $steppablePipeline.Begin($PSCmdlet) + } catch { + throw + } +} + +process { + try { + $steppablePipeline.Process($_) + } catch { + throw + } +} + +end { + try { + $steppablePipeline.End() + } catch { + throw + } +} +} + +# ---------------------------------------------------------------------------------- +# +# Copyright Microsoft Corporation +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ---------------------------------------------------------------------------------- + +<# +.Synopsis +The operation to create or update a export. +Update operation requires latest eTag to be set in the request. +You may obtain the latest eTag by performing a get operation. +Create operation does not require eTag. +.Description +The operation to create or update a export. +Update operation requires latest eTag to be set in the request. +You may obtain the latest eTag by performing a get operation. +Create operation does not require eTag. +.Example +PS C:\> Update-AzCostManagementExport -Scope "subscriptions//*********" -Name "TestExport" -ScheduleRecurrence 'Weekly' + +ETag Name Type +---- ---- ---- +"********" TestExportDatasetAggregationInfo Microsoft.CostManagement/exports +.Example +PS C:\> $oldExport = Get-AzCostManagementExport -Scope "subscriptions/*********" -Name "TestExport" +Update-AzCostManagementExport -InputObject $oldExport -ScheduleRecurrence 'Weekly' + +ETag Name Type +---- ---- ---- +"********" TestExportDatasetAggregationInfo Microsoft.CostManagement/exports + +.Inputs +Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity +.Outputs +Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport +.Notes +COMPLEX PARAMETER PROPERTIES + +To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables. + +INPUTOBJECT : Identity Parameter + [AlertId ]: Alert ID + [ExportName ]: Export Name. + [ExternalCloudProviderId ]: This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' for consolidated account used with dimension/query operations. + [ExternalCloudProviderType ]: The external cloud provider type associated with dimension/query operations. This includes 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated account. + [Id ]: Resource identity path + [Scope ]: The scope associated with view operations. This includes 'subscriptions/{subscriptionId}' for subscription scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for BillingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' for InvoiceSection scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope, 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for External Billing Account scope and 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for External Subscription scope. + [ViewName ]: View name +.Link +https://docs.microsoft.com/en-us/powershell/module/az.costmanagement/update-azcostmanagementexport +#> +function Update-AzCostManagementExport { +[OutputType([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport])] +[CmdletBinding(DefaultParameterSetName='UpdateExpanded', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')] +param( + [Parameter(ParameterSetName='UpdateExpanded', Mandatory)] + [Alias('ExportName')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [System.String] + # Export Name. + ${Name}, + + [Parameter(ParameterSetName='UpdateExpanded', Mandatory)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [System.String] + # This parameter defines the scope of costmanagement from different perspectives 'Subscription','ResourceGroup' and 'Provide Service'. + ${Scope}, + + [Parameter(ParameterSetName='UpdateViaIdentityExpanded', Mandatory, ValueFromPipeline)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity] + # Identity Parameter + # To construct, see NOTES section for INPUTOBJECT properties and create a hash table. + ${InputObject}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String[]] + # Array of column names to be included in the export. + # If not provided then the export will include all available columns. + # The available columns can vary by customer channel (see examples). + ${ConfigurationColumn}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType] + # The granularity of rows in the export. + # Currently only 'Daily' is supported. + ${DataSetGranularity}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType] + # The time frame for pulling data for the export. + # If custom, then a specific time period must be provided. + ${DefinitionTimeframe}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType] + # The type of the export. + # Note that 'Usage' is equivalent to 'ActualCost' and is applicable to exports that do not yet provide data for charges or amortization for service reservations. + ${DefinitionType}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String] + # The name of the container where exports will be uploaded. + ${DestinationContainer}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String] + # The resource id of the storage account where exports will be delivered. + ${DestinationResourceId}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String] + # The name of the directory where exports will be uploaded. + ${DestinationRootFolderPath}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String] + # eTag of the resource. + # To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not. + ${ETag}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType] + # The format of the export being delivered. + # Currently only 'Csv' is supported. + ${Format}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.DateTime] + # The start date of recurrence. + ${RecurrencePeriodFrom}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.DateTime] + # The end date of recurrence. + ${RecurrencePeriodTo}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType] + # The schedule recurrence. + ${ScheduleRecurrence}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType] + # The status of the export's schedule. + # If 'Inactive', the export's schedule is paused. + ${ScheduleStatus}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.DateTime] + # The start date for export data. + ${TimePeriodFrom}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.DateTime] + # The end date for export data. + ${TimePeriodTo}, + + [Parameter()] + [Alias('AzureRMContext', 'AzureCredential')] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Azure')] + [System.Management.Automation.PSObject] + # The credentials, account, tenant, and subscription used for communication with Azure. + ${DefaultProfile}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Wait for .NET debugger to attach + ${Break}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be appended to the front of the pipeline + ${HttpPipelineAppend}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be prepended to the front of the pipeline + ${HttpPipelinePrepend}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Uri] + # The URI for the proxy server to use + ${Proxy}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.PSCredential] + # Credentials for a proxy server to use for the remote call + ${ProxyCredential}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Use the default credentials for the proxy + ${ProxyUseDefaultCredentials} +) + +begin { + try { + $outBuffer = $null + if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer)) { + $PSBoundParameters['OutBuffer'] = 1 + } + $parameterSet = $PSCmdlet.ParameterSetName + $mapping = @{ + UpdateExpanded = 'Az.CostManagement.private\Update-AzCostManagementExport_UpdateExpanded'; + UpdateViaIdentityExpanded = 'Az.CostManagement.private\Update-AzCostManagementExport_UpdateViaIdentityExpanded'; + } + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet) + $scriptCmd = {& $wrappedCmd @PSBoundParameters} + $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin) + $steppablePipeline.Begin($PSCmdlet) + } catch { + throw + } +} + +process { + try { + $steppablePipeline.Process($_) + } catch { + throw + } +} + +end { + try { + $steppablePipeline.End() + } catch { + throw + } +} +} diff --git a/src/CostManagement/internal/Update-AzCostManagementExport.ps1 b/src/CostManagement/internal/Update-AzCostManagementExport.ps1 new file mode 100644 index 000000000000..5979b01c5e91 --- /dev/null +++ b/src/CostManagement/internal/Update-AzCostManagementExport.ps1 @@ -0,0 +1,272 @@ + +# ---------------------------------------------------------------------------------- +# +# Copyright Microsoft Corporation +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ---------------------------------------------------------------------------------- + +<# +.Synopsis +The operation to create or update a export. +Update operation requires latest eTag to be set in the request. +You may obtain the latest eTag by performing a get operation. +Create operation does not require eTag. +.Description +The operation to create or update a export. +Update operation requires latest eTag to be set in the request. +You may obtain the latest eTag by performing a get operation. +Create operation does not require eTag. +.Example +PS C:\> Update-AzCostManagementExport -Scope "subscriptions//*********" -Name "TestExport" -ScheduleRecurrence 'Weekly' + +ETag Name Type +---- ---- ---- +"********" TestExportDatasetAggregationInfo Microsoft.CostManagement/exports +.Example +PS C:\> $oldExport = Get-AzCostManagementExport -Scope "subscriptions/*********" -Name "TestExport" +Update-AzCostManagementExport -InputObject $oldExport -ScheduleRecurrence 'Weekly' + +ETag Name Type +---- ---- ---- +"********" TestExportDatasetAggregationInfo Microsoft.CostManagement/exports + +.Inputs +Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity +.Outputs +Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport +.Notes +COMPLEX PARAMETER PROPERTIES + +To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables. + +INPUTOBJECT : Identity Parameter + [AlertId ]: Alert ID + [ExportName ]: Export Name. + [ExternalCloudProviderId ]: This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' for consolidated account used with dimension/query operations. + [ExternalCloudProviderType ]: The external cloud provider type associated with dimension/query operations. This includes 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated account. + [Id ]: Resource identity path + [Scope ]: The scope associated with view operations. This includes 'subscriptions/{subscriptionId}' for subscription scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for BillingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' for InvoiceSection scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope, 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for External Billing Account scope and 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for External Subscription scope. + [ViewName ]: View name +.Link +https://docs.microsoft.com/en-us/powershell/module/az.costmanagement/update-azcostmanagementexport +#> +function Update-AzCostManagementExport { +[OutputType([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.Api20200601.IExport])] +[CmdletBinding(DefaultParameterSetName='UpdateExpanded', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')] +param( + [Parameter(ParameterSetName='UpdateExpanded', Mandatory)] + [Alias('ExportName')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [System.String] + # Export Name. + ${Name}, + + [Parameter(ParameterSetName='UpdateExpanded', Mandatory)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [System.String] + # This parameter defines the scope of costmanagement from different perspectives 'Subscription','ResourceGroup' and 'Provide Service'. + ${Scope}, + + [Parameter(ParameterSetName='UpdateViaIdentityExpanded', Mandatory, ValueFromPipeline)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Path')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Models.ICostManagementIdentity] + # Identity Parameter + # To construct, see NOTES section for INPUTOBJECT properties and create a hash table. + ${InputObject}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String[]] + # Array of column names to be included in the export. + # If not provided then the export will include all available columns. + # The available columns can vary by customer channel (see examples). + ${ConfigurationColumn}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.GranularityType] + # The granularity of rows in the export. + # Currently only 'Daily' is supported. + ${DataSetGranularity}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.TimeframeType] + # The time frame for pulling data for the export. + # If custom, then a specific time period must be provided. + ${DefinitionTimeframe}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.ExportType] + # The type of the export. + # Note that 'Usage' is equivalent to 'ActualCost' and is applicable to exports that do not yet provide data for charges or amortization for service reservations. + ${DefinitionType}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String] + # The name of the container where exports will be uploaded. + ${DestinationContainer}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String] + # The resource id of the storage account where exports will be delivered. + ${DestinationResourceId}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String] + # The name of the directory where exports will be uploaded. + ${DestinationRootFolderPath}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.String] + # eTag of the resource. + # To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not. + ${ETag}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.FormatType] + # The format of the export being delivered. + # Currently only 'Csv' is supported. + ${Format}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.DateTime] + # The start date of recurrence. + ${RecurrencePeriodFrom}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.DateTime] + # The end date of recurrence. + ${RecurrencePeriodTo}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.RecurrenceType] + # The schedule recurrence. + ${ScheduleRecurrence}, + + [Parameter()] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType])] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Support.StatusType] + # The status of the export's schedule. + # If 'Inactive', the export's schedule is paused. + ${ScheduleStatus}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.DateTime] + # The start date for export data. + ${TimePeriodFrom}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] + [System.DateTime] + # The end date for export data. + ${TimePeriodTo}, + + [Parameter()] + [Alias('AzureRMContext', 'AzureCredential')] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Azure')] + [System.Management.Automation.PSObject] + # The credentials, account, tenant, and subscription used for communication with Azure. + ${DefaultProfile}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Wait for .NET debugger to attach + ${Break}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be appended to the front of the pipeline + ${HttpPipelineAppend}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be prepended to the front of the pipeline + ${HttpPipelinePrepend}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Uri] + # The URI for the proxy server to use + ${Proxy}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.PSCredential] + # Credentials for a proxy server to use for the remote call + ${ProxyCredential}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Use the default credentials for the proxy + ${ProxyUseDefaultCredentials} +) + +begin { + try { + $outBuffer = $null + if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer)) { + $PSBoundParameters['OutBuffer'] = 1 + } + $parameterSet = $PSCmdlet.ParameterSetName + $mapping = @{ + UpdateExpanded = 'Az.CostManagement.private\Update-AzCostManagementExport_UpdateExpanded'; + UpdateViaIdentityExpanded = 'Az.CostManagement.private\Update-AzCostManagementExport_UpdateViaIdentityExpanded'; + } + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet) + $scriptCmd = {& $wrappedCmd @PSBoundParameters} + $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin) + $steppablePipeline.Begin($PSCmdlet) + } catch { + throw + } +} + +process { + try { + $steppablePipeline.Process($_) + } catch { + throw + } +} + +end { + try { + $steppablePipeline.End() + } catch { + throw + } +} +} diff --git a/src/CostManagement/internal/readme.md b/src/CostManagement/internal/readme.md new file mode 100644 index 000000000000..8273f7bf9ce4 --- /dev/null +++ b/src/CostManagement/internal/readme.md @@ -0,0 +1,14 @@ +# Internal +This directory contains a module to handle *internal only* cmdlets. Cmdlets that you **hide** in configuration are created here. For more information on hiding, see [cmdlet hiding](https://github.com/Azure/autorest/blob/master/docs/powershell/options.md#cmdlet-hiding-exportation-suppression). The cmdlets in this directory are generated at **build-time**. Do not put any custom code, files, cmdlets, etc. into this directory. Please use `..\custom` for all custom implementation. + +## Info +- Modifiable: no +- Generated: all +- Committed: no +- Packaged: yes + +## Details +The `Az.CostManagement.internal.psm1` file is generated to this folder. This module file handles the hidden cmdlets. These cmdlets will not be exported by `Az.CostManagement`. Instead, this sub-module is imported by the `..\custom\Az.CostManagement.custom.psm1` module, allowing you to use hidden cmdlets in your custom, exposed cmdlets. To call these cmdlets in your custom scripts, simply use [module-qualified calls](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_command_precedence?view=powershell-6#qualified-names). For example, `Az.CostManagement.internal\Get-Example` would call an internal cmdlet named `Get-Example`. + +## Purpose +This allows you to include REST specifications for services that you *do not wish to expose from your module*, but simply want to call within custom cmdlets. For example, if you want to make a custom cmdlet that uses `Storage` services, you could include a simplified `Storage` REST specification that has only the operations you need. When you run the generator and build this module, note the generated `Storage` cmdlets. Then, in your readme configuration, use [cmdlet hiding](https://github.com/Azure/autorest/blob/master/docs/powershell/options.md#cmdlet-hiding-exportation-suppression) on the `Storage` cmdlets and they will *only be exposed to the custom cmdlets* you want to write, and not be exported as part of `Az.CostManagement`. \ No newline at end of file diff --git a/src/CostManagement/pack-module.ps1 b/src/CostManagement/pack-module.ps1 new file mode 100644 index 000000000000..c22fad33d87b --- /dev/null +++ b/src/CostManagement/pack-module.ps1 @@ -0,0 +1,16 @@ +# ---------------------------------------------------------------------------------- +# +# Copyright Microsoft Corporation +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ---------------------------------------------------------------------------------- +Write-Host -ForegroundColor Green 'Packing module...' +dotnet pack $PSScriptRoot --no-build /nologo +Write-Host -ForegroundColor Green '-------------Done-------------' \ No newline at end of file diff --git a/src/CostManagement/readme.md b/src/CostManagement/readme.md new file mode 100644 index 000000000000..ba8f2210d58a --- /dev/null +++ b/src/CostManagement/readme.md @@ -0,0 +1,197 @@ + +# Az.CostManagement +This directory contains the PowerShell module for the Cost service. + +--- +## Status +[![Az.CostManagement](https://img.shields.io/powershellgallery/v/Az.CostManagement.svg?style=flat-square&label=Az.CostManagement "Az.CostManagement")](https://www.powershellgallery.com/packages/Az.CostManagement/) + +## Info +- Modifiable: yes +- Generated: all +- Committed: yes +- Packaged: yes + +--- +## Detail +This module was primarily generated via [AutoRest](https://github.com/Azure/autorest) using the [PowerShell](https://github.com/Azure/autorest.powershell) extension. + +## Module Requirements +- [Az.Accounts module](https://www.powershellgallery.com/packages/Az.Accounts/), version 1.8.1 or greater + +## Authentication +AutoRest does not generate authentication code for the module. Authentication is handled via Az.Accounts by altering the HTTP payload before it is sent. + +## Development +For information on how to develop for `Az.CostManagement`, see [how-to.md](how-to.md). + + +--- +## Generation Requirements +Use of the beta version of `autorest.powershell` generator requires the following: +- [NodeJS LTS](https://nodejs.org) (10.15.x LTS preferred) + - **Note**: It *will not work* with Node < 10.x. Using 11.x builds may cause issues as they may introduce instability or breaking changes. +> If you want an easy way to install and update Node, [NVS - Node Version Switcher](../nodejs/installing-via-nvs.md) or [NVM - Node Version Manager](../nodejs/installing-via-nvm.md) is recommended. +- [AutoRest](https://aka.ms/autorest) v3 beta
`npm install -g autorest@beta`
  +- PowerShell 6.0 or greater + - If you don't have it installed, you can use the cross-platform npm package
`npm install -g pwsh`
  +- .NET Core SDK 2.0 or greater + - If you don't have it installed, you can use the cross-platform npm package
`npm install -g dotnet-sdk-2.2`
  +## Run Generation +In this directory, run AutoRest: +> `autorest` +--- +### AutoRest Configuration +> see https://aka.ms/autorest + +``` yaml +Branch: 2cb80cf6668074c84cf02cf45b6bb897eff47e9b +require: + - $(this-folder)/../readme.azure.noprofile.md +input-file: + - $(repo)/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2020-06-01/costmanagement.json + - $(repo)/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2020-06-01/costmanagement.exports.json +title: CostManagement +module-version: 0.1.0 + +service-name: CostManagement + +identity-correction-for-post: true + +directive: + - where: + variant: ^Create$|^CreateViaIdentity$|^CreateViaIdentityExpanded$|^Update$|^UpdateViaIdentity$ + remove: true + - from: source-file-csharp + where: $ + transform: $ = $.replace(/AlertCategory System/, 'AlertCategory System1'); + - from: source-file-csharp + where: $ + transform: $ = $.replace(/internal partial interface/, 'public partial interface'); + - where: + verb: Set + set: + verb: Update + - where: + subject: UsageQuery + verb: invoke + remove: true + - where: + subject: ByDimensionExternalCloudProviderType|CloudForecast|DismissAlert|Forecast + verb: Invoke + remove: true + - where: + subject: Export|ExportExecutionHistory|ExportExecution + parameter-name: Scope + set: + parameter-name: Scope + parameter-description: This parameter defines the scope of costmanagement from different perspectives 'Subscription','ResourceGroup' and 'Provide Service'. + - where: + subject: Export + verb: New + hide: true + - where: + subject: Export + verb: Update + hide: true + - from: source-file-csharp + where: $ + transform: $ = $.replace(/\/runHistory\$/g, "$"); + - where: + subject: Alert|AlertExternal|Dimension|View + remove: true + - from: source-file-csharp + where: $ + transform: $ = $.replace(/\^\/\(\?\[\^\/\]\+\)/g, "(?.+)"); + - where: + model-name: QueryResult + set: + format-table: + properties: + - NextLink + - Column + - Row + - where: + model-name: ExportExecution + set: + format-table: + properties: + - ExecutionType + - ProcessingStartTime + - ProcessingEndTime + - RunSetting + - Status + - FileName + - from: swagger-document + where: $.definitions.AlertProperties.properties.details.properties.resourceGroupFilter.items + transform: >- + return { + "type": "string" + } + - from: swagger-document + where: $.definitions.AlertProperties.properties.details.properties.resourceFilter.items + transform: >- + return { + "type": "string" + } + - from: swagger-document + where: $.definitions.AlertProperties.properties.details.properties.meterFilter.items + transform: >- + return { + "type": "string" + } + - from: swagger-document + where: $.definitions.QueryProperties.properties.rows.items.items + transform: >- + return { + "type": "string" + } + - from: swagger-document + where: $.definitions.QueryFilter.properties + transform: >- + return { + "and": { + "description": "The logical \"AND\" expression. Must have at least 2 items.", + "type": "array", + "items": { + "$ref": "#/definitions/QueryFilter" + }, + "minItems": 2 + }, + "or": { + "description": "The logical \"OR\" expression. Must have at least 2 items.", + "type": "array", + "items": { + "$ref": "#/definitions/QueryFilter" + }, + "minItems": 2 + }, + "not": { + "description": "The logical \"NOT\" expression.", + "$ref": "#/definitions/QueryFilter" + }, + "dimensions": { + "description": "Has comparison expression for a dimension", + "$ref": "#/definitions/QueryComparisonExpression" + }, + "tag": { + "description": "Has comparison expression for a tag", + "$ref": "#/definitions/QueryComparisonExpression" + } + } + - where: + model-name: QueryFilter + property-name: Dimension + set: + property-name: Dimensions + - where: + model-name: QueryResult + set: + format-table: + properties: + - Column + - Row + - no-inline: + - QueryFilter + - ReportConfigFilter +``` diff --git a/src/CostManagement/run-module.ps1 b/src/CostManagement/run-module.ps1 new file mode 100644 index 000000000000..879e57c24b9b --- /dev/null +++ b/src/CostManagement/run-module.ps1 @@ -0,0 +1,59 @@ +# ---------------------------------------------------------------------------------- +# +# Copyright Microsoft Corporation +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ---------------------------------------------------------------------------------- +param([switch]$Isolated, [switch]$Code) +$ErrorActionPreference = 'Stop' + +if(-not $Isolated) { + Write-Host -ForegroundColor Green 'Creating isolated process...' + $pwsh = [System.Diagnostics.Process]::GetCurrentProcess().Path + & "$pwsh" -NoExit -NoLogo -NoProfile -File $MyInvocation.MyCommand.Path @PSBoundParameters -Isolated + return +} + +$isAzure = $true +if($isAzure) { + . (Join-Path $PSScriptRoot 'check-dependencies.ps1') -Isolated -Accounts +} + +$localModulesPath = Join-Path $PSScriptRoot 'generated\modules' +if(Test-Path -Path $localModulesPath) { + $env:PSModulePath = "$localModulesPath$([IO.Path]::PathSeparator)$env:PSModulePath" +} + +$modulePsd1 = Get-Item -Path (Join-Path $PSScriptRoot './Az.CostManagement.psd1') +$modulePath = $modulePsd1.FullName +$moduleName = $modulePsd1.BaseName + +function Prompt { + Write-Host -NoNewline -ForegroundColor Green "PS $(Get-Location)" + Write-Host -NoNewline -ForegroundColor Gray ' [' + Write-Host -NoNewline -ForegroundColor White -BackgroundColor DarkCyan $moduleName + ']> ' +} + +# where we would find the launch.json file +$vscodeDirectory = New-Item -ItemType Directory -Force -Path (Join-Path $PSScriptRoot '.vscode') +$launchJson = Join-Path $vscodeDirectory 'launch.json' + +# if there is a launch.json file, let's just assume -Code, and update the file +if(($Code) -or (test-Path $launchJson) ) { + $launchContent = '{ "version": "0.2.0", "configurations":[{ "name":"Attach to PowerShell", "type":"coreclr", "request":"attach", "processId":"' + ([System.Diagnostics.Process]::GetCurrentProcess().Id) + '", "justMyCode":false }] }' + Set-Content -Path $launchJson -Value $launchContent + if($Code) { + # only launch vscode if they say -code + code $PSScriptRoot + } +} + +Import-Module -Name $modulePath \ No newline at end of file diff --git a/src/CostManagement/test-module.ps1 b/src/CostManagement/test-module.ps1 new file mode 100644 index 000000000000..b6b48052f0dd --- /dev/null +++ b/src/CostManagement/test-module.ps1 @@ -0,0 +1,68 @@ +# ---------------------------------------------------------------------------------- +# +# Copyright Microsoft Corporation +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ---------------------------------------------------------------------------------- +param([switch]$Isolated, [switch]$Live, [switch]$Record, [switch]$Playback) +$ErrorActionPreference = 'Stop' + +if(-not $Isolated) { + Write-Host -ForegroundColor Green 'Creating isolated process...' + $pwsh = [System.Diagnostics.Process]::GetCurrentProcess().Path + & "$pwsh" -NonInteractive -NoLogo -NoProfile -File $MyInvocation.MyCommand.Path @PSBoundParameters -Isolated + return +} + +$ProgressPreference = 'SilentlyContinue' +$baseName = $PSScriptRoot.BaseName +$requireResourceModule = (($baseName -ne "Resources") -and ($Record.IsPresent -or $Live.IsPresent)) +. (Join-Path $PSScriptRoot 'check-dependencies.ps1') -Isolated -Accounts:$false -Pester -Resources:$requireResourceModule +. ("$PSScriptRoot\test\utils.ps1") + +if ($requireResourceModule) { + $resourceModulePSD = Get-Item -Path (Join-Path $HOME '.PSSharedModules\Resources\Az.Resources.TestSupport.psd1') + Import-Module -Name $resourceModulePSD.FullName +} + +$localModulesPath = Join-Path $PSScriptRoot 'generated\modules' +if(Test-Path -Path $localModulesPath) { + $env:PSModulePath = "$localModulesPath$([IO.Path]::PathSeparator)$env:PSModulePath" +} + +$modulePsd1 = Get-Item -Path (Join-Path $PSScriptRoot './Az.CostManagement.psd1') +$modulePath = $modulePsd1.FullName +$moduleName = $modulePsd1.BaseName + +Import-Module -Name Pester +Import-Module -Name $modulePath + +$TestMode = 'playback' +if($Live) { + $TestMode = 'live' +} +if($Record) { + $TestMode = 'record' +} +try { + if ($TestMode -ne 'playback') { + setupEnv + } + $testFolder = Join-Path $PSScriptRoot 'test' + Invoke-Pester -Script @{ Path = $testFolder } -EnableExit -OutputFile (Join-Path $testFolder "$moduleName-TestResults.xml") +} +Finally +{ + if ($TestMode -ne 'playback') { + cleanupEnv + } +} + +Write-Host -ForegroundColor Green '-------------Done-------------' \ No newline at end of file diff --git a/src/CostManagement/test/Az.Cost-TestResults.xml b/src/CostManagement/test/Az.Cost-TestResults.xml new file mode 100644 index 000000000000..f4779bc6f02e --- /dev/null +++ b/src/CostManagement/test/Az.Cost-TestResults.xml @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/CostManagement/test/Get-AzCostManagementExport.Recording.json b/src/CostManagement/test/Get-AzCostManagementExport.Recording.json new file mode 100644 index 000000000000..18018b228439 --- /dev/null +++ b/src/CostManagement/test/Get-AzCostManagementExport.Recording.json @@ -0,0 +1,170 @@ +{ + "Get-AzCostManagementExport+[NoContext]+List+$GET+https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports?api-version=2020-06-01+1": { + "Request": { + "Method": "GET", + "RequestUri": "https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports?api-version=2020-06-01", + "Content": null, + "Headers": { + "x-ms-unique-id": [ "1" ], + "x-ms-client-request-id": [ "019f78ea-6d5d-4526-96b6-759794f5b56e" ], + "CommandName": [ "Get-AzCostManagementExport" ], + "FullCommandName": [ "Get-AzCostManagementExport_List" ], + "ParameterSetName": [ "__AllParameterSets" ], + "User-Agent": [ "AzurePowershell/Az4.0.0-preview" ], + "Authorization": [ "[Filtered]" ] + }, + "ContentHeaders": { + } + }, + "Response": { + "StatusCode": 200, + "Headers": { + "Cache-Control": [ "no-cache" ], + "Pragma": [ "no-cache" ], + "Vary": [ "Accept-Encoding" ], + "session-id": [ "7c853323-98ff-444b-8cf2-ff9e08faef47" ], + "x-ms-request-id": [ "1d220c16-222c-493d-ba84-78097dee9e30" ], + "x-ms-correlation-request-id": [ "e86dfb49-a45f-4671-9088-43db287b2aa2" ], + "x-ms-client-request-id": [ "019f78ea-6d5d-4526-96b6-759794f5b56e" ], + "X-Powered-By": [ "ASP.NET" ], + "x-ms-ratelimit-remaining-subscription-reads": [ "11997" ], + "x-ms-routing-request-id": [ "SOUTHEASTASIA:20201118T070127Z:e86dfb49-a45f-4671-9088-43db287b2aa2" ], + "Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" ], + "X-Content-Type-Options": [ "nosniff" ], + "Date": [ "Wed, 18 Nov 2020 07:01:26 GMT" ] + }, + "ContentHeaders": { + "Content-Length": [ "30290" ], + "Content-Type": [ "application/json; charset=utf-8" ], + "Expires": [ "-1" ] + }, + "Content": "{\"value\":[{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/TestExport\",\"name\":\"TestExport\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d63fb46c1f5154\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-11T00:00:00+00:00\",\"to\":\"2020-06-20T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-costmanagement/providers/Microsoft.Storage/storageAccounts/wyunchistorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"configuration\":{\"columns\":[\"SubscriptionGuid\",\"MeterId\",\"InstanceId\",\"ResourceGroup\",\"PreTaxCost\"]},\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/TestExport1\",\"name\":\"TestExport1\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d63fb4a3f75019\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-11T20:00:00+00:00\",\"to\":\"2020-06-20T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-costmanagement/providers/Microsoft.Storage/storageAccounts/wyunchistorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"configuration\":{\"columns\":[\"SubscriptionGuid\",\"MeterId\",\"InstanceId\",\"ResourceGroup\",\"PreTaxCost\"]},\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/TestExport2\",\"name\":\"TestExport2\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d649f5dda56551\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-25T20:00:00+00:00\",\"to\":\"2020-06-29T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-costmanagement/providers/Microsoft.Storage/storageAccounts/wyunchistorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"configuration\":{\"columns\":[\"SubscriptionGuid\",\"MeterId\",\"InstanceId\",\"ResourceGroup\",\"PreTaxCost\"]},\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/TestExport3\",\"name\":\"TestExport3\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d649f6069c44bb\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-25T20:00:00+00:00\",\"to\":\"2020-06-29T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-costmanagement/providers/Microsoft.Storage/storageAccounts/wyunchistorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"configuration\":{\"columns\":[\"SubscriptionGuid\",\"MeterId\",\"InstanceId\",\"ResourceGroup\",\"PreTaxCost\"]},\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/LucasExport-T02\",\"name\":\"LucasExport-T02\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d649f8ec7b1149\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-25T20:00:00+00:00\",\"to\":\"2020-06-29T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-costmanagement/providers/Microsoft.Storage/storageAccounts/wyunchistorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\",\"aggregation\":{\"costsum\":{\"name\":\"PreTaxCost\",\"function\":\"Sum\"},\"cost\":{\"name\":\"Cost\",\"function\":\"Sum\"}},\"grouping\":[{\"type\":\"Dimension\",\"name\":\"ResourceGroup\"}]}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/LucasExport-T03\",\"name\":\"LucasExport-T03\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d649f918708873\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-25T20:00:00+00:00\",\"to\":\"2020-06-29T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-costmanagement/providers/Microsoft.Storage/storageAccounts/wyunchistorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\",\"aggregation\":{\"costsum\":{\"name\":\"PreTaxCost\",\"function\":\"Sum\"},\"cost\":{\"name\":\"Cost\",\"function\":\"Sum\"}},\"grouping\":[{\"type\":\"Dimension\",\"name\":\"ResourceGroup\"}]}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/LucasExportT06\",\"name\":\"LucasExportT06\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d649f9d2f5df21\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-27T20:00:00+00:00\",\"to\":\"2020-06-28T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-costmanagement/providers/Microsoft.Storage/storageAccounts/wyunchistorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\",\"aggregation\":{\"costsum\":{\"name\":\"PreTaxCost\",\"function\":\"Sum\"},\"cost\":{\"name\":\"Cost\",\"function\":\"Sum\"}},\"grouping\":[{\"type\":\"Dimension\",\"name\":\"ResourceGroup\"}]}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/ps-costext-t01\",\"name\":\"ps-costext-t01\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d649ff52ae2bb7\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-24T00:00:00+00:00\",\"to\":\"2020-06-26T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/azureps-manual-test/providers/Microsoft.Storage/storageAccounts/lucascostmanagement\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\",\"aggregation\":{\"costsum\":{\"name\":\"PreTaxCost\",\"function\":\"Sum\"},\"cost\":{\"name\":\"Cost\",\"function\":\"Sum\"}},\"grouping\":[{\"type\":\"Dimension\",\"name\":\"ResourceGroup\"}]}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/ps-costext-t02\",\"name\":\"ps-costext-t02\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d64d16faa5d7b4\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-28T00:00:00+00:00\",\"to\":\"2020-07-01T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/azureps-manual-test/providers/Microsoft.Storage/storageAccounts/lucascostmanagement\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\",\"aggregation\":{\"costsum\":{\"name\":\"PreTaxCost\",\"function\":\"Sum\"},\"cost\":{\"name\":\"Cost\",\"function\":\"Sum\"}},\"grouping\":[{\"type\":\"Dimension\",\"name\":\"ResourceGroup\"}]}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/ps-costext-t03\",\"name\":\"ps-costext-t03\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d64d1be92e19a4\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-28T07:45:28\",\"to\":\"2020-07-18T07:15:28\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/azureps-manual-test/providers/Microsoft.Storage/storageAccounts/lucascostmanagement\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\",\"aggregation\":{\"cost\":{\"name\":\"Cost\",\"function\":\"Sum\"},\"costsum\":{\"name\":\"PreTaxCost\",\"function\":\"Sum\"}},\"grouping\":[{\"type\":\"Dimension\",\"name\":\"ResourceGroup\"}]}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/exportws5qlv\",\"name\":\"exportws5qlv\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d64d1d1164c9ac\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-28T07:53:46\",\"to\":\"2020-07-18T07:23:46\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-manual-test/providers/Microsoft.Storage/storageAccounts/staaccountmkjhje\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\",\"aggregation\":{\"costsum\":{\"name\":\"PreTaxCost\",\"function\":\"Sum\"},\"cost\":{\"name\":\"Cost\",\"function\":\"Sum\"}},\"grouping\":[{\"type\":\"Dimension\",\"name\":\"ResourceGroup\"}]}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/manual-export-t01\",\"name\":\"manual-export-t01\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d64dd725acbcdf\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-29T20:00:00+00:00\",\"to\":\"2020-07-01T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-manual-test/providers/Microsoft.Storage/storageAccounts/lucasstorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/manual-export-t02\",\"name\":\"manual-export-t02\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d64dd8071bf283\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-29T13:00:00+00:00\",\"to\":\"2020-07-01T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-manual-test/providers/Microsoft.Storage/storageAccounts/lucasstorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/exportinfo-ps-t\",\"name\":\"exportinfo-ps-t\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d64dda275a663c\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-29T13:00:00+00:00\",\"to\":\"2020-07-01T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-manual-test/providers/Microsoft.Storage/storageAccounts/lucasstorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/ps-exportall-t\",\"name\":\"ps-exportall-t\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d64dda37395609\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-29T13:00:00+00:00\",\"to\":\"2020-07-01T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-manual-test/providers/Microsoft.Storage/storageAccounts/lucasstorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/ps-customcolum-t\",\"name\":\"ps-customcolum-t\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d64ddad337a774\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-29T13:00:00+00:00\",\"to\":\"2020-07-01T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-manual-test/providers/Microsoft.Storage/storageAccounts/lucasstorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"configuration\":{\"columns\":[\"SubscriptionGuid\",\"MeterId\",\"InstanceId\",\"ResourceGroup\",\"PreTaxCost\"]},\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/ps-aggregation-t\",\"name\":\"ps-aggregation-t\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d64ddb7d30c57d\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-29T13:00:00+00:00\",\"to\":\"2020-07-01T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-manual-test/providers/Microsoft.Storage/storageAccounts/lucasstorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\",\"aggregation\":{\"cost\":{\"name\":\"Cost\",\"function\":\"Sum\"},\"costsum\":{\"name\":\"PreTaxCost\",\"function\":\"Sum\"}}}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/ps-group-t\",\"name\":\"ps-group-t\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d64ddd2f00c7aa\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-29T13:00:00+00:00\",\"to\":\"2020-07-01T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-manual-test/providers/Microsoft.Storage/storageAccounts/lucasstorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\",\"grouping\":[{\"type\":\"Dimension\",\"name\":\"ResourceGroup\"}]}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/ps-groupaggregation-t\",\"name\":\"ps-groupaggregation-t\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d64dde4850e487\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-29T13:00:00+00:00\",\"to\":\"2020-07-01T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-manual-test/providers/Microsoft.Storage/storageAccounts/lucasstorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\",\"aggregation\":{\"cost\":{\"name\":\"Cost\",\"function\":\"Sum\"},\"costsum\":{\"name\":\"PreTaxCost\",\"function\":\"Sum\"}},\"grouping\":[{\"type\":\"Dimension\",\"name\":\"ResourceGroup\"}]}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/TestExport10\",\"name\":\"TestExport10\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d650dd9b8ab46b\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-07-03T20:00:00+00:00\",\"to\":\"2020-07-10T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-costmanagement/providers/Microsoft.Storage/storageAccounts/wyunchistorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/ps-exportall-t02\",\"name\":\"ps-exportall-t02\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d651104357293e\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-07-03T08:00:00+00:00\",\"to\":\"2020-08-01T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-manual-test/providers/Microsoft.Storage/storageAccounts/lucasstorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/ps-exportall-t03\",\"name\":\"ps-exportall-t03\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d65110a073dc56\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-07-03T08:00:00+00:00\",\"to\":\"2020-08-01T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-manual-test/providers/Microsoft.Storage/storageAccounts/lucasstorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-u9yfan\",\"name\":\"export-u9yfan\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d652b1674994fd\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-07-05T07:41:32\",\"to\":\"2020-07-21T07:41:32\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-manual-test/providers/Microsoft.Storage/storageAccounts/staaccountmhot0q\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-u9sfcn\",\"name\":\"export-u9sfcn\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d652b16952d046\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-07-05T07:41:32\",\"to\":\"2020-07-21T07:41:32\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-manual-test/providers/Microsoft.Storage/storageAccounts/staaccountmhot0q\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"configuration\":{\"columns\":[\"SubscriptionGuid\",\"MeterId\",\"InstanceId\",\"ResourceGroup\",\"PreTaxCost\"]},\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-cf6scg\",\"name\":\"export-cf6scg\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d652b16a169690\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-07-05T07:41:32\",\"to\":\"2020-07-21T07:41:32\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-manual-test/providers/Microsoft.Storage/storageAccounts/staaccountmhot0q\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\",\"grouping\":[{\"type\":\"Dimension\",\"name\":\"ResourceGroup\"}]}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-38we0i\",\"name\":\"export-38we0i\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d65375a9692caf\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-07-06T09:13:02\",\"to\":\"2020-07-26T09:13:02\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-5rij6b/providers/Microsoft.Storage/storageAccounts/staaccountjshubiu\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-r6xjol\",\"name\":\"export-r6xjol\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d65377005b37c6\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-07-06T09:13:02\",\"to\":\"2020-07-26T09:13:02\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-5rij6b/providers/Microsoft.Storage/storageAccounts/staaccountjshubiu\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-gq1kft\",\"name\":\"export-gq1kft\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d6537703972b88\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-07-06T09:13:02\",\"to\":\"2020-07-26T09:13:02\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-5rij6b/providers/Microsoft.Storage/storageAccounts/staaccountjshubiu\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\",\"grouping\":[{\"type\":\"Dimension\",\"name\":\"ResourceGroup\"}]}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-j8s5of\",\"name\":\"export-j8s5of\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d65377046dbf7c\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-07-06T09:13:02\",\"to\":\"2020-07-26T09:13:02\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-5rij6b/providers/Microsoft.Storage/storageAccounts/staaccountjshubiu\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\",\"aggregation\":{\"costsum\":{\"name\":\"PreTaxCost\",\"function\":\"Sum\"},\"cost\":{\"name\":\"Cost\",\"function\":\"Sum\"}},\"grouping\":[{\"type\":\"Dimension\",\"name\":\"ResourceGroup\"}]}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/TestExportDatasetAggregation123\",\"name\":\"TestExportDatasetAggregation123\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d6b19fb5559127\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-11-03T20:00:00+00:00\",\"to\":\"2020-11-10T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-costmanagement/providers/Microsoft.Storage/storageAccounts/wyunchistorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/TestExportDatasetAggregationInfoyouri\",\"name\":\"TestExportDatasetAggregationInfoyouri\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d6b33c18099a67\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-11-05T20:00:00+00:00\",\"to\":\"2020-11-10T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-costmanagement/providers/Microsoft.Storage/storageAccounts/wyunchistorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"configuration\":{\"columns\":[\"SubscriptionGuid\",\"MeterId\",\"InstanceId\",\"ResourceGroup\",\"PreTaxCost\"]},\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/TestUpdate1\",\"name\":\"TestUpdate1\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d6b6451f8f6d83\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-11-09T20:00:00+00:00\",\"to\":\"2020-11-20T00:00:00+00:00\"}},\"nextRunTimeEstimate\":\"2020-11-18T19:01:26.9366552Z\",\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-costmanagement/providers/Microsoft.Storage/storageAccounts/wyunchistorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/TestExportDatasetAggregationInfoYouri\",\"name\":\"TestExportDatasetAggregationInfoYouri\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d6b738f9459e9e\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-11-13T20:00:00Z\",\"to\":\"2020-11-17T00:00:00Z\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-costmanagement/providers/Microsoft.Storage/storageAccounts/wyunchistorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"adhoctest\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/TestExportDatasetAggregationYouriTest\",\"name\":\"TestExportDatasetAggregationYouriTest\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d6b7120d0af53a\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-11-10T20:00:00+00:00\",\"to\":\"2020-11-15T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-costmanagement/providers/Microsoft.Storage/storageAccounts/wyunchistorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"adhoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/TestExportDatasetAggregationInfo1118\",\"name\":\"TestExportDatasetAggregationInfo1118\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d6bd716961a536\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Weekly\",\"recurrencePeriod\":{\"from\":\"2020-11-18T20:00:00Z\",\"to\":\"2020-11-20T00:00:00Z\"}},\"nextRunTimeEstimate\":\"2020-11-18T20:00:00Z\",\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/youri-costmanagement/providers/Microsoft.Storage/storageAccounts/youristorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-oenfxg\",\"name\":\"export-oenfxg\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d6bd74b260689e\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-11-18T14:33:13\",\"to\":\"2020-12-08T14:33:13\"}},\"nextRunTimeEstimate\":\"2020-11-18T19:01:26.9366552Z\",\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-gali06/providers/Microsoft.Storage/storageAccounts/staaccountjshubiu\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-x9d0hl\",\"name\":\"export-x9d0hl\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d6bd787c7e5e56\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-11-18T14:33:13\",\"to\":\"2020-12-08T14:33:13\"}},\"nextRunTimeEstimate\":\"2020-11-18T19:01:26.9366552Z\",\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-gali06/providers/Microsoft.Storage/storageAccounts/staaccountjshubiu\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-9pcvod\",\"name\":\"export-9pcvod\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d6bd787f0fd3c0\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-11-18T14:33:13\",\"to\":\"2020-12-08T14:33:13\"}},\"nextRunTimeEstimate\":\"2020-11-18T19:01:26.9366552Z\",\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-gali06/providers/Microsoft.Storage/storageAccounts/staaccountjshubiu\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"configuration\":{\"columns\":[\"SubscriptionGuid\",\"MeterId\",\"InstanceId\",\"ResourceGroup\",\"PreTaxCost\"]},\"granularity\":\"Daily\"}}}}]}" + } + }, + "Get-AzCostManagementExport+[NoContext]+Get+$GET+https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-oenfxg?api-version=2020-06-01+1": { + "Request": { + "Method": "GET", + "RequestUri": "https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-oenfxg?api-version=2020-06-01", + "Content": null, + "Headers": { + "x-ms-unique-id": [ "2" ], + "x-ms-client-request-id": [ "284728a8-bc91-4a3a-8713-f71c14f4756f" ], + "CommandName": [ "Get-AzCostManagementExport" ], + "FullCommandName": [ "Get-AzCostManagementExport_Get" ], + "ParameterSetName": [ "__AllParameterSets" ], + "User-Agent": [ "AzurePowershell/Az4.0.0-preview" ], + "Authorization": [ "[Filtered]" ] + }, + "ContentHeaders": { + } + }, + "Response": { + "StatusCode": 200, + "Headers": { + "Cache-Control": [ "no-cache" ], + "Pragma": [ "no-cache" ], + "Vary": [ "Accept-Encoding" ], + "session-id": [ "0e2f0ad0-a2c2-4128-bf1e-790e4a6b93c9" ], + "x-ms-request-id": [ "c3b28262-7f15-4fb0-b212-893bcda8d57d" ], + "x-ms-correlation-request-id": [ "1f4c0526-984b-47b4-849d-0dc455f20959" ], + "x-ms-client-request-id": [ "284728a8-bc91-4a3a-8713-f71c14f4756f" ], + "X-Powered-By": [ "ASP.NET" ], + "x-ms-ratelimit-remaining-subscription-reads": [ "11996" ], + "x-ms-routing-request-id": [ "SOUTHEASTASIA:20201118T070127Z:1f4c0526-984b-47b4-849d-0dc455f20959" ], + "Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" ], + "X-Content-Type-Options": [ "nosniff" ], + "Date": [ "Wed, 18 Nov 2020 07:01:27 GMT" ] + }, + "ContentHeaders": { + "Content-Length": [ "762" ], + "Content-Type": [ "application/json; charset=utf-8" ], + "Expires": [ "-1" ] + }, + "Content": "{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-oenfxg\",\"name\":\"export-oenfxg\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d6bd74b260689e\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-11-18T14:33:13\",\"to\":\"2020-12-08T14:33:13\"}},\"nextRunTimeEstimate\":\"2020-11-18T19:01:27.7260468Z\",\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-gali06/providers/Microsoft.Storage/storageAccounts/staaccountjshubiu\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}}" + } + }, + "Get-AzCostManagementExport+[NoContext]+GetViaIdentity+$GET+https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-oenfxg?api-version=2020-06-01+1": { + "Request": { + "Method": "GET", + "RequestUri": "https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-oenfxg?api-version=2020-06-01", + "Content": null, + "Headers": { + "x-ms-unique-id": [ "3" ], + "x-ms-client-request-id": [ "dd33ad9d-1784-4051-b058-dc7f19937624" ], + "CommandName": [ "Get-AzCostManagementExport" ], + "FullCommandName": [ "Get-AzCostManagementExport_Get" ], + "ParameterSetName": [ "__AllParameterSets" ], + "User-Agent": [ "AzurePowershell/Az4.0.0-preview" ], + "Authorization": [ "[Filtered]" ] + }, + "ContentHeaders": { + } + }, + "Response": { + "StatusCode": 200, + "Headers": { + "Cache-Control": [ "no-cache" ], + "Pragma": [ "no-cache" ], + "Vary": [ "Accept-Encoding" ], + "session-id": [ "694c1cdd-5000-4a20-a214-06f160bb22a4" ], + "x-ms-request-id": [ "abbabf4c-1d8a-4caf-bcce-c41d246a3cf7" ], + "x-ms-correlation-request-id": [ "5ff3f209-9582-4551-94da-8a039ea7bb9a" ], + "x-ms-client-request-id": [ "dd33ad9d-1784-4051-b058-dc7f19937624" ], + "X-Powered-By": [ "ASP.NET" ], + "x-ms-ratelimit-remaining-subscription-reads": [ "11995" ], + "x-ms-routing-request-id": [ "SOUTHEASTASIA:20201118T070128Z:5ff3f209-9582-4551-94da-8a039ea7bb9a" ], + "Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" ], + "X-Content-Type-Options": [ "nosniff" ], + "Date": [ "Wed, 18 Nov 2020 07:01:28 GMT" ] + }, + "ContentHeaders": { + "Content-Length": [ "762" ], + "Content-Type": [ "application/json; charset=utf-8" ], + "Expires": [ "-1" ] + }, + "Content": "{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-oenfxg\",\"name\":\"export-oenfxg\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d6bd74b260689e\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-11-18T14:33:13\",\"to\":\"2020-12-08T14:33:13\"}},\"nextRunTimeEstimate\":\"2020-11-18T19:01:28.3543878Z\",\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-gali06/providers/Microsoft.Storage/storageAccounts/staaccountjshubiu\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}}" + } + }, + "Get-AzCostManagementExport+[NoContext]+GetViaIdentity+$GET+https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-oenfxg?api-version=2020-06-01+2": { + "Request": { + "Method": "GET", + "RequestUri": "https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-oenfxg?api-version=2020-06-01", + "Content": null, + "Headers": { + "x-ms-unique-id": [ "4" ], + "x-ms-client-request-id": [ "9aa28b62-5456-4ae9-84cf-3998beb992fd" ], + "CommandName": [ "Get-AzCostManagementExport" ], + "FullCommandName": [ "Get-AzCostManagementExport_GetViaIdentity" ], + "ParameterSetName": [ "__AllParameterSets" ], + "User-Agent": [ "AzurePowershell/Az4.0.0-preview" ], + "Authorization": [ "[Filtered]" ] + }, + "ContentHeaders": { + } + }, + "Response": { + "StatusCode": 200, + "Headers": { + "Cache-Control": [ "no-cache" ], + "Pragma": [ "no-cache" ], + "Vary": [ "Accept-Encoding" ], + "session-id": [ "f2825f60-8a64-4405-a1e5-9603815df2c7" ], + "x-ms-request-id": [ "66093be2-1093-45ca-9b47-7170ddb604d0" ], + "x-ms-correlation-request-id": [ "73507b6e-2ae5-462a-95c6-921ff56f9532" ], + "x-ms-client-request-id": [ "9aa28b62-5456-4ae9-84cf-3998beb992fd" ], + "X-Powered-By": [ "ASP.NET" ], + "x-ms-ratelimit-remaining-subscription-reads": [ "11994" ], + "x-ms-routing-request-id": [ "SOUTHEASTASIA:20201118T070129Z:73507b6e-2ae5-462a-95c6-921ff56f9532" ], + "Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" ], + "X-Content-Type-Options": [ "nosniff" ], + "Date": [ "Wed, 18 Nov 2020 07:01:28 GMT" ] + }, + "ContentHeaders": { + "Content-Length": [ "762" ], + "Content-Type": [ "application/json; charset=utf-8" ], + "Expires": [ "-1" ] + }, + "Content": "{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-oenfxg\",\"name\":\"export-oenfxg\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d6bd74b260689e\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-11-18T14:33:13\",\"to\":\"2020-12-08T14:33:13\"}},\"nextRunTimeEstimate\":\"2020-11-18T19:01:28.9611203Z\",\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-gali06/providers/Microsoft.Storage/storageAccounts/staaccountjshubiu\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}}" + } + } +} \ No newline at end of file diff --git a/src/CostManagement/test/Get-AzCostManagementExport.Tests.ps1 b/src/CostManagement/test/Get-AzCostManagementExport.Tests.ps1 new file mode 100644 index 000000000000..2940b9cb4076 --- /dev/null +++ b/src/CostManagement/test/Get-AzCostManagementExport.Tests.ps1 @@ -0,0 +1,30 @@ +$loadEnvPath = Join-Path $PSScriptRoot 'loadEnv.ps1' +if (-Not (Test-Path -Path $loadEnvPath)) { + $loadEnvPath = Join-Path $PSScriptRoot '..\loadEnv.ps1' +} +. ($loadEnvPath) +$TestRecordingFile = Join-Path $PSScriptRoot 'Get-AzCostManagementExport.Recording.json' +$currentPath = $PSScriptRoot +while(-not $mockingPath) { + $mockingPath = Get-ChildItem -Path $currentPath -Recurse -Include 'HttpPipelineMocking.ps1' -File + $currentPath = Split-Path -Path $currentPath -Parent +} +. ($mockingPath | Select-Object -First 1).FullName + +Describe 'Get-AzCostManagementExport' { + It 'List' { + $exportList = Get-AzCostManagementExport -Scope "subscriptions/$($env.SubscriptionId)" + $exportList.Count | Should -BeGreaterOrEqual 1 + } + + It 'Get' { + $export = Get-AzCostManagementExport -Scope "subscriptions/$($env.SubscriptionId)" -Name $env.exportName01 + $export.Name | Should -Be $env.exportName01 + } + + It 'GetViaIdentity' { + $export = Get-AzCostManagementExport -Scope "subscriptions/$($env.SubscriptionId)" -Name $env.exportName01 + $export = Get-AzCostManagementExport -InputObject $export + $export.Name | Should -Be $env.exportName01 + } +} diff --git a/src/CostManagement/test/Get-AzCostManagementExportExecutionHistory.Recording.json b/src/CostManagement/test/Get-AzCostManagementExportExecutionHistory.Recording.json new file mode 100644 index 000000000000..498de3ec2549 --- /dev/null +++ b/src/CostManagement/test/Get-AzCostManagementExportExecutionHistory.Recording.json @@ -0,0 +1,128 @@ +{ + "Get-AzCostManagementExportExecutionHistory+[NoContext]+Get+$GET+https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-oenfxg/runHistory?api-version=2020-06-01+1": { + "Request": { + "Method": "GET", + "RequestUri": "https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-oenfxg/runHistory?api-version=2020-06-01", + "Content": null, + "Headers": { + "x-ms-unique-id": [ "1" ], + "x-ms-client-request-id": [ "23f11f1f-f46b-4cc0-911e-8f4ec0cdfead" ], + "CommandName": [ "Get-AzCostManagementExportExecutionHistory" ], + "FullCommandName": [ "Get-AzCostManagementExportExecutionHistory_Get" ], + "ParameterSetName": [ "__AllParameterSets" ], + "User-Agent": [ "AzurePowershell/Az4.0.0-preview" ], + "Authorization": [ "[Filtered]" ] + }, + "ContentHeaders": { + } + }, + "Response": { + "StatusCode": 200, + "Headers": { + "Cache-Control": [ "no-cache" ], + "Pragma": [ "no-cache" ], + "Vary": [ "Accept-Encoding" ], + "session-id": [ "a6606686-60eb-4a95-8652-8541b8a9878e" ], + "x-ms-request-id": [ "4cec0d72-ab40-4629-aba4-55028d98a4ca" ], + "x-ms-correlation-request-id": [ "e71587b4-1863-4b23-849e-346466f86590" ], + "x-ms-client-request-id": [ "23f11f1f-f46b-4cc0-911e-8f4ec0cdfead" ], + "X-Powered-By": [ "ASP.NET" ], + "x-ms-ratelimit-remaining-subscription-reads": [ "11991" ], + "x-ms-routing-request-id": [ "SOUTHEASTASIA:20201118T072513Z:e71587b4-1863-4b23-849e-346466f86590" ], + "Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" ], + "X-Content-Type-Options": [ "nosniff" ], + "Date": [ "Wed, 18 Nov 2020 07:25:12 GMT" ] + }, + "ContentHeaders": { + "Content-Length": [ "1856" ], + "Content-Type": [ "application/json; charset=utf-8" ], + "Expires": [ "-1" ] + }, + "Content": "{\"value\":[{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-oenfxg/Run/46fcbcd5-e265-4d3d-b64d-29730797d629\",\"name\":null,\"type\":null,\"eTag\":null,\"properties\":{\"runSettings\":{\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-gali06/providers/Microsoft.Storage/storageAccounts/staaccountjshubiu\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}},\"executionType\":\"OnDemand\",\"status\":\"Completed\",\"submittedBy\":\"v-lipyo@microsoft.com\",\"submittedTime\":\"2020-11-18T07:23:47.826442Z\",\"processingStartTime\":\"2020-11-18T07:23:49.9336163Z\",\"processingEndTime\":\"2020-11-18T07:24:34.1615162Z\",\"fileName\":\"ad-hoc/export-oenfxg/20201101-20201130/export-oenfxg_46fcbcd5-e265-4d3d-b64d-29730797d629.csv\"}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-oenfxg/Run/7bc55aa1-73c7-4817-a792-a5d18f16c30b\",\"name\":null,\"type\":null,\"eTag\":null,\"properties\":{\"runSettings\":{\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-gali06/providers/Microsoft.Storage/storageAccounts/staaccountjshubiu\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}},\"executionType\":\"OnDemand\",\"status\":\"Completed\",\"submittedBy\":\"v-lipyo@microsoft.com\",\"submittedTime\":\"2020-11-18T07:23:51.0272403Z\",\"processingStartTime\":\"2020-11-18T07:23:53.0245821Z\",\"processingEndTime\":\"2020-11-18T07:24:25.01233Z\",\"fileName\":\"ad-hoc/export-oenfxg/20201101-20201130/export-oenfxg_7bc55aa1-73c7-4817-a792-a5d18f16c30b.csv\"}}]}" + } + }, + "Get-AzCostManagementExportExecutionHistory+[NoContext]+GetViaIdentity+$GET+https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-oenfxg?api-version=2020-06-01+1": { + "Request": { + "Method": "GET", + "RequestUri": "https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-oenfxg?api-version=2020-06-01", + "Content": null, + "Headers": { + "x-ms-unique-id": [ "2" ], + "x-ms-client-request-id": [ "73a50aa7-ed60-4a71-ab9e-3db97e2355e2" ], + "CommandName": [ "Get-AzCostManagementExport" ], + "FullCommandName": [ "Get-AzCostManagementExport_Get" ], + "ParameterSetName": [ "__AllParameterSets" ], + "User-Agent": [ "AzurePowershell/Az4.0.0-preview" ], + "Authorization": [ "[Filtered]" ] + }, + "ContentHeaders": { + } + }, + "Response": { + "StatusCode": 200, + "Headers": { + "Cache-Control": [ "no-cache" ], + "Pragma": [ "no-cache" ], + "Vary": [ "Accept-Encoding" ], + "session-id": [ "b9a804c4-5c5e-4270-bdd9-7ee7b70bbdcf" ], + "x-ms-request-id": [ "2ab7588d-c1dc-41c0-a957-75c6c3797d85" ], + "x-ms-correlation-request-id": [ "9900b0be-b85b-4772-a73d-ff9336d142ec" ], + "x-ms-client-request-id": [ "73a50aa7-ed60-4a71-ab9e-3db97e2355e2" ], + "X-Powered-By": [ "ASP.NET" ], + "x-ms-ratelimit-remaining-subscription-reads": [ "11990" ], + "x-ms-routing-request-id": [ "SOUTHEASTASIA:20201118T072513Z:9900b0be-b85b-4772-a73d-ff9336d142ec" ], + "Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" ], + "X-Content-Type-Options": [ "nosniff" ], + "Date": [ "Wed, 18 Nov 2020 07:25:12 GMT" ] + }, + "ContentHeaders": { + "Content-Length": [ "762" ], + "Content-Type": [ "application/json; charset=utf-8" ], + "Expires": [ "-1" ] + }, + "Content": "{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-oenfxg\",\"name\":\"export-oenfxg\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d6bd7bacc71476\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-11-18T15:18:13\",\"to\":\"2020-12-08T14:33:13\"}},\"nextRunTimeEstimate\":\"2020-11-18T19:25:13.5620095Z\",\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-gali06/providers/Microsoft.Storage/storageAccounts/staaccountjshubiu\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}}" + } + }, + "Get-AzCostManagementExportExecutionHistory+[NoContext]+GetViaIdentity+$GET+https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-oenfxg/runHistory?api-version=2020-06-01+2": { + "Request": { + "Method": "GET", + "RequestUri": "https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-oenfxg/runHistory?api-version=2020-06-01", + "Content": null, + "Headers": { + "x-ms-unique-id": [ "3" ], + "x-ms-client-request-id": [ "29fa47d9-86e7-466f-b5f0-0dcf1901cf4e" ], + "CommandName": [ "Get-AzCostManagementExportExecutionHistory" ], + "FullCommandName": [ "Get-AzCostManagementExportExecutionHistory_GetViaIdentity" ], + "ParameterSetName": [ "__AllParameterSets" ], + "User-Agent": [ "AzurePowershell/Az4.0.0-preview" ], + "Authorization": [ "[Filtered]" ] + }, + "ContentHeaders": { + } + }, + "Response": { + "StatusCode": 200, + "Headers": { + "Cache-Control": [ "no-cache" ], + "Pragma": [ "no-cache" ], + "Vary": [ "Accept-Encoding" ], + "session-id": [ "8ecb35b7-2d7b-4c0a-bd8d-8cf0a0752340" ], + "x-ms-request-id": [ "ba2e7d02-8d12-4551-b694-5311269b1512" ], + "x-ms-correlation-request-id": [ "dd87d05f-f740-4a4a-b4b2-8768f03ace3b" ], + "x-ms-client-request-id": [ "29fa47d9-86e7-466f-b5f0-0dcf1901cf4e" ], + "X-Powered-By": [ "ASP.NET" ], + "x-ms-ratelimit-remaining-subscription-reads": [ "11989" ], + "x-ms-routing-request-id": [ "SOUTHEASTASIA:20201118T072514Z:dd87d05f-f740-4a4a-b4b2-8768f03ace3b" ], + "Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" ], + "X-Content-Type-Options": [ "nosniff" ], + "Date": [ "Wed, 18 Nov 2020 07:25:13 GMT" ] + }, + "ContentHeaders": { + "Content-Length": [ "1856" ], + "Content-Type": [ "application/json; charset=utf-8" ], + "Expires": [ "-1" ] + }, + "Content": "{\"value\":[{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-oenfxg/Run/46fcbcd5-e265-4d3d-b64d-29730797d629\",\"name\":null,\"type\":null,\"eTag\":null,\"properties\":{\"runSettings\":{\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-gali06/providers/Microsoft.Storage/storageAccounts/staaccountjshubiu\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}},\"executionType\":\"OnDemand\",\"status\":\"Completed\",\"submittedBy\":\"v-lipyo@microsoft.com\",\"submittedTime\":\"2020-11-18T07:23:47.826442Z\",\"processingStartTime\":\"2020-11-18T07:23:49.9336163Z\",\"processingEndTime\":\"2020-11-18T07:24:34.1615162Z\",\"fileName\":\"ad-hoc/export-oenfxg/20201101-20201130/export-oenfxg_46fcbcd5-e265-4d3d-b64d-29730797d629.csv\"}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-oenfxg/Run/7bc55aa1-73c7-4817-a792-a5d18f16c30b\",\"name\":null,\"type\":null,\"eTag\":null,\"properties\":{\"runSettings\":{\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-gali06/providers/Microsoft.Storage/storageAccounts/staaccountjshubiu\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}},\"executionType\":\"OnDemand\",\"status\":\"Completed\",\"submittedBy\":\"v-lipyo@microsoft.com\",\"submittedTime\":\"2020-11-18T07:23:51.0272403Z\",\"processingStartTime\":\"2020-11-18T07:23:53.0245821Z\",\"processingEndTime\":\"2020-11-18T07:24:25.01233Z\",\"fileName\":\"ad-hoc/export-oenfxg/20201101-20201130/export-oenfxg_7bc55aa1-73c7-4817-a792-a5d18f16c30b.csv\"}}]}" + } + } +} \ No newline at end of file diff --git a/src/CostManagement/test/Get-AzCostManagementExportExecutionHistory.Tests.ps1 b/src/CostManagement/test/Get-AzCostManagementExportExecutionHistory.Tests.ps1 new file mode 100644 index 000000000000..a1372bb46ed9 --- /dev/null +++ b/src/CostManagement/test/Get-AzCostManagementExportExecutionHistory.Tests.ps1 @@ -0,0 +1,25 @@ +$loadEnvPath = Join-Path $PSScriptRoot 'loadEnv.ps1' +if (-Not (Test-Path -Path $loadEnvPath)) { + $loadEnvPath = Join-Path $PSScriptRoot '..\loadEnv.ps1' +} +. ($loadEnvPath) +$TestRecordingFile = Join-Path $PSScriptRoot 'Get-AzCostManagementExportExecutionHistory.Recording.json' +$currentPath = $PSScriptRoot +while(-not $mockingPath) { + $mockingPath = Get-ChildItem -Path $currentPath -Recurse -Include 'HttpPipelineMocking.ps1' -File + $currentPath = Split-Path -Path $currentPath -Parent +} +. ($mockingPath | Select-Object -First 1).FullName + +Describe 'Get-AzCostManagementExportExecutionHistory' { + It 'Get' { + $exportHist = Get-AzCostManagementExportExecutionHistory -Scope "subscriptions/$($env.SubscriptionId)" -ExportName $env.exportName01 + $exportHist.Count | Should -Be 2 + } + + It 'GetViaIdentity' { + $export = Get-AzCostManagementExport -Scope "subscriptions/$($env.SubscriptionId)" -Name $env.exportName01 + $exportHist = Get-AzCostManagementExportExecutionHistory -InputObject $export + $exportHist.Count | Should -Be 2 + } +} diff --git a/src/CostManagement/test/Invoke-AzCostManagementExecuteExport.Recording.json b/src/CostManagement/test/Invoke-AzCostManagementExecuteExport.Recording.json new file mode 100644 index 000000000000..bd7c5dfe8da8 --- /dev/null +++ b/src/CostManagement/test/Invoke-AzCostManagementExecuteExport.Recording.json @@ -0,0 +1,208 @@ +{ + "Invoke-AzCostManagementExecuteExport+[NoContext]+Execute+$POST+https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-oenfxg/run?api-version=2020-06-01+1": { + "Request": { + "Method": "POST", + "RequestUri": "https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-oenfxg/run?api-version=2020-06-01", + "Content": null, + "Headers": { + "x-ms-unique-id": [ "1" ], + "x-ms-client-request-id": [ "15e9cb13-90d9-4709-9bf8-cc6424b3fadf" ], + "CommandName": [ "Invoke-AzCostManagementExecuteExport" ], + "FullCommandName": [ "Invoke-AzCostManagementExecuteExport_Execute" ], + "ParameterSetName": [ "__AllParameterSets" ], + "User-Agent": [ "AzurePowershell/Az4.0.0-preview" ], + "Authorization": [ "[Filtered]" ] + }, + "ContentHeaders": { + } + }, + "Response": { + "StatusCode": 200, + "Headers": { + "Cache-Control": [ "no-cache" ], + "Pragma": [ "no-cache" ], + "session-id": [ "18bb1119-00da-487a-a5f9-258893d7546a" ], + "x-ms-request-id": [ "cd99ca74-4db5-492d-b7f6-d80d0b9a3c58" ], + "x-ms-correlation-request-id": [ "9cc9ce6b-f352-4366-a410-bf9f9584ed74" ], + "x-ms-client-request-id": [ "15e9cb13-90d9-4709-9bf8-cc6424b3fadf" ], + "X-Powered-By": [ "ASP.NET" ], + "x-ms-ratelimit-remaining-subscription-reads": [ "11996" ], + "x-ms-routing-request-id": [ "SOUTHEASTASIA:20201118T072349Z:9cc9ce6b-f352-4366-a410-bf9f9584ed74" ], + "Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" ], + "X-Content-Type-Options": [ "nosniff" ], + "Date": [ "Wed, 18 Nov 2020 07:23:49 GMT" ] + }, + "ContentHeaders": { + "Expires": [ "-1" ], + "Content-Length": [ "0" ] + }, + "Content": null + } + }, + "Invoke-AzCostManagementExecuteExport+[NoContext]+Execute+$GET+https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-oenfxg/runHistory?api-version=2020-06-01+2": { + "Request": { + "Method": "GET", + "RequestUri": "https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-oenfxg/runHistory?api-version=2020-06-01", + "Content": null, + "Headers": { + "x-ms-unique-id": [ "2" ], + "x-ms-client-request-id": [ "7a53a0f6-4051-4e48-a4ba-57d93a2e2f58" ], + "CommandName": [ "Get-AzCostManagementExportExecutionHistory" ], + "FullCommandName": [ "Get-AzCostManagementExportExecutionHistory_Get" ], + "ParameterSetName": [ "__AllParameterSets" ], + "User-Agent": [ "AzurePowershell/Az4.0.0-preview" ], + "Authorization": [ "[Filtered]" ] + }, + "ContentHeaders": { + } + }, + "Response": { + "StatusCode": 200, + "Headers": { + "Cache-Control": [ "no-cache" ], + "Pragma": [ "no-cache" ], + "Vary": [ "Accept-Encoding" ], + "session-id": [ "c9c9317e-b541-4389-8544-723601ab9332" ], + "x-ms-request-id": [ "ece4d240-3a16-45a4-9307-e42063bc0e4c" ], + "x-ms-correlation-request-id": [ "d059e713-a14e-4436-8cd8-e79cc17e76b2" ], + "x-ms-client-request-id": [ "7a53a0f6-4051-4e48-a4ba-57d93a2e2f58" ], + "X-Powered-By": [ "ASP.NET" ], + "x-ms-ratelimit-remaining-subscription-reads": [ "11995" ], + "x-ms-routing-request-id": [ "SOUTHEASTASIA:20201118T072350Z:d059e713-a14e-4436-8cd8-e79cc17e76b2" ], + "Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" ], + "X-Content-Type-Options": [ "nosniff" ], + "Date": [ "Wed, 18 Nov 2020 07:23:49 GMT" ] + }, + "ContentHeaders": { + "Content-Length": [ "792" ], + "Content-Type": [ "application/json; charset=utf-8" ], + "Expires": [ "-1" ] + }, + "Content": "{\"value\":[{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-oenfxg/Run/46fcbcd5-e265-4d3d-b64d-29730797d629\",\"name\":null,\"type\":null,\"eTag\":null,\"properties\":{\"runSettings\":{\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-gali06/providers/Microsoft.Storage/storageAccounts/staaccountjshubiu\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}},\"executionType\":\"OnDemand\",\"status\":\"InProgress\",\"submittedBy\":\"v-lipyo@microsoft.com\",\"submittedTime\":\"2020-11-18T07:23:47.826442Z\",\"processingStartTime\":null,\"processingEndTime\":null,\"fileName\":null}}]}" + } + }, + "Invoke-AzCostManagementExecuteExport+[NoContext]+ExecuteViaIdentity+$GET+https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-oenfxg?api-version=2020-06-01+1": { + "Request": { + "Method": "GET", + "RequestUri": "https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-oenfxg?api-version=2020-06-01", + "Content": null, + "Headers": { + "x-ms-unique-id": [ "3" ], + "x-ms-client-request-id": [ "ce57afeb-eac4-49cd-b790-634e2673251c" ], + "CommandName": [ "Get-AzCostManagementExport" ], + "FullCommandName": [ "Get-AzCostManagementExport_Get" ], + "ParameterSetName": [ "__AllParameterSets" ], + "User-Agent": [ "AzurePowershell/Az4.0.0-preview" ], + "Authorization": [ "[Filtered]" ] + }, + "ContentHeaders": { + } + }, + "Response": { + "StatusCode": 200, + "Headers": { + "Cache-Control": [ "no-cache" ], + "Pragma": [ "no-cache" ], + "Vary": [ "Accept-Encoding" ], + "session-id": [ "671aad90-703f-4db9-8b30-0526507ab6b0" ], + "x-ms-request-id": [ "107d74b6-4d7f-4511-bb72-4720738bad95" ], + "x-ms-correlation-request-id": [ "909eb4c7-2f3b-44db-88b8-5b01e8a20325" ], + "x-ms-client-request-id": [ "ce57afeb-eac4-49cd-b790-634e2673251c" ], + "X-Powered-By": [ "ASP.NET" ], + "x-ms-ratelimit-remaining-subscription-reads": [ "11994" ], + "x-ms-routing-request-id": [ "SOUTHEASTASIA:20201118T072350Z:909eb4c7-2f3b-44db-88b8-5b01e8a20325" ], + "Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" ], + "X-Content-Type-Options": [ "nosniff" ], + "Date": [ "Wed, 18 Nov 2020 07:23:50 GMT" ] + }, + "ContentHeaders": { + "Content-Length": [ "762" ], + "Content-Type": [ "application/json; charset=utf-8" ], + "Expires": [ "-1" ] + }, + "Content": "{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-oenfxg\",\"name\":\"export-oenfxg\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d6bd7bacc71476\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-11-18T15:18:13\",\"to\":\"2020-12-08T14:33:13\"}},\"nextRunTimeEstimate\":\"2020-11-18T19:23:50.5429086Z\",\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-gali06/providers/Microsoft.Storage/storageAccounts/staaccountjshubiu\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}}" + } + }, + "Invoke-AzCostManagementExecuteExport+[NoContext]+ExecuteViaIdentity+$POST+https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-oenfxg/run?api-version=2020-06-01+2": { + "Request": { + "Method": "POST", + "RequestUri": "https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-oenfxg/run?api-version=2020-06-01", + "Content": null, + "Headers": { + "x-ms-unique-id": [ "4" ], + "x-ms-client-request-id": [ "f7c1b42e-c314-4937-be4a-799dd5264710" ], + "CommandName": [ "Invoke-AzCostManagementExecuteExport" ], + "FullCommandName": [ "Invoke-AzCostManagementExecuteExport_ExecuteViaIdentity" ], + "ParameterSetName": [ "__AllParameterSets" ], + "User-Agent": [ "AzurePowershell/Az4.0.0-preview" ], + "Authorization": [ "[Filtered]" ] + }, + "ContentHeaders": { + } + }, + "Response": { + "StatusCode": 200, + "Headers": { + "Cache-Control": [ "no-cache" ], + "Pragma": [ "no-cache" ], + "session-id": [ "ba6dab3b-0775-4f70-9021-191d85b545d5" ], + "x-ms-request-id": [ "3d1f28d9-7c93-4ec9-ab82-e8a57f635bc2" ], + "x-ms-correlation-request-id": [ "70513666-265d-488e-a505-fd31c0ba4a75" ], + "x-ms-client-request-id": [ "f7c1b42e-c314-4937-be4a-799dd5264710" ], + "X-Powered-By": [ "ASP.NET" ], + "x-ms-ratelimit-remaining-subscription-reads": [ "11993" ], + "x-ms-routing-request-id": [ "SOUTHEASTASIA:20201118T072352Z:70513666-265d-488e-a505-fd31c0ba4a75" ], + "Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" ], + "X-Content-Type-Options": [ "nosniff" ], + "Date": [ "Wed, 18 Nov 2020 07:23:52 GMT" ] + }, + "ContentHeaders": { + "Expires": [ "-1" ], + "Content-Length": [ "0" ] + }, + "Content": null + } + }, + "Invoke-AzCostManagementExecuteExport+[NoContext]+ExecuteViaIdentity+$GET+https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-oenfxg/runHistory?api-version=2020-06-01+3": { + "Request": { + "Method": "GET", + "RequestUri": "https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-oenfxg/runHistory?api-version=2020-06-01", + "Content": null, + "Headers": { + "x-ms-unique-id": [ "5" ], + "x-ms-client-request-id": [ "035e700a-9b02-413e-9ebb-8d2e63725211" ], + "CommandName": [ "Get-AzCostManagementExportExecutionHistory" ], + "FullCommandName": [ "Get-AzCostManagementExportExecutionHistory_Get" ], + "ParameterSetName": [ "__AllParameterSets" ], + "User-Agent": [ "AzurePowershell/Az4.0.0-preview" ], + "Authorization": [ "[Filtered]" ] + }, + "ContentHeaders": { + } + }, + "Response": { + "StatusCode": 200, + "Headers": { + "Cache-Control": [ "no-cache" ], + "Pragma": [ "no-cache" ], + "Vary": [ "Accept-Encoding" ], + "session-id": [ "11ce37cf-b54f-4c7f-b528-5f1cd891bc42" ], + "x-ms-request-id": [ "c0e28c10-573a-4570-873c-8e1f2ebf5ca3" ], + "x-ms-correlation-request-id": [ "f4e04a41-f1c7-447e-8203-999c70d91ba0" ], + "x-ms-client-request-id": [ "035e700a-9b02-413e-9ebb-8d2e63725211" ], + "X-Powered-By": [ "ASP.NET" ], + "x-ms-ratelimit-remaining-subscription-reads": [ "11992" ], + "x-ms-routing-request-id": [ "SOUTHEASTASIA:20201118T072353Z:f4e04a41-f1c7-447e-8203-999c70d91ba0" ], + "Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" ], + "X-Content-Type-Options": [ "nosniff" ], + "Date": [ "Wed, 18 Nov 2020 07:23:52 GMT" ] + }, + "ContentHeaders": { + "Content-Length": [ "1574" ], + "Content-Type": [ "application/json; charset=utf-8" ], + "Expires": [ "-1" ] + }, + "Content": "{\"value\":[{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-oenfxg/Run/46fcbcd5-e265-4d3d-b64d-29730797d629\",\"name\":null,\"type\":null,\"eTag\":null,\"properties\":{\"runSettings\":{\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-gali06/providers/Microsoft.Storage/storageAccounts/staaccountjshubiu\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}},\"executionType\":\"OnDemand\",\"status\":\"InProgress\",\"submittedBy\":\"v-lipyo@microsoft.com\",\"submittedTime\":\"2020-11-18T07:23:47.826442Z\",\"processingStartTime\":null,\"processingEndTime\":null,\"fileName\":null}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-oenfxg/Run/7bc55aa1-73c7-4817-a792-a5d18f16c30b\",\"name\":null,\"type\":null,\"eTag\":null,\"properties\":{\"runSettings\":{\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-gali06/providers/Microsoft.Storage/storageAccounts/staaccountjshubiu\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}},\"executionType\":\"OnDemand\",\"status\":\"InProgress\",\"submittedBy\":\"v-lipyo@microsoft.com\",\"submittedTime\":\"2020-11-18T07:23:51.0272403Z\",\"processingStartTime\":null,\"processingEndTime\":null,\"fileName\":null}}]}" + } + } +} \ No newline at end of file diff --git a/src/CostManagement/test/Invoke-AzCostManagementExecuteExport.Tests.ps1 b/src/CostManagement/test/Invoke-AzCostManagementExecuteExport.Tests.ps1 new file mode 100644 index 000000000000..7c61a505d6d4 --- /dev/null +++ b/src/CostManagement/test/Invoke-AzCostManagementExecuteExport.Tests.ps1 @@ -0,0 +1,27 @@ +$loadEnvPath = Join-Path $PSScriptRoot 'loadEnv.ps1' +if (-Not (Test-Path -Path $loadEnvPath)) { + $loadEnvPath = Join-Path $PSScriptRoot '..\loadEnv.ps1' +} +. ($loadEnvPath) +$TestRecordingFile = Join-Path $PSScriptRoot 'Invoke-AzCostManagementExecuteExport.Recording.json' +$currentPath = $PSScriptRoot +while(-not $mockingPath) { + $mockingPath = Get-ChildItem -Path $currentPath -Recurse -Include 'HttpPipelineMocking.ps1' -File + $currentPath = Split-Path -Path $currentPath -Parent +} +. ($mockingPath | Select-Object -First 1).FullName + +Describe 'Invoke-AzCostManagementExecuteExport' { + It 'Execute' { + Invoke-AzCostManagementExecuteExport -Scope "subscriptions/$($env.SubscriptionId)" -ExportName $env.exportName01 + $exportHist = Get-AzCostManagementExportExecutionHistory -Scope "subscriptions/$($env.SubscriptionId)" -ExportName $env.exportName01 + $exportHist.Count | Should -Be 1 + } + + It 'ExecuteViaIdentity' { + $export = Get-AzCostManagementExport -Scope "subscriptions/$($env.SubscriptionId)" -Name $env.exportName01 + Invoke-AzCostManagementExecuteExport -InputObject $export + $exportHist = Get-AzCostManagementExportExecutionHistory -Scope "subscriptions/$($env.SubscriptionId)" -ExportName $env.exportName01 + $exportHist.Count | Should -Be 2 + } +} diff --git a/src/CostManagement/test/Invoke-AzCostManagementQuery.Tests.ps1 b/src/CostManagement/test/Invoke-AzCostManagementQuery.Tests.ps1 new file mode 100644 index 000000000000..9a9071335ebf --- /dev/null +++ b/src/CostManagement/test/Invoke-AzCostManagementQuery.Tests.ps1 @@ -0,0 +1,25 @@ +$loadEnvPath = Join-Path $PSScriptRoot 'loadEnv.ps1' +if (-Not (Test-Path -Path $loadEnvPath)) { + $loadEnvPath = Join-Path $PSScriptRoot '..\loadEnv.ps1' +} +. ($loadEnvPath) +$TestRecordingFile = Join-Path $PSScriptRoot 'Invoke-AzCostManagementQuery.Recording.json' +$currentPath = $PSScriptRoot +while(-not $mockingPath) { + $mockingPath = Get-ChildItem -Path $currentPath -Recurse -Include 'HttpPipelineMocking.ps1' -File + $currentPath = Split-Path -Path $currentPath -Parent +} +. ($mockingPath | Select-Object -First 1).FullName + +Describe 'Invoke-AzCostManagementQuery' { + It 'UsageExpanded' -skip { + $invbokeQueryResult = Invoke-AzCostManagementQuery -Scope "/subscriptions/$($env.SubscriptionId)" -Timeframe MonthToDate -Type Usage -DatasetGranularity 'Daily' + $invbokeQueryResult.Column.Name.Contains('UsageDate') | Should -Be $true + } + + # It 'UsageExpanded1' -skip { + # #$DimensionObject = new-AzCostManagementQueryComparisonExpressionObject -name 'ResourceGroup' -Operator 'In' -Value 'API' + # #$FilterObject = New-AzCostManagementQueryFilterObject -Dimension $DimensionObject + # #Invoke-AzCostManagementQuery -ExternalCloudProviderId 'Microsoft.Compute' -ExternalCloudProviderType externalBillingAccounts -Timeframe MonthToDate -type Usage -DatasetFilter $FilterObject -DatasetGranularity Daily -debug + # } +} diff --git a/src/CostManagement/test/New-AzCostManagementExport.Recording.json b/src/CostManagement/test/New-AzCostManagementExport.Recording.json new file mode 100644 index 000000000000..7344ac5256fe --- /dev/null +++ b/src/CostManagement/test/New-AzCostManagementExport.Recording.json @@ -0,0 +1,113 @@ +{ + "New-AzCostManagementExport+[NoContext]+CreateExpandedBySubscription+$PUT+https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-x9d0hl?api-version=2020-06-01+1": { + "Request": { + "Method": "PUT", + "RequestUri": "https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-x9d0hl?api-version=2020-06-01", + "Content": "{\r\n \"properties\": {\r\n \"definition\": {\r\n \"dataSet\": {\r\n \"granularity\": \"Daily\"\r\n },\r\n \"type\": \"Usage\",\r\n \"timeframe\": \"MonthToDate\"\r\n },\r\n \"deliveryInfo\": {\r\n \"destination\": {\r\n \"container\": \"exports\",\r\n \"resourceId\": \"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-gali06/providers/Microsoft.Storage/storageAccounts/staaccountjshubiu\",\r\n \"rootFolderPath\": \"ad-hoc\"\r\n }\r\n },\r\n \"format\": \"Csv\",\r\n \"schedule\": {\r\n \"recurrencePeriod\": {\r\n \"from\": \"2020-11-18T14:33:13.0000000\",\r\n \"to\": \"2020-12-08T14:33:13.0000000\"\r\n },\r\n \"recurrence\": \"Daily\",\r\n \"status\": \"Active\"\r\n }\r\n }\r\n}", + "Headers": { + }, + "ContentHeaders": { + "Content-Type": [ "application/json" ], + "Content-Length": [ "726" ] + } + }, + "Response": { + "StatusCode": 201, + "Headers": { + "Cache-Control": [ "no-cache" ], + "Pragma": [ "no-cache" ], + "Location": [ "https://costmanagement.trafficmanager.net/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-x9d0hl?api-version=2020-06-01" ], + "session-id": [ "7fcf2ee1-0f52-454b-b52b-c9035a39628e" ], + "x-ms-request-id": [ "a0551e42-d111-48c0-998f-a6aa754c5b30" ], + "x-ms-correlation-request-id": [ "5b87b8d1-a9dd-45e0-ba16-357f8ace82e8" ], + "x-ms-client-request-id": [ "9d4cf527-ae8c-4766-ae7c-d4e152715595" ], + "X-Powered-By": [ "ASP.NET" ], + "x-ms-ratelimit-remaining-subscription-reads": [ "11990" ], + "x-ms-routing-request-id": [ "SOUTHEASTASIA:20201118T071141Z:5b87b8d1-a9dd-45e0-ba16-357f8ace82e8" ], + "Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" ], + "X-Content-Type-Options": [ "nosniff" ], + "Date": [ "Wed, 18 Nov 2020 07:11:40 GMT" ] + }, + "ContentHeaders": { + "Content-Length": [ "709" ], + "Content-Type": [ "application/json; charset=utf-8" ], + "Expires": [ "-1" ] + }, + "Content": "{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-x9d0hl\",\"name\":\"export-x9d0hl\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d6bd7a0ff53443\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-11-18T14:33:13\",\"to\":\"2020-12-08T14:33:13\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-gali06/providers/Microsoft.Storage/storageAccounts/staaccountjshubiu\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}}" + } + }, + "New-AzCostManagementExport+[NoContext]+CreateExpandedByResourceGroup+$PUT+https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-gali06/providers/Microsoft.CostManagement/exports/export-d9y6fx?api-version=2020-06-01+1": { + "Request": { + "Method": "PUT", + "RequestUri": "https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-gali06/providers/Microsoft.CostManagement/exports/export-d9y6fx?api-version=2020-06-01", + "Content": "{\r\n \"properties\": {\r\n \"definition\": {\r\n \"dataSet\": {\r\n \"granularity\": \"Daily\"\r\n },\r\n \"type\": \"Usage\",\r\n \"timeframe\": \"MonthToDate\"\r\n },\r\n \"deliveryInfo\": {\r\n \"destination\": {\r\n \"container\": \"exports\",\r\n \"resourceId\": \"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-gali06/providers/Microsoft.Storage/storageAccounts/staaccountjshubiu\",\r\n \"rootFolderPath\": \"ad-hoc\"\r\n }\r\n },\r\n \"format\": \"Csv\",\r\n \"schedule\": {\r\n \"recurrencePeriod\": {\r\n \"from\": \"2020-11-18T14:33:13.0000000\",\r\n \"to\": \"2020-12-08T14:33:13.0000000\"\r\n },\r\n \"recurrence\": \"Daily\",\r\n \"status\": \"Active\"\r\n }\r\n }\r\n}", + "Headers": { + }, + "ContentHeaders": { + "Content-Type": [ "application/json" ], + "Content-Length": [ "726" ] + } + }, + "Response": { + "StatusCode": 201, + "Headers": { + "Cache-Control": [ "no-cache" ], + "Pragma": [ "no-cache" ], + "Location": [ "https://costmanagement.trafficmanager.net/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-gali06/providers/Microsoft.CostManagement/exports/export-d9y6fx?api-version=2020-06-01" ], + "session-id": [ "c227ef88-20fa-4121-a349-3d15e333a802" ], + "x-ms-request-id": [ "31026004-c411-488d-9b5c-520f6ea480c4" ], + "x-ms-correlation-request-id": [ "7d35ff32-a6b6-41a1-9e8f-d596601c6f87" ], + "x-ms-client-request-id": [ "65950298-7073-4406-985e-bfd3f4f6222b" ], + "X-Powered-By": [ "ASP.NET" ], + "x-ms-ratelimit-remaining-subscription-reads": [ "11989" ], + "x-ms-routing-request-id": [ "SOUTHEASTASIA:20201118T071142Z:7d35ff32-a6b6-41a1-9e8f-d596601c6f87" ], + "Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" ], + "X-Content-Type-Options": [ "nosniff" ], + "Date": [ "Wed, 18 Nov 2020 07:11:42 GMT" ] + }, + "ContentHeaders": { + "Content-Length": [ "749" ], + "Content-Type": [ "application/json; charset=utf-8" ], + "Expires": [ "-1" ] + }, + "Content": "{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-gali06/providers/Microsoft.CostManagement/exports/export-d9y6fx\",\"name\":\"export-d9y6fx\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d6bd7a10dd6183\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-11-18T14:33:13\",\"to\":\"2020-12-08T14:33:13\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-gali06/providers/Microsoft.Storage/storageAccounts/staaccountjshubiu\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}}" + } + }, + "New-AzCostManagementExport+[NoContext]+CreateExpandedByColumn+$PUT+https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-9pcvod?api-version=2020-06-01+1": { + "Request": { + "Method": "PUT", + "RequestUri": "https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-9pcvod?api-version=2020-06-01", + "Content": "{\r\n \"properties\": {\r\n \"definition\": {\r\n \"dataSet\": {\r\n \"configuration\": {\r\n \"columns\": [ \"SubscriptionGuid\", \"MeterId\", \"InstanceId\", \"ResourceGroup\", \"PreTaxCost\" ]\r\n },\r\n \"granularity\": \"Daily\"\r\n },\r\n \"type\": \"Usage\",\r\n \"timeframe\": \"MonthToDate\"\r\n },\r\n \"deliveryInfo\": {\r\n \"destination\": {\r\n \"container\": \"exports\",\r\n \"resourceId\": \"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-gali06/providers/Microsoft.Storage/storageAccounts/staaccountjshubiu\",\r\n \"rootFolderPath\": \"ad-hoc\"\r\n }\r\n },\r\n \"format\": \"Csv\",\r\n \"schedule\": {\r\n \"recurrencePeriod\": {\r\n \"from\": \"2020-11-18T14:33:13.0000000\",\r\n \"to\": \"2020-12-08T14:33:13.0000000\"\r\n },\r\n \"recurrence\": \"Daily\",\r\n \"status\": \"Active\"\r\n }\r\n }\r\n}", + "Headers": { + }, + "ContentHeaders": { + "Content-Type": [ "application/json" ], + "Content-Length": [ "867" ] + } + }, + "Response": { + "StatusCode": 201, + "Headers": { + "Cache-Control": [ "no-cache" ], + "Pragma": [ "no-cache" ], + "Location": [ "https://costmanagement.trafficmanager.net/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-9pcvod?api-version=2020-06-01" ], + "session-id": [ "660240c4-6608-4f6e-ac0c-a0d78f49ae3b" ], + "x-ms-request-id": [ "84d4cc5c-9777-48a8-a6fe-6db8e5dce8f4" ], + "x-ms-correlation-request-id": [ "fe40597b-cc97-4013-9e8b-95cd37deb749" ], + "x-ms-client-request-id": [ "fe5b590a-e8af-418d-8232-64a0cb4296dc" ], + "X-Powered-By": [ "ASP.NET" ], + "x-ms-ratelimit-remaining-subscription-reads": [ "11988" ], + "x-ms-routing-request-id": [ "SOUTHEASTASIA:20201118T071144Z:fe40597b-cc97-4013-9e8b-95cd37deb749" ], + "Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" ], + "X-Content-Type-Options": [ "nosniff" ], + "Date": [ "Wed, 18 Nov 2020 07:11:44 GMT" ] + }, + "ContentHeaders": { + "Content-Length": [ "810" ], + "Content-Type": [ "application/json; charset=utf-8" ], + "Expires": [ "-1" ] + }, + "Content": "{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-9pcvod\",\"name\":\"export-9pcvod\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d6bd7a11bbd2e1\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-11-18T14:33:13\",\"to\":\"2020-12-08T14:33:13\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-gali06/providers/Microsoft.Storage/storageAccounts/staaccountjshubiu\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"configuration\":{\"columns\":[\"SubscriptionGuid\",\"MeterId\",\"InstanceId\",\"ResourceGroup\",\"PreTaxCost\"]},\"granularity\":\"Daily\"}}}}" + } + } +} \ No newline at end of file diff --git a/src/CostManagement/test/New-AzCostManagementExport.Tests.ps1 b/src/CostManagement/test/New-AzCostManagementExport.Tests.ps1 new file mode 100644 index 000000000000..0639a66da637 --- /dev/null +++ b/src/CostManagement/test/New-AzCostManagementExport.Tests.ps1 @@ -0,0 +1,48 @@ +$loadEnvPath = Join-Path $PSScriptRoot 'loadEnv.ps1' +if (-Not (Test-Path -Path $loadEnvPath)) { + $loadEnvPath = Join-Path $PSScriptRoot '..\loadEnv.ps1' +} +. ($loadEnvPath) +$TestRecordingFile = Join-Path $PSScriptRoot 'New-AzCostManagementExport.Recording.json' +$currentPath = $PSScriptRoot +while(-not $mockingPath) { + $mockingPath = Get-ChildItem -Path $currentPath -Recurse -Include 'HttpPipelineMocking.ps1' -File + $currentPath = Split-Path -Path $currentPath -Parent +} +. ($mockingPath | Select-Object -First 1).FullName + +Describe 'New-AzCostManagementExport' { + It 'CreateExpandedBySubscription' { + # Create export cost management by subscription + $export = New-AzCostManagementExport -Scope "subscriptions/$($env.SubscriptionId)" -Name $env.exportName02 ` + -ScheduleStatus "Active" -ScheduleRecurrence "Daily" -RecurrencePeriodFrom $env.fromDate ` + -RecurrencePeriodTo $env.toDate -Format "Csv" ` + -DestinationResourceId $env.storageAccountId ` + -DestinationContainer "exports" -DestinationRootFolderPath "ad-hoc" -DefinitionType "Usage" -DefinitionTimeframe "MonthToDate" ` + -DatasetGranularity "Daily" + + $export.ScheduleStatus | Should -Be 'Active' + } + It 'CreateExpandedByResourceGroup' { + # Create export cost management by resource group + $export = New-AzCostManagementExport -Scope "subscriptions/$($env.SubscriptionId)/resourceGroups/$($env.resourceGroup)" -Name $env.exportName03 ` + -ScheduleStatus "Active" -ScheduleRecurrence "Daily" -RecurrencePeriodFrom $env.fromDate ` + -RecurrencePeriodTo $env.toDate -Format "Csv" ` + -DestinationResourceId $env.storageAccountId ` + -DestinationContainer "exports" -DestinationRootFolderPath "ad-hoc" -DefinitionType "Usage" -DefinitionTimeframe "MonthToDate" ` + -DatasetGranularity "Daily" + + $export.ScheduleStatus | Should -Be 'Active' + } + It 'CreateExpandedByColumn' { + $export = New-AzCostManagementExport -Scope "subscriptions/$($env.SubscriptionId)" -Name $env.exportName04 ` + -ScheduleStatus "Active" -ScheduleRecurrence "Daily" -RecurrencePeriodFrom $env.fromDate ` + -RecurrencePeriodTo $env.toDate -Format "Csv" ` + -DestinationResourceId $env.storageAccountId ` + -DestinationContainer "exports" -DestinationRootFolderPath "ad-hoc" -DefinitionType "Usage" -DefinitionTimeframe "MonthToDate" ` + -DatasetGranularity "Daily" ` + -ConfigurationColumn @('SubscriptionGuid', 'MeterId', 'InstanceId', 'ResourceGroup', 'PreTaxCost') + + $export.ScheduleStatus | Should -Be 'Active' + } +} diff --git a/src/CostManagement/test/New-AzCostManagementQueryColumnObject.Tests.ps1 b/src/CostManagement/test/New-AzCostManagementQueryColumnObject.Tests.ps1 new file mode 100644 index 000000000000..35a70dd55a82 --- /dev/null +++ b/src/CostManagement/test/New-AzCostManagementQueryColumnObject.Tests.ps1 @@ -0,0 +1,18 @@ +$loadEnvPath = Join-Path $PSScriptRoot 'loadEnv.ps1' +if (-Not (Test-Path -Path $loadEnvPath)) { + $loadEnvPath = Join-Path $PSScriptRoot '..\loadEnv.ps1' +} +. ($loadEnvPath) +$TestRecordingFile = Join-Path $PSScriptRoot 'New-AzCostManagementQueryColumnObject.Recording.json' +$currentPath = $PSScriptRoot +while(-not $mockingPath) { + $mockingPath = Get-ChildItem -Path $currentPath -Recurse -Include 'HttpPipelineMocking.ps1' -File + $currentPath = Split-Path -Path $currentPath -Parent +} +. ($mockingPath | Select-Object -First 1).FullName + +Describe 'New-AzCostManagementQueryColumnObject' { + It '__AllParameterSets' { + { New-AzCostManagementQueryColumnObject -Name 'SubscriptionGuid' -Type 'string' } | Should -Not -Throw + } +} diff --git a/src/CostManagement/test/New-AzCostManagementQueryComparisonExpressionObject.Tests.ps1 b/src/CostManagement/test/New-AzCostManagementQueryComparisonExpressionObject.Tests.ps1 new file mode 100644 index 000000000000..7cf80493cdc4 --- /dev/null +++ b/src/CostManagement/test/New-AzCostManagementQueryComparisonExpressionObject.Tests.ps1 @@ -0,0 +1,20 @@ +$loadEnvPath = Join-Path $PSScriptRoot 'loadEnv.ps1' +if (-Not (Test-Path -Path $loadEnvPath)) { + $loadEnvPath = Join-Path $PSScriptRoot '..\loadEnv.ps1' +} +. ($loadEnvPath) +$TestRecordingFile = Join-Path $PSScriptRoot 'New-AzCostManagementQueryComparisonExpressionObject.Recording.json' +$currentPath = $PSScriptRoot +while(-not $mockingPath) { + $mockingPath = Get-ChildItem -Path $currentPath -Recurse -Include 'HttpPipelineMocking.ps1' -File + $currentPath = Split-Path -Path $currentPath -Parent +} +. ($mockingPath | Select-Object -First 1).FullName + +Describe 'New-AzCostManagementQueryComparisonExpressionObject' { + It '__AllParameterSets' { + { + $orDimension = New-AzCostManagementQueryComparisonExpressionObject -Name 'ResourceLocation' -Operator In -Value @('East US', 'West Europe') + } | Should -Not -Throw + } +} diff --git a/src/CostManagement/test/New-AzCostManagementQueryFilterObject.Tests.ps1 b/src/CostManagement/test/New-AzCostManagementQueryFilterObject.Tests.ps1 new file mode 100644 index 000000000000..2e490b60f25b --- /dev/null +++ b/src/CostManagement/test/New-AzCostManagementQueryFilterObject.Tests.ps1 @@ -0,0 +1,26 @@ +$loadEnvPath = Join-Path $PSScriptRoot 'loadEnv.ps1' +if (-Not (Test-Path -Path $loadEnvPath)) { + $loadEnvPath = Join-Path $PSScriptRoot '..\loadEnv.ps1' +} +. ($loadEnvPath) +$TestRecordingFile = Join-Path $PSScriptRoot 'New-AzCostManagementQueryFilterObject.Recording.json' +$currentPath = $PSScriptRoot +while(-not $mockingPath) { + $mockingPath = Get-ChildItem -Path $currentPath -Recurse -Include 'HttpPipelineMocking.ps1' -File + $currentPath = Split-Path -Path $currentPath -Parent +} +. ($mockingPath | Select-Object -First 1).FullName + +Describe 'New-AzCostManagementQueryFilterObject' { + It '__AllParameterSets' { + { + $orDimension = New-AzCostManagementQueryComparisonExpressionObject -Name 'ResourceLocation' -Operator In -Value @('East US', 'West Europe') + $orTag = New-AzCostManagementQueryComparisonExpressionObject -Name 'Environment' -Operator In -Value @('UAT', 'Prod') + $andOr = New-AzCostManagementQueryFilterObject -or @((New-AzCostManagementQueryFilterObject -Dimension $orDimension), (New-AzCostManagementQueryFilterObject -Tag $orTag)) + + $dimension = New-AzCostManagementQueryComparisonExpressionObject -Name 'ResourceGroup' -Operator In -Value 'API' + $andDimension = New-AzCostManagementQueryFilterObject -Dimension $dimension + $fileter = New-AzCostManagementQueryFilterObject -And @($andOr, $andDimension) + } | Should -Not -Throw + } +} diff --git a/src/CostManagement/test/Remove-AzCostManagementExport.Recording.json b/src/CostManagement/test/Remove-AzCostManagementExport.Recording.json new file mode 100644 index 000000000000..e09c6f0a7d8d --- /dev/null +++ b/src/CostManagement/test/Remove-AzCostManagementExport.Recording.json @@ -0,0 +1,208 @@ +{ + "Remove-AzCostManagementExport+[NoContext]+Delete+$DELETE+https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-9pcvod?api-version=2020-06-01+1": { + "Request": { + "Method": "DELETE", + "RequestUri": "https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-9pcvod?api-version=2020-06-01", + "Content": null, + "Headers": { + "x-ms-unique-id": [ "1" ], + "x-ms-client-request-id": [ "6097a897-2c94-429f-8141-37ae62564a81" ], + "CommandName": [ "Remove-AzCostManagementExport" ], + "FullCommandName": [ "Remove-AzCostManagementExport_Delete" ], + "ParameterSetName": [ "__AllParameterSets" ], + "User-Agent": [ "AzurePowershell/Az4.0.0-preview" ], + "Authorization": [ "[Filtered]" ] + }, + "ContentHeaders": { + } + }, + "Response": { + "StatusCode": 200, + "Headers": { + "Cache-Control": [ "no-cache" ], + "Pragma": [ "no-cache" ], + "session-id": [ "99243537-446c-4223-9978-a16597ccc6d1" ], + "x-ms-request-id": [ "adc0e498-627d-4c73-838a-058a536b1dda" ], + "x-ms-correlation-request-id": [ "23aabe0d-4966-4ba4-9fa3-3923e00db19b" ], + "x-ms-client-request-id": [ "6097a897-2c94-429f-8141-37ae62564a81" ], + "X-Powered-By": [ "ASP.NET" ], + "x-ms-ratelimit-remaining-subscription-reads": [ "11975" ], + "x-ms-routing-request-id": [ "SOUTHEASTASIA:20201118T073529Z:23aabe0d-4966-4ba4-9fa3-3923e00db19b" ], + "Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" ], + "X-Content-Type-Options": [ "nosniff" ], + "Date": [ "Wed, 18 Nov 2020 07:35:29 GMT" ] + }, + "ContentHeaders": { + "Expires": [ "-1" ], + "Content-Length": [ "0" ] + }, + "Content": null + } + }, + "Remove-AzCostManagementExport+[NoContext]+Delete+$GET+https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports?api-version=2020-06-01+2": { + "Request": { + "Method": "GET", + "RequestUri": "https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports?api-version=2020-06-01", + "Content": null, + "Headers": { + "x-ms-unique-id": [ "2" ], + "x-ms-client-request-id": [ "b6609d7f-cc26-46f8-acc3-706cf8c14f75" ], + "CommandName": [ "Get-AzCostManagementExport" ], + "FullCommandName": [ "Get-AzCostManagementExport_List" ], + "ParameterSetName": [ "__AllParameterSets" ], + "User-Agent": [ "AzurePowershell/Az4.0.0-preview" ], + "Authorization": [ "[Filtered]" ] + }, + "ContentHeaders": { + } + }, + "Response": { + "StatusCode": 200, + "Headers": { + "Cache-Control": [ "no-cache" ], + "Pragma": [ "no-cache" ], + "Vary": [ "Accept-Encoding" ], + "session-id": [ "2603e8e7-9c1f-45dd-8187-52fd56799721" ], + "x-ms-request-id": [ "4a915377-e40e-4eae-b685-7cac25c37ae0" ], + "x-ms-correlation-request-id": [ "569bbca1-8fbb-477c-a491-3f8030fcf711" ], + "x-ms-client-request-id": [ "b6609d7f-cc26-46f8-acc3-706cf8c14f75" ], + "X-Powered-By": [ "ASP.NET" ], + "x-ms-ratelimit-remaining-subscription-reads": [ "11974" ], + "x-ms-routing-request-id": [ "SOUTHEASTASIA:20201118T073530Z:569bbca1-8fbb-477c-a491-3f8030fcf711" ], + "Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" ], + "X-Content-Type-Options": [ "nosniff" ], + "Date": [ "Wed, 18 Nov 2020 07:35:29 GMT" ] + }, + "ContentHeaders": { + "Content-Length": [ "28664" ], + "Content-Type": [ "application/json; charset=utf-8" ], + "Expires": [ "-1" ] + }, + "Content": "{\"value\":[{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/TestExport\",\"name\":\"TestExport\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d63fb46c1f5154\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-11T00:00:00+00:00\",\"to\":\"2020-06-20T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-costmanagement/providers/Microsoft.Storage/storageAccounts/wyunchistorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"configuration\":{\"columns\":[\"SubscriptionGuid\",\"MeterId\",\"InstanceId\",\"ResourceGroup\",\"PreTaxCost\"]},\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/TestExport1\",\"name\":\"TestExport1\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d63fb4a3f75019\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-11T20:00:00+00:00\",\"to\":\"2020-06-20T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-costmanagement/providers/Microsoft.Storage/storageAccounts/wyunchistorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"configuration\":{\"columns\":[\"SubscriptionGuid\",\"MeterId\",\"InstanceId\",\"ResourceGroup\",\"PreTaxCost\"]},\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/TestExport2\",\"name\":\"TestExport2\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d649f5dda56551\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-25T20:00:00+00:00\",\"to\":\"2020-06-29T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-costmanagement/providers/Microsoft.Storage/storageAccounts/wyunchistorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"configuration\":{\"columns\":[\"SubscriptionGuid\",\"MeterId\",\"InstanceId\",\"ResourceGroup\",\"PreTaxCost\"]},\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/TestExport3\",\"name\":\"TestExport3\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d649f6069c44bb\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-25T20:00:00+00:00\",\"to\":\"2020-06-29T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-costmanagement/providers/Microsoft.Storage/storageAccounts/wyunchistorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"configuration\":{\"columns\":[\"SubscriptionGuid\",\"MeterId\",\"InstanceId\",\"ResourceGroup\",\"PreTaxCost\"]},\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/LucasExport-T02\",\"name\":\"LucasExport-T02\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d649f8ec7b1149\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-25T20:00:00+00:00\",\"to\":\"2020-06-29T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-costmanagement/providers/Microsoft.Storage/storageAccounts/wyunchistorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\",\"aggregation\":{\"costsum\":{\"name\":\"PreTaxCost\",\"function\":\"Sum\"},\"cost\":{\"name\":\"Cost\",\"function\":\"Sum\"}},\"grouping\":[{\"type\":\"Dimension\",\"name\":\"ResourceGroup\"}]}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/LucasExport-T03\",\"name\":\"LucasExport-T03\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d649f918708873\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-25T20:00:00+00:00\",\"to\":\"2020-06-29T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-costmanagement/providers/Microsoft.Storage/storageAccounts/wyunchistorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\",\"aggregation\":{\"costsum\":{\"name\":\"PreTaxCost\",\"function\":\"Sum\"},\"cost\":{\"name\":\"Cost\",\"function\":\"Sum\"}},\"grouping\":[{\"type\":\"Dimension\",\"name\":\"ResourceGroup\"}]}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/LucasExportT06\",\"name\":\"LucasExportT06\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d649f9d2f5df21\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-27T20:00:00+00:00\",\"to\":\"2020-06-28T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-costmanagement/providers/Microsoft.Storage/storageAccounts/wyunchistorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\",\"aggregation\":{\"costsum\":{\"name\":\"PreTaxCost\",\"function\":\"Sum\"},\"cost\":{\"name\":\"Cost\",\"function\":\"Sum\"}},\"grouping\":[{\"type\":\"Dimension\",\"name\":\"ResourceGroup\"}]}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/ps-costext-t01\",\"name\":\"ps-costext-t01\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d649ff52ae2bb7\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-24T00:00:00+00:00\",\"to\":\"2020-06-26T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/azureps-manual-test/providers/Microsoft.Storage/storageAccounts/lucascostmanagement\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\",\"aggregation\":{\"costsum\":{\"name\":\"PreTaxCost\",\"function\":\"Sum\"},\"cost\":{\"name\":\"Cost\",\"function\":\"Sum\"}},\"grouping\":[{\"type\":\"Dimension\",\"name\":\"ResourceGroup\"}]}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/ps-costext-t02\",\"name\":\"ps-costext-t02\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d64d16faa5d7b4\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-28T00:00:00+00:00\",\"to\":\"2020-07-01T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/azureps-manual-test/providers/Microsoft.Storage/storageAccounts/lucascostmanagement\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\",\"aggregation\":{\"costsum\":{\"name\":\"PreTaxCost\",\"function\":\"Sum\"},\"cost\":{\"name\":\"Cost\",\"function\":\"Sum\"}},\"grouping\":[{\"type\":\"Dimension\",\"name\":\"ResourceGroup\"}]}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/ps-costext-t03\",\"name\":\"ps-costext-t03\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d64d1be92e19a4\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-28T07:45:28\",\"to\":\"2020-07-18T07:15:28\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/azureps-manual-test/providers/Microsoft.Storage/storageAccounts/lucascostmanagement\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\",\"aggregation\":{\"cost\":{\"name\":\"Cost\",\"function\":\"Sum\"},\"costsum\":{\"name\":\"PreTaxCost\",\"function\":\"Sum\"}},\"grouping\":[{\"type\":\"Dimension\",\"name\":\"ResourceGroup\"}]}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/exportws5qlv\",\"name\":\"exportws5qlv\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d64d1d1164c9ac\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-28T07:53:46\",\"to\":\"2020-07-18T07:23:46\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-manual-test/providers/Microsoft.Storage/storageAccounts/staaccountmkjhje\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\",\"aggregation\":{\"costsum\":{\"name\":\"PreTaxCost\",\"function\":\"Sum\"},\"cost\":{\"name\":\"Cost\",\"function\":\"Sum\"}},\"grouping\":[{\"type\":\"Dimension\",\"name\":\"ResourceGroup\"}]}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/manual-export-t01\",\"name\":\"manual-export-t01\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d64dd725acbcdf\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-29T20:00:00+00:00\",\"to\":\"2020-07-01T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-manual-test/providers/Microsoft.Storage/storageAccounts/lucasstorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/manual-export-t02\",\"name\":\"manual-export-t02\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d64dd8071bf283\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-29T13:00:00+00:00\",\"to\":\"2020-07-01T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-manual-test/providers/Microsoft.Storage/storageAccounts/lucasstorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/exportinfo-ps-t\",\"name\":\"exportinfo-ps-t\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d64dda275a663c\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-29T13:00:00+00:00\",\"to\":\"2020-07-01T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-manual-test/providers/Microsoft.Storage/storageAccounts/lucasstorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/ps-exportall-t\",\"name\":\"ps-exportall-t\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d64dda37395609\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-29T13:00:00+00:00\",\"to\":\"2020-07-01T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-manual-test/providers/Microsoft.Storage/storageAccounts/lucasstorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/ps-customcolum-t\",\"name\":\"ps-customcolum-t\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d64ddad337a774\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-29T13:00:00+00:00\",\"to\":\"2020-07-01T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-manual-test/providers/Microsoft.Storage/storageAccounts/lucasstorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"configuration\":{\"columns\":[\"SubscriptionGuid\",\"MeterId\",\"InstanceId\",\"ResourceGroup\",\"PreTaxCost\"]},\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/ps-aggregation-t\",\"name\":\"ps-aggregation-t\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d64ddb7d30c57d\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-29T13:00:00+00:00\",\"to\":\"2020-07-01T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-manual-test/providers/Microsoft.Storage/storageAccounts/lucasstorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\",\"aggregation\":{\"cost\":{\"name\":\"Cost\",\"function\":\"Sum\"},\"costsum\":{\"name\":\"PreTaxCost\",\"function\":\"Sum\"}}}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/ps-group-t\",\"name\":\"ps-group-t\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d64ddd2f00c7aa\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-29T13:00:00+00:00\",\"to\":\"2020-07-01T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-manual-test/providers/Microsoft.Storage/storageAccounts/lucasstorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\",\"grouping\":[{\"type\":\"Dimension\",\"name\":\"ResourceGroup\"}]}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/ps-groupaggregation-t\",\"name\":\"ps-groupaggregation-t\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d64dde4850e487\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-29T13:00:00+00:00\",\"to\":\"2020-07-01T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-manual-test/providers/Microsoft.Storage/storageAccounts/lucasstorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\",\"aggregation\":{\"cost\":{\"name\":\"Cost\",\"function\":\"Sum\"},\"costsum\":{\"name\":\"PreTaxCost\",\"function\":\"Sum\"}},\"grouping\":[{\"type\":\"Dimension\",\"name\":\"ResourceGroup\"}]}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/TestExport10\",\"name\":\"TestExport10\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d650dd9b8ab46b\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-07-03T20:00:00+00:00\",\"to\":\"2020-07-10T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-costmanagement/providers/Microsoft.Storage/storageAccounts/wyunchistorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/ps-exportall-t02\",\"name\":\"ps-exportall-t02\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d651104357293e\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-07-03T08:00:00+00:00\",\"to\":\"2020-08-01T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-manual-test/providers/Microsoft.Storage/storageAccounts/lucasstorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/ps-exportall-t03\",\"name\":\"ps-exportall-t03\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d65110a073dc56\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-07-03T08:00:00+00:00\",\"to\":\"2020-08-01T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-manual-test/providers/Microsoft.Storage/storageAccounts/lucasstorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-u9yfan\",\"name\":\"export-u9yfan\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d652b1674994fd\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-07-05T07:41:32\",\"to\":\"2020-07-21T07:41:32\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-manual-test/providers/Microsoft.Storage/storageAccounts/staaccountmhot0q\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-u9sfcn\",\"name\":\"export-u9sfcn\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d652b16952d046\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-07-05T07:41:32\",\"to\":\"2020-07-21T07:41:32\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-manual-test/providers/Microsoft.Storage/storageAccounts/staaccountmhot0q\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"configuration\":{\"columns\":[\"SubscriptionGuid\",\"MeterId\",\"InstanceId\",\"ResourceGroup\",\"PreTaxCost\"]},\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-cf6scg\",\"name\":\"export-cf6scg\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d652b16a169690\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-07-05T07:41:32\",\"to\":\"2020-07-21T07:41:32\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-manual-test/providers/Microsoft.Storage/storageAccounts/staaccountmhot0q\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\",\"grouping\":[{\"type\":\"Dimension\",\"name\":\"ResourceGroup\"}]}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-38we0i\",\"name\":\"export-38we0i\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d65375a9692caf\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-07-06T09:13:02\",\"to\":\"2020-07-26T09:13:02\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-5rij6b/providers/Microsoft.Storage/storageAccounts/staaccountjshubiu\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-r6xjol\",\"name\":\"export-r6xjol\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d65377005b37c6\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-07-06T09:13:02\",\"to\":\"2020-07-26T09:13:02\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-5rij6b/providers/Microsoft.Storage/storageAccounts/staaccountjshubiu\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-gq1kft\",\"name\":\"export-gq1kft\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d6537703972b88\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-07-06T09:13:02\",\"to\":\"2020-07-26T09:13:02\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-5rij6b/providers/Microsoft.Storage/storageAccounts/staaccountjshubiu\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\",\"grouping\":[{\"type\":\"Dimension\",\"name\":\"ResourceGroup\"}]}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-j8s5of\",\"name\":\"export-j8s5of\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d65377046dbf7c\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-07-06T09:13:02\",\"to\":\"2020-07-26T09:13:02\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-5rij6b/providers/Microsoft.Storage/storageAccounts/staaccountjshubiu\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\",\"aggregation\":{\"costsum\":{\"name\":\"PreTaxCost\",\"function\":\"Sum\"},\"cost\":{\"name\":\"Cost\",\"function\":\"Sum\"}},\"grouping\":[{\"type\":\"Dimension\",\"name\":\"ResourceGroup\"}]}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/TestExportDatasetAggregation123\",\"name\":\"TestExportDatasetAggregation123\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d6b19fb5559127\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-11-03T20:00:00+00:00\",\"to\":\"2020-11-10T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-costmanagement/providers/Microsoft.Storage/storageAccounts/wyunchistorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/TestExportDatasetAggregationInfoyouri\",\"name\":\"TestExportDatasetAggregationInfoyouri\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d6b33c18099a67\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-11-05T20:00:00+00:00\",\"to\":\"2020-11-10T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-costmanagement/providers/Microsoft.Storage/storageAccounts/wyunchistorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"configuration\":{\"columns\":[\"SubscriptionGuid\",\"MeterId\",\"InstanceId\",\"ResourceGroup\",\"PreTaxCost\"]},\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/TestUpdate1\",\"name\":\"TestUpdate1\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d6b6451f8f6d83\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-11-09T20:00:00+00:00\",\"to\":\"2020-11-20T00:00:00+00:00\"}},\"nextRunTimeEstimate\":\"2020-11-18T19:35:30.5064286Z\",\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-costmanagement/providers/Microsoft.Storage/storageAccounts/wyunchistorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/TestExportDatasetAggregationInfoYouri\",\"name\":\"TestExportDatasetAggregationInfoYouri\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d6b738f9459e9e\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-11-13T20:00:00Z\",\"to\":\"2020-11-17T00:00:00Z\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-costmanagement/providers/Microsoft.Storage/storageAccounts/wyunchistorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"adhoctest\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/TestExportDatasetAggregationYouriTest\",\"name\":\"TestExportDatasetAggregationYouriTest\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d6b7120d0af53a\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-11-10T20:00:00+00:00\",\"to\":\"2020-11-15T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-costmanagement/providers/Microsoft.Storage/storageAccounts/wyunchistorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"adhoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/TestExportDatasetAggregationInfo1118\",\"name\":\"TestExportDatasetAggregationInfo1118\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d6bd716961a536\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Weekly\",\"recurrencePeriod\":{\"from\":\"2020-11-18T20:00:00Z\",\"to\":\"2020-11-20T00:00:00Z\"}},\"nextRunTimeEstimate\":\"2020-11-18T20:00:00Z\",\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/youri-costmanagement/providers/Microsoft.Storage/storageAccounts/youristorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-oenfxg\",\"name\":\"export-oenfxg\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d6bd7c8581cbbf\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Weekly\",\"recurrencePeriod\":{\"from\":\"2020-11-18T15:18:13\",\"to\":\"2020-12-08T14:33:13\"}},\"nextRunTimeEstimate\":\"2020-11-18T19:35:30.5220541Z\",\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-gali06/providers/Microsoft.Storage/storageAccounts/staaccountjshubiu\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}}]}" + } + }, + "Remove-AzCostManagementExport+[NoContext]+DeleteViaIdentity+$GET+https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-gali06/providers/Microsoft.CostManagement/exports/export-d9y6fx?api-version=2020-06-01+1": { + "Request": { + "Method": "GET", + "RequestUri": "https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-gali06/providers/Microsoft.CostManagement/exports/export-d9y6fx?api-version=2020-06-01", + "Content": null, + "Headers": { + "x-ms-unique-id": [ "3" ], + "x-ms-client-request-id": [ "10b92aec-4d02-4c03-af0a-8852b2fef666" ], + "CommandName": [ "Get-AzCostManagementExport" ], + "FullCommandName": [ "Get-AzCostManagementExport_Get" ], + "ParameterSetName": [ "__AllParameterSets" ], + "User-Agent": [ "AzurePowershell/Az4.0.0-preview" ], + "Authorization": [ "[Filtered]" ] + }, + "ContentHeaders": { + } + }, + "Response": { + "StatusCode": 200, + "Headers": { + "Cache-Control": [ "no-cache" ], + "Pragma": [ "no-cache" ], + "Vary": [ "Accept-Encoding" ], + "session-id": [ "deabb3f6-02e7-4184-bbe7-7fc205c6281d" ], + "x-ms-request-id": [ "3467ee37-b4f1-4604-bcbf-72ab1497be1f" ], + "x-ms-correlation-request-id": [ "e4a855da-7c4d-4858-89ad-55ad09bc6263" ], + "x-ms-client-request-id": [ "10b92aec-4d02-4c03-af0a-8852b2fef666" ], + "X-Powered-By": [ "ASP.NET" ], + "x-ms-ratelimit-remaining-subscription-reads": [ "11973" ], + "x-ms-routing-request-id": [ "SOUTHEASTASIA:20201118T073531Z:e4a855da-7c4d-4858-89ad-55ad09bc6263" ], + "Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" ], + "X-Content-Type-Options": [ "nosniff" ], + "Date": [ "Wed, 18 Nov 2020 07:35:30 GMT" ] + }, + "ContentHeaders": { + "Content-Length": [ "802" ], + "Content-Type": [ "application/json; charset=utf-8" ], + "Expires": [ "-1" ] + }, + "Content": "{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-gali06/providers/Microsoft.CostManagement/exports/export-d9y6fx\",\"name\":\"export-d9y6fx\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d6bd7a10dd6183\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-11-18T14:33:13\",\"to\":\"2020-12-08T14:33:13\"}},\"nextRunTimeEstimate\":\"2020-11-18T19:35:31.3085144Z\",\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-gali06/providers/Microsoft.Storage/storageAccounts/staaccountjshubiu\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}}" + } + }, + "Remove-AzCostManagementExport+[NoContext]+DeleteViaIdentity+$DELETE+https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-gali06/providers/Microsoft.CostManagement/exports/export-d9y6fx?api-version=2020-06-01+2": { + "Request": { + "Method": "DELETE", + "RequestUri": "https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-gali06/providers/Microsoft.CostManagement/exports/export-d9y6fx?api-version=2020-06-01", + "Content": null, + "Headers": { + "x-ms-unique-id": [ "4" ], + "x-ms-client-request-id": [ "cd8e6c2d-1fb8-4bd1-b055-e389684293f3" ], + "CommandName": [ "Remove-AzCostManagementExport" ], + "FullCommandName": [ "Remove-AzCostManagementExport_DeleteViaIdentity" ], + "ParameterSetName": [ "__AllParameterSets" ], + "User-Agent": [ "AzurePowershell/Az4.0.0-preview" ], + "Authorization": [ "[Filtered]" ] + }, + "ContentHeaders": { + } + }, + "Response": { + "StatusCode": 200, + "Headers": { + "Cache-Control": [ "no-cache" ], + "Pragma": [ "no-cache" ], + "session-id": [ "3eb9af18-dfff-4861-b606-939129db2f00" ], + "x-ms-request-id": [ "1f69fc51-e1b8-43b5-a7b4-388189b4ae20" ], + "x-ms-correlation-request-id": [ "9e8153c4-0d85-4985-9bac-09254669d89f" ], + "x-ms-client-request-id": [ "cd8e6c2d-1fb8-4bd1-b055-e389684293f3" ], + "X-Powered-By": [ "ASP.NET" ], + "x-ms-ratelimit-remaining-subscription-reads": [ "11972" ], + "x-ms-routing-request-id": [ "SOUTHEASTASIA:20201118T073532Z:9e8153c4-0d85-4985-9bac-09254669d89f" ], + "Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" ], + "X-Content-Type-Options": [ "nosniff" ], + "Date": [ "Wed, 18 Nov 2020 07:35:31 GMT" ] + }, + "ContentHeaders": { + "Expires": [ "-1" ], + "Content-Length": [ "0" ] + }, + "Content": null + } + }, + "Remove-AzCostManagementExport+[NoContext]+DeleteViaIdentity+$GET+https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports?api-version=2020-06-01+3": { + "Request": { + "Method": "GET", + "RequestUri": "https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports?api-version=2020-06-01", + "Content": null, + "Headers": { + "x-ms-unique-id": [ "5" ], + "x-ms-client-request-id": [ "9cc2bac3-42f9-4cd5-9936-046b57c87b48" ], + "CommandName": [ "Get-AzCostManagementExport" ], + "FullCommandName": [ "Get-AzCostManagementExport_List" ], + "ParameterSetName": [ "__AllParameterSets" ], + "User-Agent": [ "AzurePowershell/Az4.0.0-preview" ], + "Authorization": [ "[Filtered]" ] + }, + "ContentHeaders": { + } + }, + "Response": { + "StatusCode": 200, + "Headers": { + "Cache-Control": [ "no-cache" ], + "Pragma": [ "no-cache" ], + "Vary": [ "Accept-Encoding" ], + "session-id": [ "b52ad8b7-3728-4f34-bfab-4d8a2c02409a" ], + "x-ms-request-id": [ "063076f8-77ac-43b8-9e38-d2fd07c1c346" ], + "x-ms-correlation-request-id": [ "eb6279ca-18d3-431c-91e4-0bca44a68271" ], + "x-ms-client-request-id": [ "9cc2bac3-42f9-4cd5-9936-046b57c87b48" ], + "X-Powered-By": [ "ASP.NET" ], + "x-ms-ratelimit-remaining-subscription-reads": [ "11971" ], + "x-ms-routing-request-id": [ "SOUTHEASTASIA:20201118T073533Z:eb6279ca-18d3-431c-91e4-0bca44a68271" ], + "Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" ], + "X-Content-Type-Options": [ "nosniff" ], + "Date": [ "Wed, 18 Nov 2020 07:35:32 GMT" ] + }, + "ContentHeaders": { + "Content-Length": [ "28664" ], + "Content-Type": [ "application/json; charset=utf-8" ], + "Expires": [ "-1" ] + }, + "Content": "{\"value\":[{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/TestExport\",\"name\":\"TestExport\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d63fb46c1f5154\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-11T00:00:00+00:00\",\"to\":\"2020-06-20T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-costmanagement/providers/Microsoft.Storage/storageAccounts/wyunchistorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"configuration\":{\"columns\":[\"SubscriptionGuid\",\"MeterId\",\"InstanceId\",\"ResourceGroup\",\"PreTaxCost\"]},\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/TestExport1\",\"name\":\"TestExport1\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d63fb4a3f75019\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-11T20:00:00+00:00\",\"to\":\"2020-06-20T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-costmanagement/providers/Microsoft.Storage/storageAccounts/wyunchistorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"configuration\":{\"columns\":[\"SubscriptionGuid\",\"MeterId\",\"InstanceId\",\"ResourceGroup\",\"PreTaxCost\"]},\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/TestExport2\",\"name\":\"TestExport2\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d649f5dda56551\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-25T20:00:00+00:00\",\"to\":\"2020-06-29T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-costmanagement/providers/Microsoft.Storage/storageAccounts/wyunchistorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"configuration\":{\"columns\":[\"SubscriptionGuid\",\"MeterId\",\"InstanceId\",\"ResourceGroup\",\"PreTaxCost\"]},\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/TestExport3\",\"name\":\"TestExport3\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d649f6069c44bb\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-25T20:00:00+00:00\",\"to\":\"2020-06-29T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-costmanagement/providers/Microsoft.Storage/storageAccounts/wyunchistorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"configuration\":{\"columns\":[\"SubscriptionGuid\",\"MeterId\",\"InstanceId\",\"ResourceGroup\",\"PreTaxCost\"]},\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/LucasExport-T02\",\"name\":\"LucasExport-T02\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d649f8ec7b1149\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-25T20:00:00+00:00\",\"to\":\"2020-06-29T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-costmanagement/providers/Microsoft.Storage/storageAccounts/wyunchistorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\",\"aggregation\":{\"costsum\":{\"name\":\"PreTaxCost\",\"function\":\"Sum\"},\"cost\":{\"name\":\"Cost\",\"function\":\"Sum\"}},\"grouping\":[{\"type\":\"Dimension\",\"name\":\"ResourceGroup\"}]}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/LucasExport-T03\",\"name\":\"LucasExport-T03\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d649f918708873\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-25T20:00:00+00:00\",\"to\":\"2020-06-29T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-costmanagement/providers/Microsoft.Storage/storageAccounts/wyunchistorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\",\"aggregation\":{\"costsum\":{\"name\":\"PreTaxCost\",\"function\":\"Sum\"},\"cost\":{\"name\":\"Cost\",\"function\":\"Sum\"}},\"grouping\":[{\"type\":\"Dimension\",\"name\":\"ResourceGroup\"}]}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/LucasExportT06\",\"name\":\"LucasExportT06\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d649f9d2f5df21\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-27T20:00:00+00:00\",\"to\":\"2020-06-28T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-costmanagement/providers/Microsoft.Storage/storageAccounts/wyunchistorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\",\"aggregation\":{\"costsum\":{\"name\":\"PreTaxCost\",\"function\":\"Sum\"},\"cost\":{\"name\":\"Cost\",\"function\":\"Sum\"}},\"grouping\":[{\"type\":\"Dimension\",\"name\":\"ResourceGroup\"}]}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/ps-costext-t01\",\"name\":\"ps-costext-t01\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d649ff52ae2bb7\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-24T00:00:00+00:00\",\"to\":\"2020-06-26T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/azureps-manual-test/providers/Microsoft.Storage/storageAccounts/lucascostmanagement\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\",\"aggregation\":{\"costsum\":{\"name\":\"PreTaxCost\",\"function\":\"Sum\"},\"cost\":{\"name\":\"Cost\",\"function\":\"Sum\"}},\"grouping\":[{\"type\":\"Dimension\",\"name\":\"ResourceGroup\"}]}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/ps-costext-t02\",\"name\":\"ps-costext-t02\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d64d16faa5d7b4\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-28T00:00:00+00:00\",\"to\":\"2020-07-01T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/azureps-manual-test/providers/Microsoft.Storage/storageAccounts/lucascostmanagement\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\",\"aggregation\":{\"costsum\":{\"name\":\"PreTaxCost\",\"function\":\"Sum\"},\"cost\":{\"name\":\"Cost\",\"function\":\"Sum\"}},\"grouping\":[{\"type\":\"Dimension\",\"name\":\"ResourceGroup\"}]}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/ps-costext-t03\",\"name\":\"ps-costext-t03\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d64d1be92e19a4\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-28T07:45:28\",\"to\":\"2020-07-18T07:15:28\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/azureps-manual-test/providers/Microsoft.Storage/storageAccounts/lucascostmanagement\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\",\"aggregation\":{\"cost\":{\"name\":\"Cost\",\"function\":\"Sum\"},\"costsum\":{\"name\":\"PreTaxCost\",\"function\":\"Sum\"}},\"grouping\":[{\"type\":\"Dimension\",\"name\":\"ResourceGroup\"}]}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/exportws5qlv\",\"name\":\"exportws5qlv\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d64d1d1164c9ac\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-28T07:53:46\",\"to\":\"2020-07-18T07:23:46\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-manual-test/providers/Microsoft.Storage/storageAccounts/staaccountmkjhje\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\",\"aggregation\":{\"costsum\":{\"name\":\"PreTaxCost\",\"function\":\"Sum\"},\"cost\":{\"name\":\"Cost\",\"function\":\"Sum\"}},\"grouping\":[{\"type\":\"Dimension\",\"name\":\"ResourceGroup\"}]}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/manual-export-t01\",\"name\":\"manual-export-t01\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d64dd725acbcdf\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-29T20:00:00+00:00\",\"to\":\"2020-07-01T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-manual-test/providers/Microsoft.Storage/storageAccounts/lucasstorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/manual-export-t02\",\"name\":\"manual-export-t02\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d64dd8071bf283\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-29T13:00:00+00:00\",\"to\":\"2020-07-01T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-manual-test/providers/Microsoft.Storage/storageAccounts/lucasstorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/exportinfo-ps-t\",\"name\":\"exportinfo-ps-t\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d64dda275a663c\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-29T13:00:00+00:00\",\"to\":\"2020-07-01T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-manual-test/providers/Microsoft.Storage/storageAccounts/lucasstorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/ps-exportall-t\",\"name\":\"ps-exportall-t\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d64dda37395609\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-29T13:00:00+00:00\",\"to\":\"2020-07-01T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-manual-test/providers/Microsoft.Storage/storageAccounts/lucasstorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/ps-customcolum-t\",\"name\":\"ps-customcolum-t\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d64ddad337a774\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-29T13:00:00+00:00\",\"to\":\"2020-07-01T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-manual-test/providers/Microsoft.Storage/storageAccounts/lucasstorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"configuration\":{\"columns\":[\"SubscriptionGuid\",\"MeterId\",\"InstanceId\",\"ResourceGroup\",\"PreTaxCost\"]},\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/ps-aggregation-t\",\"name\":\"ps-aggregation-t\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d64ddb7d30c57d\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-29T13:00:00+00:00\",\"to\":\"2020-07-01T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-manual-test/providers/Microsoft.Storage/storageAccounts/lucasstorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\",\"aggregation\":{\"cost\":{\"name\":\"Cost\",\"function\":\"Sum\"},\"costsum\":{\"name\":\"PreTaxCost\",\"function\":\"Sum\"}}}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/ps-group-t\",\"name\":\"ps-group-t\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d64ddd2f00c7aa\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-29T13:00:00+00:00\",\"to\":\"2020-07-01T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-manual-test/providers/Microsoft.Storage/storageAccounts/lucasstorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\",\"grouping\":[{\"type\":\"Dimension\",\"name\":\"ResourceGroup\"}]}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/ps-groupaggregation-t\",\"name\":\"ps-groupaggregation-t\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d64dde4850e487\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-06-29T13:00:00+00:00\",\"to\":\"2020-07-01T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-manual-test/providers/Microsoft.Storage/storageAccounts/lucasstorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\",\"aggregation\":{\"cost\":{\"name\":\"Cost\",\"function\":\"Sum\"},\"costsum\":{\"name\":\"PreTaxCost\",\"function\":\"Sum\"}},\"grouping\":[{\"type\":\"Dimension\",\"name\":\"ResourceGroup\"}]}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/TestExport10\",\"name\":\"TestExport10\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d650dd9b8ab46b\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-07-03T20:00:00+00:00\",\"to\":\"2020-07-10T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-costmanagement/providers/Microsoft.Storage/storageAccounts/wyunchistorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/ps-exportall-t02\",\"name\":\"ps-exportall-t02\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d651104357293e\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-07-03T08:00:00+00:00\",\"to\":\"2020-08-01T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-manual-test/providers/Microsoft.Storage/storageAccounts/lucasstorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/ps-exportall-t03\",\"name\":\"ps-exportall-t03\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d65110a073dc56\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-07-03T08:00:00+00:00\",\"to\":\"2020-08-01T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-manual-test/providers/Microsoft.Storage/storageAccounts/lucasstorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-u9yfan\",\"name\":\"export-u9yfan\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d652b1674994fd\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-07-05T07:41:32\",\"to\":\"2020-07-21T07:41:32\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-manual-test/providers/Microsoft.Storage/storageAccounts/staaccountmhot0q\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-u9sfcn\",\"name\":\"export-u9sfcn\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d652b16952d046\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-07-05T07:41:32\",\"to\":\"2020-07-21T07:41:32\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-manual-test/providers/Microsoft.Storage/storageAccounts/staaccountmhot0q\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"configuration\":{\"columns\":[\"SubscriptionGuid\",\"MeterId\",\"InstanceId\",\"ResourceGroup\",\"PreTaxCost\"]},\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-cf6scg\",\"name\":\"export-cf6scg\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d652b16a169690\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-07-05T07:41:32\",\"to\":\"2020-07-21T07:41:32\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-manual-test/providers/Microsoft.Storage/storageAccounts/staaccountmhot0q\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\",\"grouping\":[{\"type\":\"Dimension\",\"name\":\"ResourceGroup\"}]}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-38we0i\",\"name\":\"export-38we0i\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d65375a9692caf\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-07-06T09:13:02\",\"to\":\"2020-07-26T09:13:02\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-5rij6b/providers/Microsoft.Storage/storageAccounts/staaccountjshubiu\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-r6xjol\",\"name\":\"export-r6xjol\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d65377005b37c6\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-07-06T09:13:02\",\"to\":\"2020-07-26T09:13:02\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-5rij6b/providers/Microsoft.Storage/storageAccounts/staaccountjshubiu\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-gq1kft\",\"name\":\"export-gq1kft\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d6537703972b88\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-07-06T09:13:02\",\"to\":\"2020-07-26T09:13:02\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-5rij6b/providers/Microsoft.Storage/storageAccounts/staaccountjshubiu\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\",\"grouping\":[{\"type\":\"Dimension\",\"name\":\"ResourceGroup\"}]}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-j8s5of\",\"name\":\"export-j8s5of\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d65377046dbf7c\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-07-06T09:13:02\",\"to\":\"2020-07-26T09:13:02\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-5rij6b/providers/Microsoft.Storage/storageAccounts/staaccountjshubiu\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\",\"aggregation\":{\"costsum\":{\"name\":\"PreTaxCost\",\"function\":\"Sum\"},\"cost\":{\"name\":\"Cost\",\"function\":\"Sum\"}},\"grouping\":[{\"type\":\"Dimension\",\"name\":\"ResourceGroup\"}]}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/TestExportDatasetAggregation123\",\"name\":\"TestExportDatasetAggregation123\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d6b19fb5559127\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-11-03T20:00:00+00:00\",\"to\":\"2020-11-10T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-costmanagement/providers/Microsoft.Storage/storageAccounts/wyunchistorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/TestExportDatasetAggregationInfoyouri\",\"name\":\"TestExportDatasetAggregationInfoyouri\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d6b33c18099a67\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-11-05T20:00:00+00:00\",\"to\":\"2020-11-10T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-costmanagement/providers/Microsoft.Storage/storageAccounts/wyunchistorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"configuration\":{\"columns\":[\"SubscriptionGuid\",\"MeterId\",\"InstanceId\",\"ResourceGroup\",\"PreTaxCost\"]},\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/TestUpdate1\",\"name\":\"TestUpdate1\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d6b6451f8f6d83\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-11-09T20:00:00+00:00\",\"to\":\"2020-11-20T00:00:00+00:00\"}},\"nextRunTimeEstimate\":\"2020-11-18T19:35:32.9300902Z\",\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-costmanagement/providers/Microsoft.Storage/storageAccounts/wyunchistorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/TestExportDatasetAggregationInfoYouri\",\"name\":\"TestExportDatasetAggregationInfoYouri\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d6b738f9459e9e\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-11-13T20:00:00Z\",\"to\":\"2020-11-17T00:00:00Z\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-costmanagement/providers/Microsoft.Storage/storageAccounts/wyunchistorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"adhoctest\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/TestExportDatasetAggregationYouriTest\",\"name\":\"TestExportDatasetAggregationYouriTest\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d6b7120d0af53a\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Daily\",\"recurrencePeriod\":{\"from\":\"2020-11-10T20:00:00+00:00\",\"to\":\"2020-11-15T00:00:00+00:00\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-costmanagement/providers/Microsoft.Storage/storageAccounts/wyunchistorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"adhoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/TestExportDatasetAggregationInfo1118\",\"name\":\"TestExportDatasetAggregationInfo1118\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d6bd716961a536\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Weekly\",\"recurrencePeriod\":{\"from\":\"2020-11-18T20:00:00Z\",\"to\":\"2020-11-20T00:00:00Z\"}},\"nextRunTimeEstimate\":\"2020-11-18T20:00:00Z\",\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/youri-costmanagement/providers/Microsoft.Storage/storageAccounts/youristorageaccount\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}},{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-oenfxg\",\"name\":\"export-oenfxg\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d6bd7c8581cbbf\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Weekly\",\"recurrencePeriod\":{\"from\":\"2020-11-18T15:18:13\",\"to\":\"2020-12-08T14:33:13\"}},\"nextRunTimeEstimate\":\"2020-11-18T19:35:32.9300902Z\",\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-gali06/providers/Microsoft.Storage/storageAccounts/staaccountjshubiu\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}}]}" + } + } +} \ No newline at end of file diff --git a/src/CostManagement/test/Remove-AzCostManagementExport.Tests.ps1 b/src/CostManagement/test/Remove-AzCostManagementExport.Tests.ps1 new file mode 100644 index 000000000000..ba82788c08a2 --- /dev/null +++ b/src/CostManagement/test/Remove-AzCostManagementExport.Tests.ps1 @@ -0,0 +1,27 @@ +$loadEnvPath = Join-Path $PSScriptRoot 'loadEnv.ps1' +if (-Not (Test-Path -Path $loadEnvPath)) { + $loadEnvPath = Join-Path $PSScriptRoot '..\loadEnv.ps1' +} +. ($loadEnvPath) +$TestRecordingFile = Join-Path $PSScriptRoot 'Remove-AzCostManagementExport.Recording.json' +$currentPath = $PSScriptRoot +while(-not $mockingPath) { + $mockingPath = Get-ChildItem -Path $currentPath -Recurse -Include 'HttpPipelineMocking.ps1' -File + $currentPath = Split-Path -Path $currentPath -Parent +} +. ($mockingPath | Select-Object -First 1).FullName + +Describe 'Remove-AzCostManagementExport' { + It 'Delete' { + Remove-AzCostManagementExport -Scope "subscriptions/$($env.SubscriptionId)" -Name $env.exportName04 + $exportList = Get-AzCostManagementExport -Scope "subscriptions/$($env.SubscriptionId)" + $exportList.Name| Should -Not -Contain $env.exportName04 + } + + It 'DeleteViaIdentity' { + $export = Get-AzCostManagementExport -Scope "subscriptions/$($env.SubscriptionId)/resourceGroups/$($env.resourceGroup)" -Name $env.exportName03 + Remove-AzCostManagementExport -InputObject $export + $exportList = Get-AzCostManagementExport -Scope "subscriptions/$($env.SubscriptionId)" + $exportList.Name| Should -Not -Contain $env.exportName03 + } +} diff --git a/src/CostManagement/test/Update-AzCostManagementExport.Recording.json b/src/CostManagement/test/Update-AzCostManagementExport.Recording.json new file mode 100644 index 000000000000..6a9283b3031f --- /dev/null +++ b/src/CostManagement/test/Update-AzCostManagementExport.Recording.json @@ -0,0 +1,118 @@ +{ + "Update-AzCostManagementExport+[NoContext]+UpdateExpanded+$PUT+https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-oenfxg?api-version=2020-06-01+1": { + "Request": { + "Method": "PUT", + "RequestUri": "https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-oenfxg?api-version=2020-06-01", + "Content": "{\r\n \"eTag\": \"\\\"1d6bd7c6fb60904\\\"\",\r\n \"properties\": {\r\n \"definition\": {\r\n \"dataSet\": {\r\n \"granularity\": \"Daily\"\r\n },\r\n \"type\": \"Usage\",\r\n \"timeframe\": \"MonthToDate\"\r\n },\r\n \"deliveryInfo\": {\r\n \"destination\": {\r\n \"container\": \"exports\",\r\n \"resourceId\": \"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-gali06/providers/Microsoft.Storage/storageAccounts/staaccountjshubiu\",\r\n \"rootFolderPath\": \"ad-hoc\"\r\n }\r\n },\r\n \"format\": \"Csv\",\r\n \"schedule\": {\r\n \"recurrencePeriod\": {\r\n \"from\": \"2020-11-18T15:18:13.0000000\",\r\n \"to\": \"2020-12-08T14:33:13.0000000\"\r\n },\r\n \"recurrence\": \"Weekly\",\r\n \"status\": \"Active\"\r\n }\r\n }\r\n}", + "Headers": { + }, + "ContentHeaders": { + "Content-Type": [ "application/json" ], + "Content-Length": [ "761" ] + } + }, + "Response": { + "StatusCode": 200, + "Headers": { + "Cache-Control": [ "no-cache" ], + "Pragma": [ "no-cache" ], + "Vary": [ "Accept-Encoding" ], + "session-id": [ "116036c7-5f25-4e8e-98ac-3ba7e661fdc4" ], + "x-ms-request-id": [ "a5913571-3cb3-46f3-a505-cf72a401720b" ], + "x-ms-correlation-request-id": [ "163c4040-64b6-475d-9caf-48f600889e60" ], + "x-ms-client-request-id": [ "d2d4120a-6b1d-4266-819b-7c1dc1c025dd" ], + "X-Powered-By": [ "ASP.NET" ], + "x-ms-ratelimit-remaining-subscription-reads": [ "11991" ], + "x-ms-routing-request-id": [ "SOUTHEASTASIA:20201118T072914Z:163c4040-64b6-475d-9caf-48f600889e60" ], + "Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" ], + "X-Content-Type-Options": [ "nosniff" ], + "Date": [ "Wed, 18 Nov 2020 07:29:14 GMT" ] + }, + "ContentHeaders": { + "Content-Length": [ "710" ], + "Content-Type": [ "application/json; charset=utf-8" ], + "Expires": [ "-1" ] + }, + "Content": "{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-oenfxg\",\"name\":\"export-oenfxg\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d6bd7c83a38ed5\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Weekly\",\"recurrencePeriod\":{\"from\":\"2020-11-18T15:18:13\",\"to\":\"2020-12-08T14:33:13\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-gali06/providers/Microsoft.Storage/storageAccounts/staaccountjshubiu\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}}" + } + }, + "Update-AzCostManagementExport+[NoContext]+UpdateViaIdentityExpanded+$GET+https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-oenfxg?api-version=2020-06-01+1": { + "Request": { + "Method": "GET", + "RequestUri": "https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-oenfxg?api-version=2020-06-01", + "Content": null, + "Headers": { + "x-ms-unique-id": [ "3" ], + "x-ms-client-request-id": [ "0443d1b0-ce55-4ad5-9dd9-50f92cfe3abf" ], + "CommandName": [ "Get-AzCostManagementExport" ], + "FullCommandName": [ "Get-AzCostManagementExport_Get" ], + "ParameterSetName": [ "__AllParameterSets" ], + "User-Agent": [ "AzurePowershell/Az4.0.0-preview" ], + "Authorization": [ "[Filtered]" ] + }, + "ContentHeaders": { + } + }, + "Response": { + "StatusCode": 200, + "Headers": { + "Cache-Control": [ "no-cache" ], + "Pragma": [ "no-cache" ], + "Vary": [ "Accept-Encoding" ], + "session-id": [ "761b8792-51a0-44aa-95a9-a79a1a0173c8" ], + "x-ms-request-id": [ "94adf3d4-cda2-47d6-ab6d-30c068dde8c3" ], + "x-ms-correlation-request-id": [ "3ac7c6e2-d839-4eff-9913-13c7dd8698ee" ], + "x-ms-client-request-id": [ "0443d1b0-ce55-4ad5-9dd9-50f92cfe3abf" ], + "X-Powered-By": [ "ASP.NET" ], + "x-ms-ratelimit-remaining-subscription-reads": [ "11990" ], + "x-ms-routing-request-id": [ "SOUTHEASTASIA:20201118T072915Z:3ac7c6e2-d839-4eff-9913-13c7dd8698ee" ], + "Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" ], + "X-Content-Type-Options": [ "nosniff" ], + "Date": [ "Wed, 18 Nov 2020 07:29:14 GMT" ] + }, + "ContentHeaders": { + "Content-Length": [ "763" ], + "Content-Type": [ "application/json; charset=utf-8" ], + "Expires": [ "-1" ] + }, + "Content": "{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-oenfxg\",\"name\":\"export-oenfxg\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d6bd7c83a38ed5\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Weekly\",\"recurrencePeriod\":{\"from\":\"2020-11-18T15:18:13\",\"to\":\"2020-12-08T14:33:13\"}},\"nextRunTimeEstimate\":\"2020-11-18T19:29:15.0750135Z\",\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-gali06/providers/Microsoft.Storage/storageAccounts/staaccountjshubiu\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}}" + } + }, + "Update-AzCostManagementExport+[NoContext]+UpdateViaIdentityExpanded+$PUT+https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-oenfxg?api-version=2020-06-01+2": { + "Request": { + "Method": "PUT", + "RequestUri": "https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-oenfxg?api-version=2020-06-01", + "Content": "{\r\n \"eTag\": \"\\\"1d6bd7c83a38ed5\\\"\",\r\n \"properties\": {\r\n \"definition\": {\r\n \"dataSet\": {\r\n \"granularity\": \"Daily\"\r\n },\r\n \"type\": \"Usage\",\r\n \"timeframe\": \"MonthToDate\"\r\n },\r\n \"deliveryInfo\": {\r\n \"destination\": {\r\n \"container\": \"exports\",\r\n \"resourceId\": \"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-gali06/providers/Microsoft.Storage/storageAccounts/staaccountjshubiu\",\r\n \"rootFolderPath\": \"ad-hoc\"\r\n }\r\n },\r\n \"format\": \"Csv\",\r\n \"schedule\": {\r\n \"recurrencePeriod\": {\r\n \"from\": \"2020-11-18T15:18:13.0000000\",\r\n \"to\": \"2020-12-08T14:33:13.0000000\"\r\n },\r\n \"recurrence\": \"Weekly\",\r\n \"status\": \"Active\"\r\n }\r\n }\r\n}", + "Headers": { + }, + "ContentHeaders": { + "Content-Type": [ "application/json" ], + "Content-Length": [ "761" ] + } + }, + "Response": { + "StatusCode": 200, + "Headers": { + "Cache-Control": [ "no-cache" ], + "Pragma": [ "no-cache" ], + "Vary": [ "Accept-Encoding" ], + "session-id": [ "85a03a0d-e76d-403a-b051-36de6304db05" ], + "x-ms-request-id": [ "ecf0b256-3026-49ce-80f4-3a955e62465a" ], + "x-ms-correlation-request-id": [ "cefe2cf0-cc0e-40d8-bc11-138b5bd10a1a" ], + "x-ms-client-request-id": [ "1bcc7462-a6cf-407a-a6d6-65cb3c0020bf" ], + "X-Powered-By": [ "ASP.NET" ], + "x-ms-ratelimit-remaining-subscription-reads": [ "11988" ], + "x-ms-routing-request-id": [ "SOUTHEASTASIA:20201118T072917Z:cefe2cf0-cc0e-40d8-bc11-138b5bd10a1a" ], + "Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" ], + "X-Content-Type-Options": [ "nosniff" ], + "Date": [ "Wed, 18 Nov 2020 07:29:17 GMT" ] + }, + "ContentHeaders": { + "Content-Length": [ "710" ], + "Content-Type": [ "application/json; charset=utf-8" ], + "Expires": [ "-1" ] + }, + "Content": "{\"id\":\"subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.CostManagement/exports/export-oenfxg\",\"name\":\"export-oenfxg\",\"type\":\"Microsoft.CostManagement/exports\",\"eTag\":\"\\\"1d6bd7c8581cbbf\\\"\",\"properties\":{\"schedule\":{\"status\":\"Active\",\"recurrence\":\"Weekly\",\"recurrencePeriod\":{\"from\":\"2020-11-18T15:18:13\",\"to\":\"2020-12-08T14:33:13\"}},\"format\":\"Csv\",\"deliveryInfo\":{\"destination\":{\"resourceId\":\"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-gali06/providers/Microsoft.Storage/storageAccounts/staaccountjshubiu\",\"container\":\"exports\",\"rootFolderPath\":\"ad-hoc\"}},\"definition\":{\"type\":\"Usage\",\"timeframe\":\"MonthToDate\",\"dataSet\":{\"granularity\":\"Daily\"}}}}" + } + } +} \ No newline at end of file diff --git a/src/CostManagement/test/Update-AzCostManagementExport.Tests.ps1 b/src/CostManagement/test/Update-AzCostManagementExport.Tests.ps1 new file mode 100644 index 000000000000..22a037e9d0f3 --- /dev/null +++ b/src/CostManagement/test/Update-AzCostManagementExport.Tests.ps1 @@ -0,0 +1,25 @@ +$loadEnvPath = Join-Path $PSScriptRoot 'loadEnv.ps1' +if (-Not (Test-Path -Path $loadEnvPath)) { + $loadEnvPath = Join-Path $PSScriptRoot '..\loadEnv.ps1' +} +. ($loadEnvPath) +$TestRecordingFile = Join-Path $PSScriptRoot 'Update-AzCostManagementExport.Recording.json' +$currentPath = $PSScriptRoot +while(-not $mockingPath) { + $mockingPath = Get-ChildItem -Path $currentPath -Recurse -Include 'HttpPipelineMocking.ps1' -File + $currentPath = Split-Path -Path $currentPath -Parent +} +. ($mockingPath | Select-Object -First 1).FullName + +Describe 'Update-AzCostManagementExport' { + It 'UpdateExpanded' { + $export = Update-AzCostManagementExport -Scope "subscriptions/$($env.SubscriptionId)" -Name $env.exportName01 -ScheduleRecurrence 'Weekly' + $export.property.ScheduleRecurrence | Should -Be 'Weekly' + } + + It 'UpdateViaIdentityExpanded' { + $oldExport = Get-AzCostManagementExport -Scope "subscriptions/$($env.SubscriptionId)" -Name $env.exportName01 + $export = Update-AzCostManagementExport -InputObject $oldExport -ScheduleRecurrence 'Weekly' + $export.property.ScheduleRecurrence | Should -Be 'Weekly' + } +} diff --git a/src/CostManagement/test/deployment-templates/storage-account/parameters.json b/src/CostManagement/test/deployment-templates/storage-account/parameters.json new file mode 100644 index 000000000000..005b17d22f35 --- /dev/null +++ b/src/CostManagement/test/deployment-templates/storage-account/parameters.json @@ -0,0 +1,7 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "storageAccounts_name": null + } +} diff --git a/src/CostManagement/test/deployment-templates/storage-account/template.json b/src/CostManagement/test/deployment-templates/storage-account/template.json new file mode 100644 index 000000000000..1ce0851a5d9e --- /dev/null +++ b/src/CostManagement/test/deployment-templates/storage-account/template.json @@ -0,0 +1,96 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "storageAccounts_name": { + "defaultValue": "staaccountjshubiu", + "type": "String" + } + }, + "variables": {}, + "resources": [ + { + "type": "Microsoft.Storage/storageAccounts", + "apiVersion": "2019-06-01", + "name": "[parameters('storageAccounts_name')]", + "location": "eastus", + "sku": { + "name": "Standard_RAGRS", + "tier": "Standard" + }, + "kind": "StorageV2", + "properties": { + "networkAcls": { + "bypass": "AzureServices", + "virtualNetworkRules": [], + "ipRules": [], + "defaultAction": "Allow" + }, + "supportsHttpsTrafficOnly": true, + "encryption": { + "services": { + "file": { + "keyType": "Account", + "enabled": true + }, + "blob": { + "keyType": "Account", + "enabled": true + } + }, + "keySource": "Microsoft.Storage" + }, + "accessTier": "Hot" + } + }, + { + "type": "Microsoft.Storage/storageAccounts/blobServices", + "apiVersion": "2019-06-01", + "name": "[concat(parameters('storageAccounts_name'), '/default')]", + "dependsOn": [ + "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccounts_name'))]" + ], + "sku": { + "name": "Standard_RAGRS", + "tier": "Standard" + }, + "properties": { + "cors": { + "corsRules": [] + }, + "deleteRetentionPolicy": { + "enabled": false + } + } + }, + { + "type": "Microsoft.Storage/storageAccounts/fileServices", + "apiVersion": "2019-06-01", + "name": "[concat(parameters('storageAccounts_name'), '/default')]", + "dependsOn": [ + "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccounts_name'))]" + ], + "sku": { + "name": "Standard_RAGRS", + "tier": "Standard" + }, + "properties": { + "cors": { + "corsRules": [] + } + } + }, + { + "type": "Microsoft.Storage/storageAccounts/blobServices/containers", + "apiVersion": "2019-06-01", + "name": "[concat(parameters('storageAccounts_name'), '/default/exports')]", + "dependsOn": [ + "[resourceId('Microsoft.Storage/storageAccounts/blobServices', parameters('storageAccounts_name'), 'default')]", + "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccounts_name'))]" + ], + "properties": { + "publicAccess": "None" + } + } + ] +} \ No newline at end of file diff --git a/src/CostManagement/test/env.json b/src/CostManagement/test/env.json new file mode 100644 index 000000000000..d1f91363faa7 --- /dev/null +++ b/src/CostManagement/test/env.json @@ -0,0 +1,13 @@ +{ + "exportName03": "export-d9y6fx", + "storageAccountId": "/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/costmanagement-rg-gali06/providers/Microsoft.Storage/storageAccounts/staaccountjshubiu", + "Tenant": "72f988bf-86f1-41af-91ab-2d7cd011db47", + "exportName04": "export-9pcvod", + "fromDate": "2020/11/18 14:33:13", + "resourceGroup": "costmanagement-rg-gali06", + "toDate": "2020/12/8 14:33:13", + "SubscriptionId": "9e223dbe-3399-4e19-88eb-0975f02ac87f", + "exportName02": "export-x9d0hl", + "location": "eastus", + "exportName01": "export-oenfxg" +} diff --git a/src/CostManagement/test/loadEnv.ps1 b/src/CostManagement/test/loadEnv.ps1 new file mode 100644 index 000000000000..c4ebf2e8310c --- /dev/null +++ b/src/CostManagement/test/loadEnv.ps1 @@ -0,0 +1,28 @@ +# ---------------------------------------------------------------------------------- +# +# Copyright Microsoft Corporation +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ---------------------------------------------------------------------------------- +$envFile = 'env.json' +if ($TestMode -eq 'live') { + $envFile = 'localEnv.json' +} + +if (Test-Path -Path (Join-Path $PSScriptRoot $envFile)) { + $envFilePath = Join-Path $PSScriptRoot $envFile +} else { + $envFilePath = Join-Path $PSScriptRoot '..\$envFile' +} +$env = @{} +if (Test-Path -Path $envFilePath) { + $env = Get-Content (Join-Path $PSScriptRoot $envFile) | ConvertFrom-Json + $PSDefaultParameterValues=@{"*:SubscriptionId"=$env.SubscriptionId; "*:Tenant"=$env.Tenant} +} \ No newline at end of file diff --git a/src/CostManagement/test/readme.md b/src/CostManagement/test/readme.md new file mode 100644 index 000000000000..7c752b4c8c43 --- /dev/null +++ b/src/CostManagement/test/readme.md @@ -0,0 +1,17 @@ +# Test +This directory contains the [Pester](https://www.powershellgallery.com/packages/Pester) tests to run for the module. We use Pester as it is the unofficial standard for PowerShell unit testing. Test stubs for custom cmdlets (created in `..\custom`) will be generated into this folder when `build-module.ps1` is ran. These test stubs will fail automatically, to indicate that tests should be written for custom cmdlets. + +## Info +- Modifiable: yes +- Generated: partial +- Committed: yes +- Packaged: no + +## Details +We allow three testing modes: *live*, *record*, and *playback*. These can be selected using the `-Live`, `-Record`, and `-Playback` switches respectively on the `test-module.ps1` script. This script will run through any `.Tests.ps1` scripts in the `test` folder. If you choose the *record* mode, it will create a `.Recording.json` file of the REST calls between the client and server. Then, when you choose *playback* mode, it will use the `.Recording.json` file to mock the communication between server and client. The *live* mode runs the same as the *record* mode; however, it doesn't create the `.Recording.json` file. + +## Purpose +Custom cmdlets generally encompass additional functionality not described in the REST specification, or combines functionality generated from the REST spec. To validate this functionality continues to operate as intended, creating tests that can be ran and re-ran against custom cmdlets is part of the framework. + +## Usage +To execute tests, run the `test-module.ps1`. To write tests, [this example](https://github.com/pester/Pester/blob/8b9cf4248315e44f1ac6673be149f7e0d7f10466/Examples/Planets/Get-Planet.Tests.ps1#L1) from the Pester repository is very useful for getting started. \ No newline at end of file diff --git a/src/CostManagement/test/test-script.ps1 b/src/CostManagement/test/test-script.ps1 new file mode 100644 index 000000000000..21a919b92419 --- /dev/null +++ b/src/CostManagement/test/test-script.ps1 @@ -0,0 +1,91 @@ +<# +New-AzCostManagementExport -Debug -Scope "subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f" -Name "LucasTestExport" ` +-ScheduleStatus "Active" -ScheduleRecurrence "Daily" ` +-RecurrencePeriodFrom "2020-06-20T20:00:00Z" ` +-RecurrencePeriodTo "2020-06-24T00:00:00Z" ` +-Format "Csv" ` +-DestinationResourceId "/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-costmanagement/providers/Microsoft.Storage/storageAccounts/wyunchistorageaccount" ` +-DestinationContainer "exports" -DestinationRootFolderPath "ad-hoc" ` +-DefinitionType "Usage" -DefinitionTimeframe "MonthToDate" -DatasetGranularity "Daily" ` +#-ConfigurationColumn @('SubscriptionGuid', 'MeterId', 'InstanceId', 'ResourceGroup', 'PreTaxCost') +-DatasetAggregation $AggregationDict ` +-DatasetGrouping @(@{type='Dimension'; name='SubscriptionName'}; @{type='Tag'; name='Environment'}) ` +#-DatasetFilter $fileter +#> + +<# export all info pass +New-AzCostManagementExport -Debug -Scope "subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f" -Name "ps-exportall-t" ` +-ScheduleStatus "Active" -ScheduleRecurrence "Daily" -RecurrencePeriodFrom "2020-06-29T13:00:00Z" ` +-RecurrencePeriodTo "2020-07-01T00:00:00Z" -Format "Csv" ` +-DestinationResourceId "/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-manual-test/providers/Microsoft.Storage/storageAccounts/lucasstorageaccount" ` +-DestinationContainer "exports" -DestinationRootFolderPath "ad-hoc" -DefinitionType "Usage" -DefinitionTimeframe "MonthToDate" ` +-DatasetGranularity "Daily" +#> + +<# custom colum pass +New-AzCostManagementExport -Debug -Scope "subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f" -Name "ps-customcolum-t" ` +-ScheduleStatus "Active" -ScheduleRecurrence "Daily" -RecurrencePeriodFrom "2020-06-29T13:00:00Z" ` +-RecurrencePeriodTo "2020-07-01T00:00:00Z" -Format "Csv" ` +-DestinationResourceId "/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-manual-test/providers/Microsoft.Storage/storageAccounts/lucasstorageaccount" ` +-DestinationContainer "exports" -DestinationRootFolderPath "ad-hoc" -DefinitionType "Usage" -DefinitionTimeframe "MonthToDate" ` +-DatasetGranularity "Daily" ` +-ConfigurationColumn @('SubscriptionGuid', 'MeterId', 'InstanceId', 'ResourceGroup', 'PreTaxCost') +#> + +<# Aggregation: The data not generate in the storage account +$Aggregation1 = @{ name = 'PreTaxCost'; function='sum'} +$Aggregation2 = @{ name = 'Cost'; function='sum'} +$AggregationDict = @{costsum=$aggregation1; cost=$aggregation2} + +New-AzCostManagementExport -Debug -Scope "subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f" -Name "ps-aggregation-t" ` +-ScheduleStatus "Active" -ScheduleRecurrence "Daily" -RecurrencePeriodFrom "2020-06-29T13:00:00Z" ` +-RecurrencePeriodTo "2020-07-01T00:00:00Z" -Format "Csv" ` +-DestinationResourceId "/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-manual-test/providers/Microsoft.Storage/storageAccounts/lucasstorageaccount" ` +-DestinationContainer "exports" -DestinationRootFolderPath "ad-hoc" -DefinitionType "Usage" -DefinitionTimeframe "MonthToDate" ` +-DatasetGranularity "Daily" ` +-DatasetAggregation $AggregationDict +#> + +<#Group pass +New-AzCostManagementExport -Debug -Scope "subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f" -Name "ps-group-t" ` +-ScheduleStatus "Active" -ScheduleRecurrence "Daily" -RecurrencePeriodFrom "2020-06-29T15:00:00Z" ` +-RecurrencePeriodTo "2020-07-01T00:00:00Z" -Format "Csv" ` +-DestinationResourceId "/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-manual-test/providers/Microsoft.Storage/storageAccounts/lucasstorageaccount" ` +-DestinationContainer "exports" -DestinationRootFolderPath "ad-hoc" -DefinitionType "Usage" -DefinitionTimeframe "MonthToDate" ` +-DatasetGranularity "Daily" ` +-DatasetGrouping @(@{type='Dimension'; name='ResourceGroup'}) + #> + +<#Group Aggregation: No data generated in the storage account +$Aggregation1 = @{ name = 'PreTaxCost'; function='sum'} +$Aggregation2 = @{ name = 'Cost'; function='sum'} +$AggregationDict = @{costsum=$aggregation1; cost=$aggregation2} + +New-AzCostManagementExport -Debug -Scope "subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f" -Name "ps-groupaggregation-t" ` +-ScheduleStatus "Active" -ScheduleRecurrence "Daily" -RecurrencePeriodFrom "2020-06-29T13:00:00Z" ` +-RecurrencePeriodTo "2020-07-01T00:00:00Z" -Format "Csv" ` +-DestinationResourceId "/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-manual-test/providers/Microsoft.Storage/storageAccounts/lucasstorageaccount" ` +-DestinationContainer "exports" -DestinationRootFolderPath "ad-hoc" -DefinitionType "Usage" -DefinitionTimeframe "MonthToDate" ` +-DatasetGranularity "Daily" ` +-DatasetGrouping @(@{type='Dimension'; name='ResourceGroup'}) ` +-DatasetAggregation $AggregationDict +#> +<# +$orDimension = New-AzCostManagementQueryComparisonExpressionObject -Name 'ResourceLocation' -Operator In -Value @('East US', 'West Europe') +$queryOrDimension = New-AzCostManagementQueryFilterObject -Dimension $orDimension +$orTag = New-AzCostManagementQueryComparisonExpressionObject -Name 'Environment' -Operator In -Value @('UAT', 'Prod') +$queryOrTag = New-AzCostManagementQueryFilterObject -Tag $orTag +$andOr = New-AzCostManagementQueryFilterObject -or @((New-AzCostManagementQueryFilterObject -Dimension $orDimension), (New-AzCostManagementQueryFilterObject -Tag $orTag)) + +$dimension = New-AzCostManagementQueryComparisonExpressionObject -Name 'ResourceGroup' -Operator In -Value 'API' +$andDimension = New-AzCostManagementQueryFilterObject -Dimension $dimension +$fileter = New-AzCostManagementQueryFilterObject -And @($andOr, $andDimension) +#> +New-AzCostManagementExport -Debug -Scope "subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f" -Name "ps-filter-t01" ` +-ScheduleStatus "Active" -ScheduleRecurrence "Daily" -RecurrencePeriodFrom "2020-07-05T00:00:00Z" ` +-RecurrencePeriodTo "2020-07-30T00:00:00Z" -Format "Csv" ` +-DestinationResourceId "/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-manual-test/providers/Microsoft.Storage/storageAccounts/lucasstorageaccount" ` +-DestinationContainer "exports" -DestinationRootFolderPath "ad-hoc" -DefinitionType "Usage" -DefinitionTimeframe "MonthToDate" ` +-DatasetGranularity "Daily" ` +-DatasetFilter $fileter + diff --git a/src/CostManagement/test/utils.ps1 b/src/CostManagement/test/utils.ps1 new file mode 100644 index 000000000000..9af824ea60d7 --- /dev/null +++ b/src/CostManagement/test/utils.ps1 @@ -0,0 +1,86 @@ +function RandomString([bool]$allChars, [int32]$len) { + if ($allChars) { + return -join ((33..126) | Get-Random -Count $len | % {[char]$_}) + } else { + return -join ((48..57) + (97..122) | Get-Random -Count $len | % {[char]$_}) + } +} +function getUseModules() { + $usedModule = & 'gmo' + foreach($module in $usedModule) + { + $name = $module.Name + $version = $module.Version + Write-Host -ForegroundColor Green "Using module name: $name $version" + } +} +$env = @{} +function setupEnv() { + # Preload subscriptionId and tenant from context, which will be used in test + # as default. You could change them if needed. + $env.SubscriptionId = (Get-AzContext).Subscription.Id + $env.Tenant = (Get-AzContext).Tenant.Id + $env.location = 'eastus' + # For any resources you created for test, you should add it to $env here. + $exportName01 = 'export-' + (RandomString -allChars $false -len 6) + $exportName02 = 'export-' + (RandomString -allChars $false -len 6) + $exportName03 = 'export-' + (RandomString -allChars $false -len 6) + $exportName04 = 'export-' + (RandomString -allChars $false -len 6) + + $null = $env.Add('exportName01', $exportName01) + $null = $env.Add('exportName02', $exportName02) + $null = $env.Add('exportName03', $exportName03) + $null = $env.Add('exportName04', $exportName04) + + Write-Host -ForegroundColor Green "Create test group..." + $resourceGroup = 'costmanagement-rg-' + (RandomString -allChars $false -len 6) + Write-Host $resourceGroup + New-AzResourceGroup -Name $resourceGroup -Location $env.location + $null = $env.Add('resourceGroup', $resourceGroup) + Write-Host -ForegroundColor Green 'The test group create completed.' + + # Deploy storage account for test. + Write-Host -ForegroundColor Green "Deploying storage account..." + <# Cause error: The request content was invalid and could not be deserialized: 'Error converting value "staaccountuigcan" to type + 'Microsoft.WindowsAzure.ResourceStack.Frontdoor.Data.Definitions.DeploymentParameterDefinition'. Path + 'properties.parameters.storageAccounts_wyunchistorageaccount_name', line 5, position 70.'. + + $staaccountName = 'staaccount' + (RandomString -allChars $false -len 6) + $staaccountParam = Get-Content .\test\deployment-templates\storage-account\parameters.json | ConvertFrom-Json + $staaccountParam.parameters.storageAccounts_name = $staaccountName + set-content -Path .\test\deployment-templates\storage-account\parameters.json -Value (ConvertTo-Json $staaccountParam) + #> + New-AzDeployment -Mode Incremental -TemplateFile .\test\deployment-templates\storage-account\template.json -TemplateParameterFile .\test\deployment-templates\storage-account\parameters.json -ResourceGroupName $env.resourceGroup + $staaccountName = 'staaccountjshubiu' # Value in template.json + $env.storageAccountId = "/subscriptions/$($env.SubscriptionId)/resourceGroups/$($env.resourceGroup)/providers/Microsoft.Storage/storageAccounts/$($staaccountName)" + Start-Sleep -s 60 # Waiting storage account create complete. + Write-Host -ForegroundColor Green "The storage account deployed successfully." + + Write-Host -ForegroundColor Green "Create cost management export for test..." + $env.fromDate = (Get-Date).ToString() + $env.toDate = (Get-Date).AddDays(20).ToString() + #Create One CostManagementExport + New-AzCostManagementExport -Scope "subscriptions/$($env.SubscriptionId)" -Name $env.exportName01 ` + -ScheduleStatus "Active" -ScheduleRecurrence "Daily" ` + -RecurrencePeriodFrom $env.fromDate -RecurrencePeriodTo $env.toDate ` + -Format "Csv" ` + -DestinationResourceId $env.storageAccountId ` + -DestinationContainer "exports" -DestinationRootFolderPath "ad-hoc" -DefinitionType "Usage" ` + -DefinitionTimeframe "MonthToDate" -DatasetGranularity "Daily" + + # Invoke-AzCostManagementExecuteExport -Scope "subscriptions/$($env.SubscriptionId)" -ExportName $env.exportName01 + + Write-Host -ForegroundColor Green "The cost management export created successfully." + + $envFile = 'env.json' + if ($TestMode -eq 'live') { + $envFile = 'localEnv.json' + } + set-content -Path (Join-Path $PSScriptRoot $envFile) -Value (ConvertTo-Json $env) + +} +function cleanupEnv() { + # Clean resources you create for testing + Remove-AzResourceGroup -Name $env.resourceGroup +} + diff --git a/tools/CreateMappings_rules.json b/tools/CreateMappings_rules.json index 2d37a04cda0b..0da81a32d80a 100644 --- a/tools/CreateMappings_rules.json +++ b/tools/CreateMappings_rules.json @@ -604,5 +604,9 @@ { "alias": "WindowsIotServices", "regex": "WindowsIotServices" + }, + { + "regex": "CostManagement", + "alias": "CostManagement" } -] \ No newline at end of file +] diff --git a/tools/GeneratedModuleList.txt b/tools/GeneratedModuleList.txt index 9ead0eeae29d..1fc355318002 100644 --- a/tools/GeneratedModuleList.txt +++ b/tools/GeneratedModuleList.txt @@ -1,6 +1,7 @@ Az.AppConfiguration Az.Blockchain Az.ConnectedKubernetes +Az.CostManagement Az.CustomProviders Az.Databricks Az.DesktopVirtualization From d14cc017ee0ae58af0ef84392c74ff3d73dea909 Mon Sep 17 00:00:00 2001 From: wyunchi-ms Date: Wed, 2 Dec 2020 23:52:44 +0800 Subject: [PATCH 2/4] Init for CostManagement --- src/CostManagement/Changelog.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/CostManagement/Changelog.md b/src/CostManagement/Changelog.md index a8a29db2e3de..0d05b23c2c38 100644 --- a/src/CostManagement/Changelog.md +++ b/src/CostManagement/Changelog.md @@ -18,7 +18,5 @@ - Additional information about change #1 --> ## Upcoming Release - -## Version 0.1.0 * First preview release for module Az.CostManagement From bb12551eb52b06aab505ccb71701670b16cb317b Mon Sep 17 00:00:00 2001 From: wyunchi-ms Date: Thu, 3 Dec 2020 12:03:42 +0800 Subject: [PATCH 3/4] Fix the issue of document --- src/CostManagement/help/New-AzCostManagementExport.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/CostManagement/help/New-AzCostManagementExport.md b/src/CostManagement/help/New-AzCostManagementExport.md index 7e575be45fc5..6f61f45cd5e3 100644 --- a/src/CostManagement/help/New-AzCostManagementExport.md +++ b/src/CostManagement/help/New-AzCostManagementExport.md @@ -171,12 +171,6 @@ Accept wildcard characters: False ``` ### -Format -[Parameter()] -[Microsoft.Azure.PowerShell.Cmdlets.CostManagement.Category('Body')] -[System.String] -# eTag of the resource. -# To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not. -${ETag}, The format of the export being delivered. Currently only 'Csv' is supported. From 670383541a5ef195518395d2c665253c45abc669 Mon Sep 17 00:00:00 2001 From: wyunchi-ms Date: Thu, 3 Dec 2020 12:20:47 +0800 Subject: [PATCH 4/4] Add release notes for Costmanagement. --- src/CostManagement/Az.CostManagement.psd1 | 2 +- src/CostManagement/Changelog.md | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/CostManagement/Az.CostManagement.psd1 b/src/CostManagement/Az.CostManagement.psd1 index 129670e8a64f..bef24deb4b89 100644 --- a/src/CostManagement/Az.CostManagement.psd1 +++ b/src/CostManagement/Az.CostManagement.psd1 @@ -113,7 +113,7 @@ PrivateData = @{ # IconUri = '' # ReleaseNotes of this module - # ReleaseNotes = '' + ReleaseNotes = '* First preview release for module Az.CostManagement.' # Prerelease string of this module # Prerelease = '' diff --git a/src/CostManagement/Changelog.md b/src/CostManagement/Changelog.md index 0d05b23c2c38..a8a29db2e3de 100644 --- a/src/CostManagement/Changelog.md +++ b/src/CostManagement/Changelog.md @@ -18,5 +18,7 @@ - Additional information about change #1 --> ## Upcoming Release + +## Version 0.1.0 * First preview release for module Az.CostManagement